OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_ANDROID_H_ | 5 #ifndef CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_ANDROID_H_ |
6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_ANDROID_H_ | 6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_ANDROID_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 #include <memory> | |
12 | 11 |
13 #include "base/android/jni_weak_ref.h" | 12 #include "base/android/jni_weak_ref.h" |
14 #include "base/callback.h" | 13 #include "base/callback.h" |
15 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
16 #include "base/macros.h" | 15 #include "base/macros.h" |
17 #include "base/time/time.h" | 16 #include "base/time/time.h" |
18 #include "components/invalidation/public/invalidation_util.h" | 17 #include "components/invalidation/public/invalidation_util.h" |
19 #include "components/sync/driver/sync_prefs.h" | 18 #include "components/sync/driver/sync_prefs.h" |
20 #include "components/sync/driver/sync_service_observer.h" | 19 #include "components/sync/driver/sync_service_observer.h" |
21 #include "google/cacheinvalidation/include/types.h" | 20 #include "google/cacheinvalidation/include/types.h" |
22 #include "google_apis/gaia/google_service_auth_error.h" | 21 #include "google_apis/gaia/google_service_auth_error.h" |
23 | 22 |
24 class Profile; | 23 class Profile; |
25 | 24 |
26 namespace browser_sync { | 25 namespace browser_sync { |
27 class ProfileSyncService; | 26 class ProfileSyncService; |
28 } | 27 } |
29 | 28 |
30 namespace syncer { | 29 namespace sync_driver { |
31 class SyncSetupInProgressHandle; | 30 class SyncSetupInProgressHandle; |
32 } | 31 } |
33 | 32 |
34 // Android wrapper of the ProfileSyncService which provides access from the Java | 33 // Android wrapper of the ProfileSyncService which provides access from the Java |
35 // layer. Note that on Android, there's only a single profile, and therefore | 34 // layer. Note that on Android, there's only a single profile, and therefore |
36 // a single instance of this wrapper. The name of the Java class is | 35 // a single instance of this wrapper. The name of the Java class is |
37 // ProfileSyncService. | 36 // ProfileSyncService. |
38 // This class should only be accessed from the UI thread. | 37 // This class should only be accessed from the UI thread. |
39 class ProfileSyncServiceAndroid : public syncer::SyncServiceObserver { | 38 class ProfileSyncServiceAndroid : public sync_driver::SyncServiceObserver { |
40 public: | 39 public: |
| 40 |
41 ProfileSyncServiceAndroid(JNIEnv* env, jobject obj); | 41 ProfileSyncServiceAndroid(JNIEnv* env, jobject obj); |
42 ~ProfileSyncServiceAndroid() override; | 42 ~ProfileSyncServiceAndroid() override; |
43 | 43 |
44 // This method should be called once right after contructing the object. | 44 // This method should be called once right after contructing the object. |
45 // Returns false if we didn't get a ProfileSyncService. | 45 // Returns false if we didn't get a ProfileSyncService. |
46 bool Init(); | 46 bool Init(); |
47 | 47 |
48 // syncer::SyncServiceObserver: | 48 // sync_driver::SyncServiceObserver: |
49 void OnStateChanged() override; | 49 void OnStateChanged() override; |
50 | 50 |
51 // Pure ProfileSyncService calls. | 51 // Pure ProfileSyncService calls. |
52 jboolean IsSyncRequested(JNIEnv* env, | 52 jboolean IsSyncRequested(JNIEnv* env, |
53 const base::android::JavaParamRef<jobject>& obj); | 53 const base::android::JavaParamRef<jobject>& obj); |
54 void RequestStart(JNIEnv* env, | 54 void RequestStart(JNIEnv* env, |
55 const base::android::JavaParamRef<jobject>& obj); | 55 const base::android::JavaParamRef<jobject>& obj); |
56 void RequestStop(JNIEnv* env, | 56 void RequestStop(JNIEnv* env, |
57 const base::android::JavaParamRef<jobject>& obj); | 57 const base::android::JavaParamRef<jobject>& obj); |
58 void SignOutSync(JNIEnv* env, | 58 void SignOutSync(JNIEnv* env, |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 // Returns whether sync is allowed by Android. | 198 // Returns whether sync is allowed by Android. |
199 bool IsSyncAllowedByAndroid() const; | 199 bool IsSyncAllowedByAndroid() const; |
200 | 200 |
201 // A reference to the Chrome profile object. | 201 // A reference to the Chrome profile object. |
202 Profile* profile_; | 202 Profile* profile_; |
203 | 203 |
204 // A reference to the sync service for this profile. | 204 // A reference to the sync service for this profile. |
205 browser_sync::ProfileSyncService* sync_service_; | 205 browser_sync::ProfileSyncService* sync_service_; |
206 | 206 |
207 // Prevents Sync from running until configuration is complete. | 207 // Prevents Sync from running until configuration is complete. |
208 std::unique_ptr<syncer::SyncSetupInProgressHandle> sync_blocker_; | 208 std::unique_ptr<sync_driver::SyncSetupInProgressHandle> sync_blocker_; |
209 | 209 |
210 // The class that handles getting, setting, and persisting sync | 210 // The class that handles getting, setting, and persisting sync |
211 // preferences. | 211 // preferences. |
212 std::unique_ptr<syncer::SyncPrefs> sync_prefs_; | 212 std::unique_ptr<sync_driver::SyncPrefs> sync_prefs_; |
213 | 213 |
214 // Java-side ProfileSyncService object. | 214 // Java-side ProfileSyncService object. |
215 JavaObjectWeakGlobalRef weak_java_profile_sync_service_; | 215 JavaObjectWeakGlobalRef weak_java_profile_sync_service_; |
216 | 216 |
217 DISALLOW_COPY_AND_ASSIGN(ProfileSyncServiceAndroid); | 217 DISALLOW_COPY_AND_ASSIGN(ProfileSyncServiceAndroid); |
218 }; | 218 }; |
219 | 219 |
220 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_ANDROID_H_ | 220 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_ANDROID_H_ |
OLD | NEW |