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 | 11 |
12 #include "base/android/jni_weak_ref.h" | 12 #include "base/android/jni_weak_ref.h" |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
17 #include "components/invalidation/public/invalidation_util.h" | 17 #include "components/invalidation/public/invalidation_util.h" |
18 #include "components/sync/driver/sync_prefs.h" | 18 #include "components/sync/driver/sync_prefs.h" |
19 #include "components/sync/driver/sync_service_observer.h" | 19 #include "components/sync/driver/sync_service_observer.h" |
20 #include "google/cacheinvalidation/include/types.h" | 20 #include "google/cacheinvalidation/include/types.h" |
21 #include "google_apis/gaia/google_service_auth_error.h" | 21 #include "google_apis/gaia/google_service_auth_error.h" |
22 | 22 |
| 23 class Profile; |
| 24 |
| 25 namespace browser_sync { |
| 26 class ProfileSyncService; |
| 27 } |
| 28 |
23 namespace sync_driver { | 29 namespace sync_driver { |
24 class SyncSetupInProgressHandle; | 30 class SyncSetupInProgressHandle; |
25 } | 31 } |
26 | 32 |
27 class Profile; | |
28 class ProfileSyncService; | |
29 | |
30 // Android wrapper of the ProfileSyncService which provides access from the Java | 33 // Android wrapper of the ProfileSyncService which provides access from the Java |
31 // 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 |
32 // 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 |
33 // ProfileSyncService. | 36 // ProfileSyncService. |
34 // This class should only be accessed from the UI thread. | 37 // This class should only be accessed from the UI thread. |
35 class ProfileSyncServiceAndroid : public sync_driver::SyncServiceObserver { | 38 class ProfileSyncServiceAndroid : public sync_driver::SyncServiceObserver { |
36 public: | 39 public: |
37 | 40 |
38 ProfileSyncServiceAndroid(JNIEnv* env, jobject obj); | 41 ProfileSyncServiceAndroid(JNIEnv* env, jobject obj); |
39 ~ProfileSyncServiceAndroid() override; | 42 ~ProfileSyncServiceAndroid() override; |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 static bool Register(JNIEnv* env); | 195 static bool Register(JNIEnv* env); |
193 | 196 |
194 private: | 197 private: |
195 // Returns whether sync is allowed by Android. | 198 // Returns whether sync is allowed by Android. |
196 bool IsSyncAllowedByAndroid() const; | 199 bool IsSyncAllowedByAndroid() const; |
197 | 200 |
198 // A reference to the Chrome profile object. | 201 // A reference to the Chrome profile object. |
199 Profile* profile_; | 202 Profile* profile_; |
200 | 203 |
201 // A reference to the sync service for this profile. | 204 // A reference to the sync service for this profile. |
202 ProfileSyncService* sync_service_; | 205 browser_sync::ProfileSyncService* sync_service_; |
203 | 206 |
204 // Prevents Sync from running until configuration is complete. | 207 // Prevents Sync from running until configuration is complete. |
205 std::unique_ptr<sync_driver::SyncSetupInProgressHandle> sync_blocker_; | 208 std::unique_ptr<sync_driver::SyncSetupInProgressHandle> sync_blocker_; |
206 | 209 |
207 // The class that handles getting, setting, and persisting sync | 210 // The class that handles getting, setting, and persisting sync |
208 // preferences. | 211 // preferences. |
209 std::unique_ptr<sync_driver::SyncPrefs> sync_prefs_; | 212 std::unique_ptr<sync_driver::SyncPrefs> sync_prefs_; |
210 | 213 |
211 // Java-side ProfileSyncService object. | 214 // Java-side ProfileSyncService object. |
212 JavaObjectWeakGlobalRef weak_java_profile_sync_service_; | 215 JavaObjectWeakGlobalRef weak_java_profile_sync_service_; |
213 | 216 |
214 DISALLOW_COPY_AND_ASSIGN(ProfileSyncServiceAndroid); | 217 DISALLOW_COPY_AND_ASSIGN(ProfileSyncServiceAndroid); |
215 }; | 218 }; |
216 | 219 |
217 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_ANDROID_H_ | 220 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_ANDROID_H_ |
OLD | NEW |