forked from sanyaade-mobiledev/chromium.src
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Massive refactor of the Android invalidation code.
We want the invalidations code to exist as a component independent of sync (see bug). This CL seeks to move toward that for the Android invalidations codebase. Generally, things moved from //chrome/browser/invalidation to //components/invalidation, even if git didn't mark them as moves. To accomplish this, I had to unify where the JNI occurred. In Java, InvalidationService was renamed to InvalidationClientService as the class that communicates with GCM. A new InvalidationService class was introduced to handle JNI and other Java entry points to the component. Several methods from ProfileSyncService and InvalidationController moved to it. InvalidationController is now the bridge between sync and the invalidation component, and has no JNI nor C++ counterpart. InvalidationServiceFactory was added to assist in the creation and management of InvalidationService objects across the JNI boundary. BUG=259559 Review URL: https://codereview.chromium.org/459513002 Cr-Commit-Position: refs/heads/master@{#297202}
- Loading branch information
maxbogue
authored and
Commit bot
committed
Sep 29, 2014
1 parent
1c629b0
commit b8d6efc
Showing
42 changed files
with
868 additions
and
694 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
include_rules = [ | ||
"+components/invalidation", | ||
"+jni", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...android/java/src/org/chromium/chrome/browser/invalidation/InvalidationServiceFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright 2014 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
package org.chromium.chrome.browser.invalidation; | ||
|
||
import android.content.Context; | ||
|
||
import org.chromium.base.JNINamespace; | ||
import org.chromium.base.ThreadUtils; | ||
import org.chromium.chrome.browser.profiles.Profile; | ||
import org.chromium.components.invalidation.InvalidationService; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* InvalidationServiceFactory maps Profiles to instances of | ||
* {@link InvalidationService} instances. Each {@link Profile} will at most | ||
* have one instance of this service. If the service does not already exist, | ||
* it will be created on the first access. | ||
*/ | ||
@JNINamespace("invalidation") | ||
public final class InvalidationServiceFactory { | ||
|
||
private static final Map<Profile, InvalidationService> sServiceMap = | ||
new HashMap<Profile, InvalidationService>(); | ||
|
||
private InvalidationServiceFactory() {} | ||
|
||
/** | ||
* Returns Java InvalidationService for the given Profile. | ||
*/ | ||
public static InvalidationService getForProfile(Profile profile) { | ||
ThreadUtils.assertOnUiThread(); | ||
InvalidationService service = sServiceMap.get(profile); | ||
if (service == null) { | ||
service = nativeGetForProfile(profile); | ||
sServiceMap.put(profile, service); | ||
} | ||
return service; | ||
} | ||
|
||
public static InvalidationService getForTest(Context context) { | ||
return nativeGetForTest(context); | ||
} | ||
|
||
private static native InvalidationService nativeGetForProfile(Profile profile); | ||
private static native InvalidationService nativeGetForTest(Context context); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...e/android/javatests/src/org/chromium/chrome/browser/invalidation/IntentSavingContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright 2014 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
package org.chromium.chrome.browser.invalidation; | ||
|
||
import android.content.ComponentName; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.content.pm.PackageManager; | ||
|
||
import org.chromium.base.test.util.AdvancedMockContext; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* Mock context that saves all intents given to {@code startService}. | ||
*/ | ||
public class IntentSavingContext extends AdvancedMockContext { | ||
private final List<Intent> mStartedIntents = new ArrayList<Intent>(); | ||
|
||
IntentSavingContext(Context targetContext) { | ||
super(targetContext); | ||
} | ||
|
||
@Override | ||
public ComponentName startService(Intent intent) { | ||
mStartedIntents.add(intent); | ||
return new ComponentName(this, getClass()); | ||
} | ||
|
||
int getNumStartedIntents() { | ||
return mStartedIntents.size(); | ||
} | ||
|
||
Intent getStartedIntent(int idx) { | ||
return mStartedIntents.get(idx); | ||
} | ||
|
||
@Override | ||
public PackageManager getPackageManager() { | ||
return getBaseContext().getPackageManager(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.