OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 COMPONENTS_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ | 5 #ifndef COMPONENTS_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
6 #define COMPONENTS_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ | 6 #define COMPONENTS_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 #include "components/sync/js/sync_js_controller.h" | 51 #include "components/sync/js/sync_js_controller.h" |
52 #include "components/version_info/version_info.h" | 52 #include "components/version_info/version_info.h" |
53 #include "google_apis/gaia/google_service_auth_error.h" | 53 #include "google_apis/gaia/google_service_auth_error.h" |
54 #include "google_apis/gaia/oauth2_token_service.h" | 54 #include "google_apis/gaia/oauth2_token_service.h" |
55 #include "net/base/backoff_entry.h" | 55 #include "net/base/backoff_entry.h" |
56 #include "url/gurl.h" | 56 #include "url/gurl.h" |
57 | 57 |
58 class Profile; | 58 class Profile; |
59 class ProfileOAuth2TokenService; | 59 class ProfileOAuth2TokenService; |
60 class SigninManagerWrapper; | 60 class SigninManagerWrapper; |
| 61 class SyncErrorController; |
| 62 class SyncTypePreferenceProvider; |
61 | 63 |
62 namespace sync_pb { | 64 namespace sync_driver { |
63 class EncryptedData; | 65 class DataTypeManager; |
64 } // namespace sync_pb | 66 class DeviceInfoSyncService; |
| 67 class DeviceInfoTracker; |
| 68 class LocalDeviceInfoProvider; |
| 69 class SyncApiComponentFactory; |
| 70 class SyncClient; |
| 71 } // namespace sync_driver |
| 72 |
| 73 namespace sync_driver_v2 { |
| 74 class DeviceInfoService; |
| 75 } |
65 | 76 |
66 namespace sync_sessions { | 77 namespace sync_sessions { |
67 class FaviconCache; | 78 class FaviconCache; |
68 class OpenTabsUIDelegate; | 79 class OpenTabsUIDelegate; |
69 class SessionsSyncManager; | 80 class SessionsSyncManager; |
70 } // namespace sync_sessions | 81 } // namespace sync_sessions |
71 | 82 |
72 namespace syncer { | 83 namespace syncer { |
73 class BackendMigrator; | |
74 class BaseTransaction; | 84 class BaseTransaction; |
75 class DataTypeManager; | |
76 class DeviceInfoService; | |
77 class DeviceInfoSyncService; | |
78 class DeviceInfoTracker; | |
79 class LocalDeviceInfoProvider; | |
80 class NetworkResources; | 85 class NetworkResources; |
81 class SyncApiComponentFactory; | |
82 class SyncClient; | |
83 class SyncErrorController; | |
84 class SyncTypePreferenceProvider; | |
85 class TypeDebugInfoObserver; | 86 class TypeDebugInfoObserver; |
86 struct CommitCounters; | 87 struct CommitCounters; |
87 struct StatusCounters; | 88 struct StatusCounters; |
88 struct SyncCredentials; | 89 struct SyncCredentials; |
89 struct UpdateCounters; | 90 struct UpdateCounters; |
90 struct UserShare; | 91 struct UserShare; |
91 } // namespace syncer | 92 } // namespace syncer |
92 | 93 |
| 94 namespace sync_pb { |
| 95 class EncryptedData; |
| 96 } // namespace sync_pb |
| 97 |
93 namespace browser_sync { | 98 namespace browser_sync { |
94 | 99 |
| 100 class BackendMigrator; |
| 101 |
95 // ProfileSyncService is the layer between browser subsystems like bookmarks, | 102 // ProfileSyncService is the layer between browser subsystems like bookmarks, |
96 // and the sync backend. Each subsystem is logically thought of as being | 103 // and the sync backend. Each subsystem is logically thought of as being |
97 // a sync datatype. | 104 // a sync datatype. |
98 // | 105 // |
99 // Individual datatypes can, at any point, be in a variety of stages of being | 106 // Individual datatypes can, at any point, be in a variety of stages of being |
100 // "enabled". Here are some specific terms for concepts used in this class: | 107 // "enabled". Here are some specific terms for concepts used in this class: |
101 // | 108 // |
102 // 'Registered' (feature suppression for a datatype) | 109 // 'Registered' (feature suppression for a datatype) |
103 // | 110 // |
104 // When a datatype is registered, the user has the option of syncing it. | 111 // When a datatype is registered, the user has the option of syncing it. |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 // * GetSetupInProgressHandle() | 171 // * GetSetupInProgressHandle() |
165 // | 172 // |
166 // SetFirstSetupComplete() should be called once the user has finished setting | 173 // SetFirstSetupComplete() should be called once the user has finished setting |
167 // up sync at least once on their account. GetSetupInProgressHandle() should | 174 // up sync at least once on their account. GetSetupInProgressHandle() should |
168 // be called while the user is actively configuring their account. The handle | 175 // be called while the user is actively configuring their account. The handle |
169 // should be deleted once configuration is complete. | 176 // should be deleted once configuration is complete. |
170 // | 177 // |
171 // Once first setup has completed and there are no outstanding | 178 // Once first setup has completed and there are no outstanding |
172 // setup-in-progress handles, CanConfigureDataTypes() will return true and | 179 // setup-in-progress handles, CanConfigureDataTypes() will return true and |
173 // datatype configuration can begin. | 180 // datatype configuration can begin. |
174 class ProfileSyncService : public syncer::SyncService, | 181 class ProfileSyncService : public sync_driver::SyncService, |
175 public syncer::SyncFrontend, | 182 public sync_driver::SyncFrontend, |
176 public syncer::SyncPrefObserver, | 183 public sync_driver::SyncPrefObserver, |
177 public syncer::DataTypeManagerObserver, | 184 public sync_driver::DataTypeManagerObserver, |
178 public syncer::UnrecoverableErrorHandler, | 185 public syncer::UnrecoverableErrorHandler, |
179 public KeyedService, | 186 public KeyedService, |
180 public OAuth2TokenService::Consumer, | 187 public OAuth2TokenService::Consumer, |
181 public OAuth2TokenService::Observer, | 188 public OAuth2TokenService::Observer, |
182 public SigninManagerBase::Observer, | 189 public SigninManagerBase::Observer, |
183 public GaiaCookieManagerService::Observer { | 190 public GaiaCookieManagerService::Observer { |
184 public: | 191 public: |
185 typedef syncer::SyncBackendHost::Status Status; | 192 typedef SyncBackendHost::Status Status; |
186 typedef base::Callback<bool(void)> PlatformSyncAllowedProvider; | 193 typedef base::Callback<bool(void)> PlatformSyncAllowedProvider; |
187 | 194 |
188 enum SyncEventCodes { | 195 enum SyncEventCodes { |
189 MIN_SYNC_EVENT_CODE = 0, | 196 MIN_SYNC_EVENT_CODE = 0, |
190 | 197 |
191 // Events starting the sync service. | 198 // Events starting the sync service. |
192 START_FROM_NTP = 1, // Sync was started from the ad in NTP | 199 START_FROM_NTP = 1, // Sync was started from the ad in NTP |
193 START_FROM_WRENCH = 2, // Sync was started from the Wrench menu. | 200 START_FROM_WRENCH = 2, // Sync was started from the Wrench menu. |
194 START_FROM_OPTIONS = 3, // Sync was started from Wrench->Options. | 201 START_FROM_OPTIONS = 3, // Sync was started from Wrench->Options. |
195 START_FROM_BOOKMARK_MANAGER = 4, // Sync was started from Bookmark manager. | 202 START_FROM_BOOKMARK_MANAGER = 4, // Sync was started from Bookmark manager. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 | 236 |
230 // Bundles the arguments for ProfileSyncService construction. This is a | 237 // Bundles the arguments for ProfileSyncService construction. This is a |
231 // movable struct. Because of the non-POD data members, it needs out-of-line | 238 // movable struct. Because of the non-POD data members, it needs out-of-line |
232 // constructors, so in particular the move constructor needs to be | 239 // constructors, so in particular the move constructor needs to be |
233 // explicitly defined. | 240 // explicitly defined. |
234 struct InitParams { | 241 struct InitParams { |
235 InitParams(); | 242 InitParams(); |
236 ~InitParams(); | 243 ~InitParams(); |
237 InitParams(InitParams&& other); // NOLINT | 244 InitParams(InitParams&& other); // NOLINT |
238 | 245 |
239 std::unique_ptr<syncer::SyncClient> sync_client; | 246 std::unique_ptr<sync_driver::SyncClient> sync_client; |
240 std::unique_ptr<SigninManagerWrapper> signin_wrapper; | 247 std::unique_ptr<SigninManagerWrapper> signin_wrapper; |
241 ProfileOAuth2TokenService* oauth2_token_service = nullptr; | 248 ProfileOAuth2TokenService* oauth2_token_service = nullptr; |
242 GaiaCookieManagerService* gaia_cookie_manager_service = nullptr; | 249 GaiaCookieManagerService* gaia_cookie_manager_service = nullptr; |
243 StartBehavior start_behavior = MANUAL_START; | 250 StartBehavior start_behavior = MANUAL_START; |
244 syncer::NetworkTimeUpdateCallback network_time_update_callback; | 251 syncer::NetworkTimeUpdateCallback network_time_update_callback; |
245 base::FilePath base_directory; | 252 base::FilePath base_directory; |
246 scoped_refptr<net::URLRequestContextGetter> url_request_context; | 253 scoped_refptr<net::URLRequestContextGetter> url_request_context; |
247 std::string debug_identifier; | 254 std::string debug_identifier; |
248 version_info::Channel channel = version_info::Channel::UNKNOWN; | 255 version_info::Channel channel = version_info::Channel::UNKNOWN; |
249 scoped_refptr<base::SingleThreadTaskRunner> db_thread; | 256 scoped_refptr<base::SingleThreadTaskRunner> db_thread; |
250 scoped_refptr<base::SingleThreadTaskRunner> file_thread; | 257 scoped_refptr<base::SingleThreadTaskRunner> file_thread; |
251 base::SequencedWorkerPool* blocking_pool = nullptr; | 258 base::SequencedWorkerPool* blocking_pool = nullptr; |
252 | 259 |
253 private: | 260 private: |
254 DISALLOW_COPY_AND_ASSIGN(InitParams); | 261 DISALLOW_COPY_AND_ASSIGN(InitParams); |
255 }; | 262 }; |
256 | 263 |
257 explicit ProfileSyncService(InitParams init_params); | 264 explicit ProfileSyncService(InitParams init_params); |
258 | 265 |
259 ~ProfileSyncService() override; | 266 ~ProfileSyncService() override; |
260 | 267 |
261 // Initializes the object. This must be called at most once, and | 268 // Initializes the object. This must be called at most once, and |
262 // immediately after an object of this class is constructed. | 269 // immediately after an object of this class is constructed. |
263 void Initialize(); | 270 void Initialize(); |
264 | 271 |
265 // syncer::SyncService implementation | 272 // sync_driver::SyncService implementation |
266 bool IsFirstSetupComplete() const override; | 273 bool IsFirstSetupComplete() const override; |
267 bool IsSyncAllowed() const override; | 274 bool IsSyncAllowed() const override; |
268 bool IsSyncActive() const override; | 275 bool IsSyncActive() const override; |
269 void TriggerRefresh(const syncer::ModelTypeSet& types) override; | 276 void TriggerRefresh(const syncer::ModelTypeSet& types) override; |
270 void OnDataTypeRequestsSyncStartup(syncer::ModelType type) override; | 277 void OnDataTypeRequestsSyncStartup(syncer::ModelType type) override; |
271 bool CanSyncStart() const override; | 278 bool CanSyncStart() const override; |
272 void RequestStop(SyncStopDataFate data_fate) override; | 279 void RequestStop(SyncStopDataFate data_fate) override; |
273 void RequestStart() override; | 280 void RequestStart() override; |
274 syncer::ModelTypeSet GetActiveDataTypes() const override; | 281 syncer::ModelTypeSet GetActiveDataTypes() const override; |
275 syncer::SyncClient* GetSyncClient() const override; | 282 sync_driver::SyncClient* GetSyncClient() const override; |
276 syncer::ModelTypeSet GetPreferredDataTypes() const override; | 283 syncer::ModelTypeSet GetPreferredDataTypes() const override; |
277 void OnUserChoseDatatypes(bool sync_everything, | 284 void OnUserChoseDatatypes(bool sync_everything, |
278 syncer::ModelTypeSet chosen_types) override; | 285 syncer::ModelTypeSet chosen_types) override; |
279 void SetFirstSetupComplete() override; | 286 void SetFirstSetupComplete() override; |
280 bool IsFirstSetupInProgress() const override; | 287 bool IsFirstSetupInProgress() const override; |
281 std::unique_ptr<syncer::SyncSetupInProgressHandle> GetSetupInProgressHandle() | 288 std::unique_ptr<sync_driver::SyncSetupInProgressHandle> |
282 override; | 289 GetSetupInProgressHandle() override; |
283 bool IsSetupInProgress() const override; | 290 bool IsSetupInProgress() const override; |
284 bool ConfigurationDone() const override; | 291 bool ConfigurationDone() const override; |
285 const GoogleServiceAuthError& GetAuthError() const override; | 292 const GoogleServiceAuthError& GetAuthError() const override; |
286 bool HasUnrecoverableError() const override; | 293 bool HasUnrecoverableError() const override; |
287 bool IsBackendInitialized() const override; | 294 bool IsBackendInitialized() const override; |
288 sync_sessions::OpenTabsUIDelegate* GetOpenTabsUIDelegate() override; | 295 sync_sessions::OpenTabsUIDelegate* GetOpenTabsUIDelegate() override; |
289 bool IsPassphraseRequiredForDecryption() const override; | 296 bool IsPassphraseRequiredForDecryption() const override; |
290 base::Time GetExplicitPassphraseTime() const override; | 297 base::Time GetExplicitPassphraseTime() const override; |
291 bool IsUsingSecondaryPassphrase() const override; | 298 bool IsUsingSecondaryPassphrase() const override; |
292 void EnableEncryptEverything() override; | 299 void EnableEncryptEverything() override; |
293 bool IsEncryptEverythingEnabled() const override; | 300 bool IsEncryptEverythingEnabled() const override; |
294 void SetEncryptionPassphrase(const std::string& passphrase, | 301 void SetEncryptionPassphrase(const std::string& passphrase, |
295 PassphraseType type) override; | 302 PassphraseType type) override; |
296 bool SetDecryptionPassphrase(const std::string& passphrase) override | 303 bool SetDecryptionPassphrase(const std::string& passphrase) override |
297 WARN_UNUSED_RESULT; | 304 WARN_UNUSED_RESULT; |
298 bool IsCryptographerReady( | 305 bool IsCryptographerReady( |
299 const syncer::BaseTransaction* trans) const override; | 306 const syncer::BaseTransaction* trans) const override; |
300 syncer::UserShare* GetUserShare() const override; | 307 syncer::UserShare* GetUserShare() const override; |
301 syncer::LocalDeviceInfoProvider* GetLocalDeviceInfoProvider() const override; | 308 sync_driver::LocalDeviceInfoProvider* GetLocalDeviceInfoProvider() |
302 void AddObserver(syncer::SyncServiceObserver* observer) override; | 309 const override; |
303 void RemoveObserver(syncer::SyncServiceObserver* observer) override; | 310 void AddObserver(sync_driver::SyncServiceObserver* observer) override; |
304 bool HasObserver(const syncer::SyncServiceObserver* observer) const override; | 311 void RemoveObserver(sync_driver::SyncServiceObserver* observer) override; |
305 void RegisterDataTypeController(std::unique_ptr<syncer::DataTypeController> | 312 bool HasObserver( |
306 data_type_controller) override; | 313 const sync_driver::SyncServiceObserver* observer) const override; |
| 314 void RegisterDataTypeController( |
| 315 std::unique_ptr<sync_driver::DataTypeController> data_type_controller) |
| 316 override; |
307 void ReenableDatatype(syncer::ModelType type) override; | 317 void ReenableDatatype(syncer::ModelType type) override; |
308 SyncTokenStatus GetSyncTokenStatus() const override; | 318 SyncTokenStatus GetSyncTokenStatus() const override; |
309 std::string QuerySyncStatusSummaryString() override; | 319 std::string QuerySyncStatusSummaryString() override; |
310 bool QueryDetailedSyncStatus(syncer::SyncStatus* result) override; | 320 bool QueryDetailedSyncStatus(syncer::SyncStatus* result) override; |
311 base::string16 GetLastSyncedTimeString() const override; | 321 base::string16 GetLastSyncedTimeString() const override; |
312 std::string GetBackendInitializationStateString() const override; | 322 std::string GetBackendInitializationStateString() const override; |
313 syncer::SyncCycleSnapshot GetLastCycleSnapshot() const override; | 323 syncer::SyncCycleSnapshot GetLastCycleSnapshot() const override; |
314 base::Value* GetTypeStatusMap() const override; | 324 base::Value* GetTypeStatusMap() const override; |
315 const GURL& sync_service_url() const override; | 325 const GURL& sync_service_url() const override; |
316 std::string unrecoverable_error_message() const override; | 326 std::string unrecoverable_error_message() const override; |
317 tracked_objects::Location unrecoverable_error_location() const override; | 327 tracked_objects::Location unrecoverable_error_location() const override; |
318 void AddProtocolEventObserver( | 328 void AddProtocolEventObserver(ProtocolEventObserver* observer) override; |
319 syncer::ProtocolEventObserver* observer) override; | 329 void RemoveProtocolEventObserver(ProtocolEventObserver* observer) override; |
320 void RemoveProtocolEventObserver( | |
321 syncer::ProtocolEventObserver* observer) override; | |
322 void AddTypeDebugInfoObserver( | 330 void AddTypeDebugInfoObserver( |
323 syncer::TypeDebugInfoObserver* observer) override; | 331 syncer::TypeDebugInfoObserver* observer) override; |
324 void RemoveTypeDebugInfoObserver( | 332 void RemoveTypeDebugInfoObserver( |
325 syncer::TypeDebugInfoObserver* observer) override; | 333 syncer::TypeDebugInfoObserver* observer) override; |
326 base::WeakPtr<syncer::JsController> GetJsController() override; | 334 base::WeakPtr<syncer::JsController> GetJsController() override; |
327 void GetAllNodes(const base::Callback<void(std::unique_ptr<base::ListValue>)>& | 335 void GetAllNodes(const base::Callback<void(std::unique_ptr<base::ListValue>)>& |
328 callback) override; | 336 callback) override; |
329 | 337 |
330 // Add a sync type preference provider. Each provider may only be added once. | 338 // Add a sync type preference provider. Each provider may only be added once. |
331 void AddPreferenceProvider(syncer::SyncTypePreferenceProvider* provider); | 339 void AddPreferenceProvider(SyncTypePreferenceProvider* provider); |
332 // Remove a sync type preference provider. May only be called for providers | 340 // Remove a sync type preference provider. May only be called for providers |
333 // that have been added. Providers must not remove themselves while being | 341 // that have been added. Providers must not remove themselves while being |
334 // called back. | 342 // called back. |
335 void RemovePreferenceProvider(syncer::SyncTypePreferenceProvider* provider); | 343 void RemovePreferenceProvider(SyncTypePreferenceProvider* provider); |
336 // Check whether a given sync type preference provider has been added. | 344 // Check whether a given sync type preference provider has been added. |
337 bool HasPreferenceProvider( | 345 bool HasPreferenceProvider(SyncTypePreferenceProvider* provider) const; |
338 syncer::SyncTypePreferenceProvider* provider) const; | |
339 | 346 |
340 void RegisterAuthNotifications(); | 347 void RegisterAuthNotifications(); |
341 void UnregisterAuthNotifications(); | 348 void UnregisterAuthNotifications(); |
342 | 349 |
343 // Returns the SyncableService for syncer::SESSIONS. | 350 // Returns the SyncableService for syncer::SESSIONS. |
344 virtual syncer::SyncableService* GetSessionsSyncableService(); | 351 virtual syncer::SyncableService* GetSessionsSyncableService(); |
345 | 352 |
346 // Returns the SyncableService for syncer::DEVICE_INFO. | 353 // Returns the SyncableService for syncer::DEVICE_INFO. |
347 virtual syncer::SyncableService* GetDeviceInfoSyncableService(); | 354 virtual syncer::SyncableService* GetDeviceInfoSyncableService(); |
348 | 355 |
349 // Returns the ModelTypeService for syncer::DEVICE_INFO. | 356 // Returns the ModelTypeService for syncer::DEVICE_INFO. |
350 virtual syncer::ModelTypeService* GetDeviceInfoService(); | 357 virtual syncer_v2::ModelTypeService* GetDeviceInfoService(); |
351 | 358 |
352 // Returns synced devices tracker. | 359 // Returns synced devices tracker. |
353 virtual syncer::DeviceInfoTracker* GetDeviceInfoTracker() const; | 360 virtual sync_driver::DeviceInfoTracker* GetDeviceInfoTracker() const; |
354 | 361 |
355 // Fills state_map with a map of current data types that are possible to | 362 // Fills state_map with a map of current data types that are possible to |
356 // sync, as well as their states. | 363 // sync, as well as their states. |
357 void GetDataTypeControllerStates( | 364 void GetDataTypeControllerStates( |
358 syncer::DataTypeController::StateMap* state_map) const; | 365 sync_driver::DataTypeController::StateMap* state_map) const; |
359 | 366 |
360 // Called when asynchronous session restore has completed. | 367 // Called when asynchronous session restore has completed. |
361 void OnSessionRestoreComplete(); | 368 void OnSessionRestoreComplete(); |
362 | 369 |
363 // SyncFrontend implementation. | 370 // SyncFrontend implementation. |
364 void OnBackendInitialized( | 371 void OnBackendInitialized( |
365 const syncer::WeakHandle<syncer::JsBackend>& js_backend, | 372 const syncer::WeakHandle<syncer::JsBackend>& js_backend, |
366 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>& | 373 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>& |
367 debug_info_listener, | 374 debug_info_listener, |
368 const std::string& cache_guid, | 375 const std::string& cache_guid, |
(...skipping 18 matching lines...) Expand all Loading... |
387 bool encrypt_everything) override; | 394 bool encrypt_everything) override; |
388 void OnEncryptionComplete() override; | 395 void OnEncryptionComplete() override; |
389 void OnMigrationNeededForTypes(syncer::ModelTypeSet types) override; | 396 void OnMigrationNeededForTypes(syncer::ModelTypeSet types) override; |
390 void OnExperimentsChanged(const syncer::Experiments& experiments) override; | 397 void OnExperimentsChanged(const syncer::Experiments& experiments) override; |
391 void OnActionableError(const syncer::SyncProtocolError& error) override; | 398 void OnActionableError(const syncer::SyncProtocolError& error) override; |
392 void OnLocalSetPassphraseEncryption( | 399 void OnLocalSetPassphraseEncryption( |
393 const syncer::SyncEncryptionHandler::NigoriState& nigori_state) override; | 400 const syncer::SyncEncryptionHandler::NigoriState& nigori_state) override; |
394 | 401 |
395 // DataTypeManagerObserver implementation. | 402 // DataTypeManagerObserver implementation. |
396 void OnConfigureDone( | 403 void OnConfigureDone( |
397 const syncer::DataTypeManager::ConfigureResult& result) override; | 404 const sync_driver::DataTypeManager::ConfigureResult& result) override; |
398 void OnConfigureStart() override; | 405 void OnConfigureStart() override; |
399 | 406 |
400 // DataTypeEncryptionHandler implementation. | 407 // DataTypeEncryptionHandler implementation. |
401 bool IsPassphraseRequired() const override; | 408 bool IsPassphraseRequired() const override; |
402 syncer::ModelTypeSet GetEncryptedDataTypes() const override; | 409 syncer::ModelTypeSet GetEncryptedDataTypes() const override; |
403 | 410 |
404 // SigninManagerBase::Observer implementation. | 411 // SigninManagerBase::Observer implementation. |
405 void GoogleSigninSucceeded(const std::string& account_id, | 412 void GoogleSigninSucceeded(const std::string& account_id, |
406 const std::string& username, | 413 const std::string& username, |
407 const std::string& password) override; | 414 const std::string& password) override; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 // TODO(akalin): These two functions are used only by | 470 // TODO(akalin): These two functions are used only by |
464 // ProfileSyncServiceHarness. Figure out a different way to expose | 471 // ProfileSyncServiceHarness. Figure out a different way to expose |
465 // this info to that class, and remove these functions. | 472 // this info to that class, and remove these functions. |
466 | 473 |
467 // Returns whether or not the underlying sync engine has made any | 474 // Returns whether or not the underlying sync engine has made any |
468 // local changes to items that have not yet been synced with the | 475 // local changes to items that have not yet been synced with the |
469 // server. | 476 // server. |
470 bool HasUnsyncedItems() const; | 477 bool HasUnsyncedItems() const; |
471 | 478 |
472 // Used by ProfileSyncServiceHarness. May return NULL. | 479 // Used by ProfileSyncServiceHarness. May return NULL. |
473 syncer::BackendMigrator* GetBackendMigratorForTest(); | 480 BackendMigrator* GetBackendMigratorForTest(); |
474 | 481 |
475 // Used by tests to inspect interaction with OAuth2TokenService. | 482 // Used by tests to inspect interaction with OAuth2TokenService. |
476 bool IsRetryingAccessTokenFetchForTest() const; | 483 bool IsRetryingAccessTokenFetchForTest() const; |
477 | 484 |
478 // Used by tests to inspect the OAuth2 access tokens used by PSS. | 485 // Used by tests to inspect the OAuth2 access tokens used by PSS. |
479 std::string GetAccessTokenForTest() const; | 486 std::string GetAccessTokenForTest() const; |
480 | 487 |
481 // TODO(sync): This is only used in tests. Can we remove it? | 488 // TODO(sync): This is only used in tests. Can we remove it? |
482 void GetModelSafeRoutingInfo(syncer::ModelSafeRoutingInfo* out) const; | 489 void GetModelSafeRoutingInfo(syncer::ModelSafeRoutingInfo* out) const; |
483 | 490 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 virtual bool IsEncryptEverythingAllowed() const; | 522 virtual bool IsEncryptEverythingAllowed() const; |
516 | 523 |
517 // Sets whether encrypting all the sync data is allowed or not. | 524 // Sets whether encrypting all the sync data is allowed or not. |
518 virtual void SetEncryptEverythingAllowed(bool allowed); | 525 virtual void SetEncryptEverythingAllowed(bool allowed); |
519 | 526 |
520 // Returns true if the syncer is waiting for new datatypes to be encrypted. | 527 // Returns true if the syncer is waiting for new datatypes to be encrypted. |
521 virtual bool encryption_pending() const; | 528 virtual bool encryption_pending() const; |
522 | 529 |
523 SigninManagerBase* signin() const; | 530 SigninManagerBase* signin() const; |
524 | 531 |
525 syncer::SyncErrorController* sync_error_controller() { | 532 SyncErrorController* sync_error_controller() { |
526 return sync_error_controller_.get(); | 533 return sync_error_controller_.get(); |
527 } | 534 } |
528 | 535 |
529 // TODO(sync): This is only used in tests. Can we remove it? | 536 // TODO(sync): This is only used in tests. Can we remove it? |
530 const syncer::DataTypeStatusTable& data_type_status_table() const; | 537 const sync_driver::DataTypeStatusTable& data_type_status_table() const; |
531 | 538 |
532 syncer::DataTypeManager::ConfigureStatus configure_status() { | 539 sync_driver::DataTypeManager::ConfigureStatus configure_status() { |
533 return configure_status_; | 540 return configure_status_; |
534 } | 541 } |
535 | 542 |
536 // If true, the ProfileSyncService has detected that a new GAIA signin has | 543 // If true, the ProfileSyncService has detected that a new GAIA signin has |
537 // succeeded, and is waiting for initialization to complete. This is used by | 544 // succeeded, and is waiting for initialization to complete. This is used by |
538 // the UI to differentiate between a new auth error (encountered as part of | 545 // the UI to differentiate between a new auth error (encountered as part of |
539 // the initialization process) and a pre-existing auth error that just hasn't | 546 // the initialization process) and a pre-existing auth error that just hasn't |
540 // been cleared yet. Virtual for testing purposes. | 547 // been cleared yet. Virtual for testing purposes. |
541 virtual bool waiting_for_auth() const; | 548 virtual bool waiting_for_auth() const; |
542 | 549 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 const std::string& message, | 621 const std::string& message, |
615 bool delete_sync_database); | 622 bool delete_sync_database); |
616 | 623 |
617 // This is a cache of the last authentication response we received from the | 624 // This is a cache of the last authentication response we received from the |
618 // sync server. The UI queries this to display appropriate messaging to the | 625 // sync server. The UI queries this to display appropriate messaging to the |
619 // user. | 626 // user. |
620 GoogleServiceAuthError last_auth_error_; | 627 GoogleServiceAuthError last_auth_error_; |
621 | 628 |
622 // Our asynchronous backend to communicate with sync components living on | 629 // Our asynchronous backend to communicate with sync components living on |
623 // other threads. | 630 // other threads. |
624 std::unique_ptr<syncer::SyncBackendHost> backend_; | 631 std::unique_ptr<SyncBackendHost> backend_; |
625 | 632 |
626 // Was the last SYNC_PASSPHRASE_REQUIRED notification sent because it | 633 // Was the last SYNC_PASSPHRASE_REQUIRED notification sent because it |
627 // was required for encryption, decryption with a cached passphrase, or | 634 // was required for encryption, decryption with a cached passphrase, or |
628 // because a new passphrase is required? | 635 // because a new passphrase is required? |
629 syncer::PassphraseRequiredReason passphrase_required_reason_; | 636 syncer::PassphraseRequiredReason passphrase_required_reason_; |
630 | 637 |
631 private: | 638 private: |
632 enum UnrecoverableErrorReason { | 639 enum UnrecoverableErrorReason { |
633 ERROR_REASON_UNSET, | 640 ERROR_REASON_UNSET, |
634 ERROR_REASON_SYNCER, | 641 ERROR_REASON_SYNCER, |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 void OnClearServerDataDone(); | 795 void OnClearServerDataDone(); |
789 | 796 |
790 // True if setup has been completed at least once and is not in progress. | 797 // True if setup has been completed at least once and is not in progress. |
791 bool CanConfigureDataTypes() const; | 798 bool CanConfigureDataTypes() const; |
792 | 799 |
793 // Called when a SetupInProgressHandle issued by this instance is destroyed. | 800 // Called when a SetupInProgressHandle issued by this instance is destroyed. |
794 virtual void OnSetupInProgressHandleDestroyed(); | 801 virtual void OnSetupInProgressHandleDestroyed(); |
795 | 802 |
796 // This profile's SyncClient, which abstracts away non-Sync dependencies and | 803 // This profile's SyncClient, which abstracts away non-Sync dependencies and |
797 // the Sync API component factory. | 804 // the Sync API component factory. |
798 std::unique_ptr<syncer::SyncClient> sync_client_; | 805 std::unique_ptr<sync_driver::SyncClient> sync_client_; |
799 | 806 |
800 // The class that handles getting, setting, and persisting sync | 807 // The class that handles getting, setting, and persisting sync |
801 // preferences. | 808 // preferences. |
802 syncer::SyncPrefs sync_prefs_; | 809 sync_driver::SyncPrefs sync_prefs_; |
803 | 810 |
804 // TODO(ncarter): Put this in a profile, once there is UI for it. | 811 // TODO(ncarter): Put this in a profile, once there is UI for it. |
805 // This specifies where to find the sync server. | 812 // This specifies where to find the sync server. |
806 const GURL sync_service_url_; | 813 const GURL sync_service_url_; |
807 | 814 |
808 // The time that OnConfigureStart is called. This member is zero if | 815 // The time that OnConfigureStart is called. This member is zero if |
809 // OnConfigureStart has not yet been called, and is reset to zero once | 816 // OnConfigureStart has not yet been called, and is reset to zero once |
810 // OnConfigureDone is called. | 817 // OnConfigureDone is called. |
811 base::Time sync_configure_start_time_; | 818 base::Time sync_configure_start_time_; |
812 | 819 |
(...skipping 20 matching lines...) Expand all Loading... |
833 | 840 |
834 // Indicates if this is the first time sync is being configured. This value | 841 // Indicates if this is the first time sync is being configured. This value |
835 // is equal to !IsFirstSetupComplete() at the time of OnBackendInitialized(). | 842 // is equal to !IsFirstSetupComplete() at the time of OnBackendInitialized(). |
836 bool is_first_time_sync_configure_; | 843 bool is_first_time_sync_configure_; |
837 | 844 |
838 // Number of UIs currently configuring the Sync service. When this number | 845 // Number of UIs currently configuring the Sync service. When this number |
839 // is decremented back to zero, Sync setup is marked no longer in progress. | 846 // is decremented back to zero, Sync setup is marked no longer in progress. |
840 int outstanding_setup_in_progress_handles_ = 0; | 847 int outstanding_setup_in_progress_handles_ = 0; |
841 | 848 |
842 // List of available data type controllers. | 849 // List of available data type controllers. |
843 syncer::DataTypeController::TypeMap data_type_controllers_; | 850 sync_driver::DataTypeController::TypeMap data_type_controllers_; |
844 | 851 |
845 // Whether the SyncBackendHost has been initialized. | 852 // Whether the SyncBackendHost has been initialized. |
846 bool backend_initialized_; | 853 bool backend_initialized_; |
847 | 854 |
848 // Set when sync receives DISABLED_BY_ADMIN error from server. Prevents | 855 // Set when sync receives DISABLED_BY_ADMIN error from server. Prevents |
849 // ProfileSyncService from starting backend till browser restarted or user | 856 // ProfileSyncService from starting backend till browser restarted or user |
850 // signed out. | 857 // signed out. |
851 bool sync_disabled_by_admin_; | 858 bool sync_disabled_by_admin_; |
852 | 859 |
853 // Set to true if a signin has completed but we're still waiting for the | 860 // Set to true if a signin has completed but we're still waiting for the |
854 // backend to refresh its credentials. | 861 // backend to refresh its credentials. |
855 bool is_auth_in_progress_; | 862 bool is_auth_in_progress_; |
856 | 863 |
857 // Encapsulates user signin - used to set/get the user's authenticated | 864 // Encapsulates user signin - used to set/get the user's authenticated |
858 // email address. | 865 // email address. |
859 const std::unique_ptr<SigninManagerWrapper> signin_; | 866 const std::unique_ptr<SigninManagerWrapper> signin_; |
860 | 867 |
861 // Information describing an unrecoverable error. | 868 // Information describing an unrecoverable error. |
862 UnrecoverableErrorReason unrecoverable_error_reason_; | 869 UnrecoverableErrorReason unrecoverable_error_reason_; |
863 std::string unrecoverable_error_message_; | 870 std::string unrecoverable_error_message_; |
864 tracked_objects::Location unrecoverable_error_location_; | 871 tracked_objects::Location unrecoverable_error_location_; |
865 | 872 |
866 // Manages the start and stop of the data types. | 873 // Manages the start and stop of the data types. |
867 std::unique_ptr<syncer::DataTypeManager> data_type_manager_; | 874 std::unique_ptr<sync_driver::DataTypeManager> data_type_manager_; |
868 | 875 |
869 base::ObserverList<syncer::SyncServiceObserver> observers_; | 876 base::ObserverList<sync_driver::SyncServiceObserver> observers_; |
870 base::ObserverList<syncer::ProtocolEventObserver> protocol_event_observers_; | 877 base::ObserverList<ProtocolEventObserver> protocol_event_observers_; |
871 base::ObserverList<syncer::TypeDebugInfoObserver> type_debug_info_observers_; | 878 base::ObserverList<syncer::TypeDebugInfoObserver> type_debug_info_observers_; |
872 | 879 |
873 std::set<syncer::SyncTypePreferenceProvider*> preference_providers_; | 880 std::set<SyncTypePreferenceProvider*> preference_providers_; |
874 | 881 |
875 syncer::SyncJsController sync_js_controller_; | 882 syncer::SyncJsController sync_js_controller_; |
876 | 883 |
877 // This allows us to gracefully handle an ABORTED return code from the | 884 // This allows us to gracefully handle an ABORTED return code from the |
878 // DataTypeManager in the event that the server informed us to cease and | 885 // DataTypeManager in the event that the server informed us to cease and |
879 // desist syncing immediately. | 886 // desist syncing immediately. |
880 bool expect_sync_configuration_aborted_; | 887 bool expect_sync_configuration_aborted_; |
881 | 888 |
882 // Sometimes we need to temporarily hold on to a passphrase because we don't | 889 // Sometimes we need to temporarily hold on to a passphrase because we don't |
883 // yet have a backend to send it to. This happens during initialization as | 890 // yet have a backend to send it to. This happens during initialization as |
884 // we don't StartUp until we have a valid token, which happens after valid | 891 // we don't StartUp until we have a valid token, which happens after valid |
885 // credentials were provided. | 892 // credentials were provided. |
886 std::string cached_passphrase_; | 893 std::string cached_passphrase_; |
887 | 894 |
888 // The current set of encrypted types. Always a superset of | 895 // The current set of encrypted types. Always a superset of |
889 // syncer::Cryptographer::SensitiveTypes(). | 896 // syncer::Cryptographer::SensitiveTypes(). |
890 syncer::ModelTypeSet encrypted_types_; | 897 syncer::ModelTypeSet encrypted_types_; |
891 | 898 |
892 // Whether encrypting everything is allowed. | 899 // Whether encrypting everything is allowed. |
893 bool encrypt_everything_allowed_; | 900 bool encrypt_everything_allowed_; |
894 | 901 |
895 // Whether we want to encrypt everything. | 902 // Whether we want to encrypt everything. |
896 bool encrypt_everything_; | 903 bool encrypt_everything_; |
897 | 904 |
898 // Whether we're waiting for an attempt to encryption all sync data to | 905 // Whether we're waiting for an attempt to encryption all sync data to |
899 // complete. We track this at this layer in order to allow the user to cancel | 906 // complete. We track this at this layer in order to allow the user to cancel |
900 // if they e.g. don't remember their explicit passphrase. | 907 // if they e.g. don't remember their explicit passphrase. |
901 bool encryption_pending_; | 908 bool encryption_pending_; |
902 | 909 |
903 std::unique_ptr<syncer::BackendMigrator> migrator_; | 910 std::unique_ptr<BackendMigrator> migrator_; |
904 | 911 |
905 // This is the last |SyncProtocolError| we received from the server that had | 912 // This is the last |SyncProtocolError| we received from the server that had |
906 // an action set on it. | 913 // an action set on it. |
907 syncer::SyncProtocolError last_actionable_error_; | 914 syncer::SyncProtocolError last_actionable_error_; |
908 | 915 |
909 // Exposes sync errors to the UI. | 916 // Exposes sync errors to the UI. |
910 std::unique_ptr<syncer::SyncErrorController> sync_error_controller_; | 917 std::unique_ptr<SyncErrorController> sync_error_controller_; |
911 | 918 |
912 // Tracks the set of failed data types (those that encounter an error | 919 // Tracks the set of failed data types (those that encounter an error |
913 // or must delay loading for some reason). | 920 // or must delay loading for some reason). |
914 syncer::DataTypeStatusTable data_type_status_table_; | 921 sync_driver::DataTypeStatusTable data_type_status_table_; |
915 | 922 |
916 syncer::DataTypeManager::ConfigureStatus configure_status_; | 923 sync_driver::DataTypeManager::ConfigureStatus configure_status_; |
917 | 924 |
918 // The set of currently enabled sync experiments. | 925 // The set of currently enabled sync experiments. |
919 syncer::Experiments current_experiments_; | 926 syncer::Experiments current_experiments_; |
920 | 927 |
921 // Sync's internal debug info listener. Used to record datatype configuration | 928 // Sync's internal debug info listener. Used to record datatype configuration |
922 // and association information. | 929 // and association information. |
923 syncer::WeakHandle<syncer::DataTypeDebugInfoListener> debug_info_listener_; | 930 syncer::WeakHandle<syncer::DataTypeDebugInfoListener> debug_info_listener_; |
924 | 931 |
925 // A thread where all the sync operations happen. | 932 // A thread where all the sync operations happen. |
926 // OWNERSHIP Notes: | 933 // OWNERSHIP Notes: |
(...skipping 23 matching lines...) Expand all Loading... |
950 syncer::ConnectionStatus connection_status_; | 957 syncer::ConnectionStatus connection_status_; |
951 base::Time token_request_time_; | 958 base::Time token_request_time_; |
952 base::Time token_receive_time_; | 959 base::Time token_receive_time_; |
953 GoogleServiceAuthError last_get_token_error_; | 960 GoogleServiceAuthError last_get_token_error_; |
954 base::Time next_token_request_time_; | 961 base::Time next_token_request_time_; |
955 | 962 |
956 // The gaia cookie manager. Used for monitoring cookie jar changes to detect | 963 // The gaia cookie manager. Used for monitoring cookie jar changes to detect |
957 // when the user signs out of the content area. | 964 // when the user signs out of the content area. |
958 GaiaCookieManagerService* const gaia_cookie_manager_service_; | 965 GaiaCookieManagerService* const gaia_cookie_manager_service_; |
959 | 966 |
960 std::unique_ptr<syncer::LocalDeviceInfoProvider> local_device_; | 967 std::unique_ptr<sync_driver::LocalDeviceInfoProvider> local_device_; |
961 | 968 |
962 // Locally owned SyncableService and ModelTypeService implementations. | 969 // Locally owned SyncableService and ModelTypeService implementations. |
963 std::unique_ptr<sync_sessions::SessionsSyncManager> sessions_sync_manager_; | 970 std::unique_ptr<sync_sessions::SessionsSyncManager> sessions_sync_manager_; |
964 std::unique_ptr<syncer::DeviceInfoSyncService> device_info_sync_service_; | 971 std::unique_ptr<sync_driver::DeviceInfoSyncService> device_info_sync_service_; |
965 std::unique_ptr<syncer::DeviceInfoService> device_info_service_; | 972 std::unique_ptr<sync_driver_v2::DeviceInfoService> device_info_service_; |
966 | 973 |
967 std::unique_ptr<syncer::NetworkResources> network_resources_; | 974 std::unique_ptr<syncer::NetworkResources> network_resources_; |
968 | 975 |
969 StartBehavior start_behavior_; | 976 StartBehavior start_behavior_; |
970 std::unique_ptr<syncer::StartupController> startup_controller_; | 977 std::unique_ptr<StartupController> startup_controller_; |
971 | 978 |
972 // The full path to the sync data directory. | 979 // The full path to the sync data directory. |
973 base::FilePath directory_path_; | 980 base::FilePath directory_path_; |
974 | 981 |
975 std::unique_ptr<syncer::SyncStoppedReporter> sync_stopped_reporter_; | 982 std::unique_ptr<SyncStoppedReporter> sync_stopped_reporter_; |
976 | 983 |
977 // Listens for the system being under memory pressure. | 984 // Listens for the system being under memory pressure. |
978 std::unique_ptr<base::MemoryPressureListener> memory_pressure_listener_; | 985 std::unique_ptr<base::MemoryPressureListener> memory_pressure_listener_; |
979 | 986 |
980 // Nigori state after user switching to custom passphrase, saved until | 987 // Nigori state after user switching to custom passphrase, saved until |
981 // transition steps complete. It will be injected into new backend after sync | 988 // transition steps complete. It will be injected into new backend after sync |
982 // restart. | 989 // restart. |
983 std::unique_ptr<syncer::SyncEncryptionHandler::NigoriState> | 990 std::unique_ptr<syncer::SyncEncryptionHandler::NigoriState> |
984 saved_nigori_state_; | 991 saved_nigori_state_; |
985 | 992 |
(...skipping 23 matching lines...) Expand all Loading... |
1009 base::WeakPtrFactory<ProfileSyncService> weak_factory_; | 1016 base::WeakPtrFactory<ProfileSyncService> weak_factory_; |
1010 | 1017 |
1011 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); | 1018 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); |
1012 }; | 1019 }; |
1013 | 1020 |
1014 bool ShouldShowActionOnUI(const syncer::SyncProtocolError& error); | 1021 bool ShouldShowActionOnUI(const syncer::SyncProtocolError& error); |
1015 | 1022 |
1016 } // namespace browser_sync | 1023 } // namespace browser_sync |
1017 | 1024 |
1018 #endif // COMPONENTS_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ | 1025 #endif // COMPONENTS_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
OLD | NEW |