Chromium Code Reviews| Index: components/invalidation/invalidation_service_android.h |
| diff --git a/chrome/browser/invalidation/invalidation_service_android.h b/components/invalidation/invalidation_service_android.h |
| similarity index 62% |
| rename from chrome/browser/invalidation/invalidation_service_android.h |
| rename to components/invalidation/invalidation_service_android.h |
| index 63af3fc3d0c3da60350409ac9b8c8cd9a9dbaf94..6790db3b909105baab2e700e604872b31f1b80f8 100644 |
| --- a/chrome/browser/invalidation/invalidation_service_android.h |
| +++ b/components/invalidation/invalidation_service_android.h |
| @@ -2,9 +2,14 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#ifndef CHROME_BROWSER_INVALIDATION_INVALIDATION_SERVICE_ANDROID_H_ |
| -#define CHROME_BROWSER_INVALIDATION_INVALIDATION_SERVICE_ANDROID_H_ |
| +#ifndef COMPONENTS_INVALIDATION_INVALIDATION_SERVICE_ANDROID_H_ |
| +#define COMPONENTS_INVALIDATION_INVALIDATION_SERVICE_ANDROID_H_ |
| +#include <jni.h> |
| +#include <map> |
| + |
| +#include "base/android/jni_android.h" |
| +#include "base/android/scoped_java_ref.h" |
| #include "base/basictypes.h" |
| #include "base/compiler_specific.h" |
| #include "base/memory/scoped_ptr.h" |
| @@ -13,28 +18,18 @@ |
| #include "components/invalidation/invalidation_service.h" |
| #include "components/invalidation/invalidator_registrar.h" |
| #include "components/keyed_service/core/keyed_service.h" |
| -#include "content/public/browser/notification_observer.h" |
| -#include "content/public/browser/notification_registrar.h" |
| - |
| -class Profile; |
| namespace invalidation { |
| -class InvalidationControllerAndroid; |
| + |
| class InvalidationLogger; |
| // This InvalidationService is used to deliver invalidations on Android. The |
| // Android operating system has its own mechanisms for delivering invalidations. |
| -// This class uses the NotificationService to communicate with a thin wrapper |
| -// around Android's invalidations service. |
| class InvalidationServiceAndroid |
| : public base::NonThreadSafe, |
| - public InvalidationService, |
| - public content::NotificationObserver { |
| + public InvalidationService { |
| public: |
| - // Takes ownership of |invalidation_controller|. |
| - InvalidationServiceAndroid( |
| - Profile* profile, |
| - InvalidationControllerAndroid* invalidation_controller); |
| + InvalidationServiceAndroid(jobject context); |
| virtual ~InvalidationServiceAndroid(); |
| // InvalidationService implementation. |
| @@ -57,28 +52,51 @@ class InvalidationServiceAndroid |
| OVERRIDE; |
| virtual IdentityProvider* GetIdentityProvider() OVERRIDE; |
| - // content::NotificationObserver implementation. |
| - virtual void Observe(int type, |
| - const content::NotificationSource& source, |
| - const content::NotificationDetails& details) OVERRIDE; |
| + void RequestSync(JNIEnv* env, |
|
nyquist
2014/09/04 09:01:56
Is RequestSync really the correct name now? Should
maxbogue
2014/09/05 16:42:46
Since this would require changing a lot of things,
|
| + jobject obj, |
| + jint object_source, |
| + jstring object_id, |
| + jlong version, |
| + jstring state); |
| + |
| + void RequestSyncForAllTypes(JNIEnv* env, jobject obj); |
| // The InvalidationServiceAndroid always reports that it is enabled. |
| // This is used only by unit tests. |
| void TriggerStateChangeForTest(syncer::InvalidatorState state); |
| + static bool RegisterJni(JNIEnv* env); |
| + |
| private: |
| + typedef std::map<invalidation::ObjectId, |
| + int64, |
| + syncer::ObjectIdLessThan> ObjectIdVersionMap; |
| + |
| + // Friend class so that InvalidationServiceFactoryAndroid has access to |
| + // private member object java_ref_. |
| + friend class InvalidationServiceFactoryAndroid; |
| + |
| + // Points to a Java instance of InvalidationService. |
| + base::android::ScopedJavaGlobalRef<jobject> java_ref_; |
| + |
| syncer::InvalidatorRegistrar invalidator_registrar_; |
| - content::NotificationRegistrar registrar_; |
| syncer::InvalidatorState invalidator_state_; |
| - scoped_ptr<InvalidationControllerAndroid> invalidation_controller_; |
| + |
| + // The invalidation API spec allows for the possibility of redundant |
| + // invalidations, so keep track of the max versions and drop |
| + // invalidations with old versions. |
| + ObjectIdVersionMap max_invalidation_versions_; |
| // The invalidation logger object we use to record state changes |
| // and invalidations. |
| InvalidationLogger logger_; |
| + void DispatchInvalidations( |
| + syncer::ObjectIdInvalidationMap& object_invalidation_map); |
| + |
| DISALLOW_COPY_AND_ASSIGN(InvalidationServiceAndroid); |
| }; |
| } // namespace invalidation |
| -#endif // CHROME_BROWSER_INVALIDATION_INVALIDATION_SERVICE_ANDROID_H_ |
| +#endif // COMPONENTS_INVALIDATION_INVALIDATION_SERVICE_ANDROID_H_ |