author | Jim Chen <nchen@mozilla.com> |
Wed, 15 Feb 2017 17:12:56 -0500 | |
changeset 343200 | 26359cfd0d245637ff7efc288098d07f1652d417 |
parent 343199 | c80d17b6ea4897766816f0f3ac9b005ce551cbd3 |
child 343201 | 8620e18b5878bdf7f9169364503aff9a910afa47 |
push id | 31372 |
push user | cbook@mozilla.com |
push date | Thu, 16 Feb 2017 12:16:10 +0000 |
treeherder | mozilla-central@2737f66ad6ac [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | snorp |
bugs | 1339160 |
milestone | 54.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
mobile/android/base/java/org/mozilla/gecko/GeckoService.java | file | annotate | diff | comparison | revisions |
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoService.java +++ b/mobile/android/base/java/org/mozilla/gecko/GeckoService.java @@ -26,16 +26,18 @@ public class GeckoService extends Servic private static final String LOGTAG = "GeckoService"; private static final boolean DEBUG = false; private static final String INTENT_PROFILE_NAME = "org.mozilla.gecko.intent.PROFILE_NAME"; private static final String INTENT_PROFILE_DIR = "org.mozilla.gecko.intent.PROFILE_DIR"; private static final String INTENT_ACTION_UPDATE_ADDONS = "update-addons"; private static final String INTENT_ACTION_CREATE_SERVICES = "create-services"; + private static final String INTENT_ACTION_LOAD_LIBS = "load-libs"; + private static final String INTENT_ACTION_START_GECKO = "start-gecko"; private static final String INTENT_SERVICE_CATEGORY = "category"; private static final String INTENT_SERVICE_DATA = "data"; private static class EventListener implements BundleEventListener { @Override // BundleEventListener public void handleMessage(final String event, final GeckoBundle message, @@ -127,25 +129,34 @@ public class GeckoService extends Servic intent.putExtra(INTENT_SERVICE_DATA, data); return intent; } public static Intent getIntentToCreateServices(final Context context, final String category) { return getIntentToCreateServices(context, category, /* data */ null); } + public static Intent getIntentToLoadLibs(final Context context) { + return getIntentForAction(context, INTENT_ACTION_LOAD_LIBS); + } + + public static Intent getIntentToStartGecko(final Context context) { + return getIntentForAction(context, INTENT_ACTION_START_GECKO); + } + public static void setIntentProfile(final Intent intent, final String profileName, final String profileDir) { intent.putExtra(INTENT_PROFILE_NAME, profileName); intent.putExtra(INTENT_PROFILE_DIR, profileDir); } - private int handleIntent(final Intent intent, final int startId) { - if (DEBUG) { - Log.d(LOGTAG, "Handling " + intent.getAction()); + private boolean initGecko(final Intent intent) { + if (INTENT_ACTION_LOAD_LIBS.equals(intent.getAction())) { + // Intentionally not initialize Gecko when only loading libs. + return true; } final String profileName = intent.getStringExtra(INTENT_PROFILE_NAME); final String profileDir = intent.getStringExtra(INTENT_PROFILE_DIR); if (profileName == null) { throw new IllegalArgumentException("Intent must specify profile."); } @@ -155,26 +166,41 @@ public class GeckoService extends Servic Log.w(LOGTAG, "Ignoring due to profile mismatch: " + profileName + " [" + profileDir + ']'); final GeckoProfile profile = GeckoThread.getActiveProfile(); if (profile != null) { Log.w(LOGTAG, "Current profile is " + profile.getName() + " [" + profile.getDir().getAbsolutePath() + ']'); } + return false; + } + return true; + } + + private int handleIntent(final Intent intent, final int startId) { + if (DEBUG) { + Log.d(LOGTAG, "Handling " + intent.getAction()); + } + + if (!initGecko(intent)) { stopSelf(startId); return Service.START_NOT_STICKY; } GeckoThread.launch(); switch (intent.getAction()) { case INTENT_ACTION_UPDATE_ADDONS: // Run the add-on update service. Because the service is automatically invoked // when loading Gecko, we don't have to do anything else here. + case INTENT_ACTION_LOAD_LIBS: + // Load libs only. Don't take any additional actions. + case INTENT_ACTION_START_GECKO: + // Load libs and start Gecko. Don't take any additional actions. break; case INTENT_ACTION_CREATE_SERVICES: final String category = intent.getStringExtra(INTENT_SERVICE_CATEGORY); final String data = intent.getStringExtra(INTENT_SERVICE_DATA); if (category == null) { break;