Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(292)

Side by Side Diff: components/browser_sync/profile_sync_service.h

Issue 2551023006: [Sync] SyncEngine 1.5: Fix all backend references in PSS. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 struct CommitCounters; 86 struct CommitCounters;
87 struct StatusCounters; 87 struct StatusCounters;
88 struct SyncCredentials; 88 struct SyncCredentials;
89 struct UpdateCounters; 89 struct UpdateCounters;
90 struct UserShare; 90 struct UserShare;
91 } // namespace syncer 91 } // namespace syncer
92 92
93 namespace browser_sync { 93 namespace browser_sync {
94 94
95 // ProfileSyncService is the layer between browser subsystems like bookmarks, 95 // ProfileSyncService is the layer between browser subsystems like bookmarks,
96 // and the sync backend. Each subsystem is logically thought of as being 96 // and the sync engine. Each subsystem is logically thought of as being a sync
97 // a sync datatype. 97 // datatype. Individual datatypes can, at any point, be in a variety of stages
98 // 98 // of being "enabled". Here are some specific terms for concepts used in this
99 // Individual datatypes can, at any point, be in a variety of stages of being 99 // class:
100 // "enabled". Here are some specific terms for concepts used in this class:
101 // 100 //
102 // 'Registered' (feature suppression for a datatype) 101 // 'Registered' (feature suppression for a datatype)
103 // 102 //
104 // When a datatype is registered, the user has the option of syncing it. 103 // When a datatype is registered, the user has the option of syncing it.
105 // The sync opt-in UI will show only registered types; a checkbox should 104 // The sync opt-in UI will show only registered types; a checkbox should
106 // never be shown for an unregistered type, and nor should it ever be 105 // never be shown for an unregistered type, and nor should it ever be
107 // synced. 106 // synced.
108 // 107 //
109 // A datatype is considered registered once RegisterDataTypeController 108 // A datatype is considered registered once RegisterDataTypeController
110 // has been called with that datatype's DataTypeController. 109 // has been called with that datatype's DataTypeController.
111 // 110 //
112 // 'Preferred' (user preferences and opt-out for a datatype) 111 // 'Preferred' (user preferences and opt-out for a datatype)
113 // 112 //
114 // This means the user's opt-in or opt-out preference on a per-datatype 113 // This means the user's opt-in or opt-out preference on a per-datatype
115 // basis. The sync service will try to make active exactly these types. 114 // basis. The sync service will try to make active exactly these types.
116 // If a user has opted out of syncing a particular datatype, it will 115 // If a user has opted out of syncing a particular datatype, it will
117 // be registered, but not preferred. 116 // be registered, but not preferred.
118 // 117 //
119 // This state is controlled by the ConfigurePreferredDataTypes and 118 // This state is controlled by the ConfigurePreferredDataTypes and
120 // GetPreferredDataTypes. They are stored in the preferences system, 119 // GetPreferredDataTypes. They are stored in the preferences system,
121 // and persist; though if a datatype is not registered, it cannot 120 // and persist; though if a datatype is not registered, it cannot
122 // be a preferred datatype. 121 // be a preferred datatype.
123 // 122 //
124 // 'Active' (run-time initialization of sync system for a datatype) 123 // 'Active' (run-time initialization of sync system for a datatype)
125 // 124 //
126 // An active datatype is a preferred datatype that is actively being 125 // An active datatype is a preferred datatype that is actively being
127 // synchronized: the syncer has been instructed to querying the server 126 // synchronized: the syncer has been instructed to querying the server
128 // for this datatype, first-time merges have finished, and there is an 127 // for this datatype, first-time merges have finished, and there is an
129 // actively installed ChangeProcessor that listens for changes to this 128 // actively installed ChangeProcessor that listens for changes to this
130 // datatype, propagating such changes into and out of the sync backend 129 // datatype, propagating such changes into and out of the sync engine
131 // as necessary. 130 // as necessary.
132 // 131 //
133 // When a datatype is in the process of becoming active, it may be 132 // When a datatype is in the process of becoming active, it may be
134 // in some intermediate state. Those finer-grained intermediate states 133 // in some intermediate state. Those finer-grained intermediate states
135 // are differentiated by the DataTypeController state. 134 // are differentiated by the DataTypeController state.
136 // 135 //
137 // Sync Configuration: 136 // Sync Configuration:
138 // 137 //
139 // Sync configuration is accomplished via the following APIs: 138 // Sync configuration is accomplished via the following APIs:
140 // * OnUserChoseDatatypes(): Set the data types the user wants to sync. 139 // * OnUserChoseDatatypes(): Set the data types the user wants to sync.
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 void OnUserChoseDatatypes(bool sync_everything, 274 void OnUserChoseDatatypes(bool sync_everything,
276 syncer::ModelTypeSet chosen_types) override; 275 syncer::ModelTypeSet chosen_types) override;
277 void SetFirstSetupComplete() override; 276 void SetFirstSetupComplete() override;
278 bool IsFirstSetupInProgress() const override; 277 bool IsFirstSetupInProgress() const override;
279 std::unique_ptr<syncer::SyncSetupInProgressHandle> GetSetupInProgressHandle() 278 std::unique_ptr<syncer::SyncSetupInProgressHandle> GetSetupInProgressHandle()
280 override; 279 override;
281 bool IsSetupInProgress() const override; 280 bool IsSetupInProgress() const override;
282 bool ConfigurationDone() const override; 281 bool ConfigurationDone() const override;
283 const GoogleServiceAuthError& GetAuthError() const override; 282 const GoogleServiceAuthError& GetAuthError() const override;
284 bool HasUnrecoverableError() const override; 283 bool HasUnrecoverableError() const override;
285 bool IsBackendInitialized() const override; 284 bool IsEngineInitialized() const override;
286 sync_sessions::OpenTabsUIDelegate* GetOpenTabsUIDelegate() override; 285 sync_sessions::OpenTabsUIDelegate* GetOpenTabsUIDelegate() override;
287 bool IsPassphraseRequiredForDecryption() const override; 286 bool IsPassphraseRequiredForDecryption() const override;
288 base::Time GetExplicitPassphraseTime() const override; 287 base::Time GetExplicitPassphraseTime() const override;
289 bool IsUsingSecondaryPassphrase() const override; 288 bool IsUsingSecondaryPassphrase() const override;
290 void EnableEncryptEverything() override; 289 void EnableEncryptEverything() override;
291 bool IsEncryptEverythingEnabled() const override; 290 bool IsEncryptEverythingEnabled() const override;
292 void SetEncryptionPassphrase(const std::string& passphrase, 291 void SetEncryptionPassphrase(const std::string& passphrase,
293 PassphraseType type) override; 292 PassphraseType type) override;
294 bool SetDecryptionPassphrase(const std::string& passphrase) override 293 bool SetDecryptionPassphrase(const std::string& passphrase) override
295 WARN_UNUSED_RESULT; 294 WARN_UNUSED_RESULT;
296 bool IsCryptographerReady( 295 bool IsCryptographerReady(
297 const syncer::BaseTransaction* trans) const override; 296 const syncer::BaseTransaction* trans) const override;
298 syncer::UserShare* GetUserShare() const override; 297 syncer::UserShare* GetUserShare() const override;
299 syncer::LocalDeviceInfoProvider* GetLocalDeviceInfoProvider() const override; 298 syncer::LocalDeviceInfoProvider* GetLocalDeviceInfoProvider() const override;
300 void AddObserver(syncer::SyncServiceObserver* observer) override; 299 void AddObserver(syncer::SyncServiceObserver* observer) override;
301 void RemoveObserver(syncer::SyncServiceObserver* observer) override; 300 void RemoveObserver(syncer::SyncServiceObserver* observer) override;
302 bool HasObserver(const syncer::SyncServiceObserver* observer) const override; 301 bool HasObserver(const syncer::SyncServiceObserver* observer) const override;
303 void RegisterDataTypeController(std::unique_ptr<syncer::DataTypeController> 302 void RegisterDataTypeController(std::unique_ptr<syncer::DataTypeController>
304 data_type_controller) override; 303 data_type_controller) override;
305 void ReenableDatatype(syncer::ModelType type) override; 304 void ReenableDatatype(syncer::ModelType type) override;
306 SyncTokenStatus GetSyncTokenStatus() const override; 305 SyncTokenStatus GetSyncTokenStatus() const override;
307 std::string QuerySyncStatusSummaryString() override; 306 std::string QuerySyncStatusSummaryString() override;
308 bool QueryDetailedSyncStatus(syncer::SyncStatus* result) override; 307 bool QueryDetailedSyncStatus(syncer::SyncStatus* result) override;
309 base::string16 GetLastSyncedTimeString() const override; 308 base::string16 GetLastSyncedTimeString() const override;
310 std::string GetBackendInitializationStateString() const override; 309 std::string GetEngineInitializationStateString() const override;
311 syncer::SyncCycleSnapshot GetLastCycleSnapshot() const override; 310 syncer::SyncCycleSnapshot GetLastCycleSnapshot() const override;
312 std::unique_ptr<base::Value> GetTypeStatusMap() override; 311 std::unique_ptr<base::Value> GetTypeStatusMap() override;
313 const GURL& sync_service_url() const override; 312 const GURL& sync_service_url() const override;
314 std::string unrecoverable_error_message() const override; 313 std::string unrecoverable_error_message() const override;
315 tracked_objects::Location unrecoverable_error_location() const override; 314 tracked_objects::Location unrecoverable_error_location() const override;
316 void AddProtocolEventObserver( 315 void AddProtocolEventObserver(
317 syncer::ProtocolEventObserver* observer) override; 316 syncer::ProtocolEventObserver* observer) override;
318 void RemoveProtocolEventObserver( 317 void RemoveProtocolEventObserver(
319 syncer::ProtocolEventObserver* observer) override; 318 syncer::ProtocolEventObserver* observer) override;
320 void AddTypeDebugInfoObserver( 319 void AddTypeDebugInfoObserver(
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 351
353 // Fills state_map with a map of current data types that are possible to 352 // Fills state_map with a map of current data types that are possible to
354 // sync, as well as their states. 353 // sync, as well as their states.
355 void GetDataTypeControllerStates( 354 void GetDataTypeControllerStates(
356 syncer::DataTypeController::StateMap* state_map) const; 355 syncer::DataTypeController::StateMap* state_map) const;
357 356
358 // Called when asynchronous session restore has completed. 357 // Called when asynchronous session restore has completed.
359 void OnSessionRestoreComplete(); 358 void OnSessionRestoreComplete();
360 359
361 // SyncEngineHost implementation. 360 // SyncEngineHost implementation.
362 void OnBackendInitialized( 361 void OnEngineInitialized(
363 const syncer::WeakHandle<syncer::JsBackend>& js_backend, 362 const syncer::WeakHandle<syncer::JsBackend>& js_backend,
skym 2016/12/05 19:38:56 And this gets less ambiguous! Woooo!
maxbogue 2016/12/05 22:17:11 :D
364 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>& 363 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>&
365 debug_info_listener, 364 debug_info_listener,
366 const std::string& cache_guid, 365 const std::string& cache_guid,
367 bool success) override; 366 bool success) override;
368 void OnSyncCycleCompleted() override; 367 void OnSyncCycleCompleted() override;
369 void OnProtocolEvent(const syncer::ProtocolEvent& event) override; 368 void OnProtocolEvent(const syncer::ProtocolEvent& event) override;
370 void OnDirectoryTypeCommitCounterUpdated( 369 void OnDirectoryTypeCommitCounterUpdated(
371 syncer::ModelType type, 370 syncer::ModelType type,
372 const syncer::CommitCounters& counters) override; 371 const syncer::CommitCounters& counters) override;
373 void OnDirectoryTypeUpdateCounterUpdated( 372 void OnDirectoryTypeUpdateCounterUpdated(
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 // GaiaCookieManagerService::Observer implementation. 408 // GaiaCookieManagerService::Observer implementation.
410 void OnGaiaAccountsInCookieUpdated( 409 void OnGaiaAccountsInCookieUpdated(
411 const std::vector<gaia::ListedAccount>& accounts, 410 const std::vector<gaia::ListedAccount>& accounts,
412 const std::vector<gaia::ListedAccount>& signed_out_accounts, 411 const std::vector<gaia::ListedAccount>& signed_out_accounts,
413 const GoogleServiceAuthError& error) override; 412 const GoogleServiceAuthError& error) override;
414 413
415 // Get the sync status code. 414 // Get the sync status code.
416 SyncStatusSummary QuerySyncStatusSummary(); 415 SyncStatusSummary QuerySyncStatusSummary();
417 416
418 // Reconfigures the data type manager with the latest enabled types. 417 // Reconfigures the data type manager with the latest enabled types.
419 // Note: Does not initialize the backend if it is not already initialized. 418 // Note: Does not initialize the engine if it is not already initialized.
420 // This function needs to be called only after sync has been initialized 419 // This function needs to be called only after sync has been initialized
421 // (i.e.,only for reconfigurations). The reason we don't initialize the 420 // (i.e.,only for reconfigurations). The reason we don't initialize the
422 // backend is because if we had encountered an unrecoverable error we don't 421 // engine is because if we had encountered an unrecoverable error we don't
423 // want to startup once more. 422 // want to startup once more.
424 // This function is called by |SetSetupInProgress|. 423 // This function is called by |SetSetupInProgress|.
425 virtual void ReconfigureDatatypeManager(); 424 virtual void ReconfigureDatatypeManager();
426 425
427 syncer::PassphraseRequiredReason passphrase_required_reason() const { 426 syncer::PassphraseRequiredReason passphrase_required_reason() const {
428 return passphrase_required_reason_; 427 return passphrase_required_reason_;
429 } 428 }
430 429
431 // Returns true if sync is requested to be running by the user. 430 // Returns true if sync is requested to be running by the user.
432 // Note that this does not mean that sync WILL be running; e.g. if 431 // Note that this does not mean that sync WILL be running; e.g. if
(...skipping 16 matching lines...) Expand all
449 448
450 // Returns whether sync is managed, i.e. controlled by configuration 449 // Returns whether sync is managed, i.e. controlled by configuration
451 // management. If so, the user is not allowed to configure sync. 450 // management. If so, the user is not allowed to configure sync.
452 virtual bool IsManaged() const; 451 virtual bool IsManaged() const;
453 452
454 // syncer::UnrecoverableErrorHandler implementation. 453 // syncer::UnrecoverableErrorHandler implementation.
455 void OnUnrecoverableError(const tracked_objects::Location& from_here, 454 void OnUnrecoverableError(const tracked_objects::Location& from_here,
456 const std::string& message) override; 455 const std::string& message) override;
457 456
458 // The functions below (until ActivateDataType()) should only be 457 // The functions below (until ActivateDataType()) should only be
459 // called if IsBackendInitialized() is true. 458 // called if IsEngineInitialized() is true.
460 459
461 // TODO(akalin): These two functions are used only by 460 // TODO(akalin): These two functions are used only by
462 // ProfileSyncServiceHarness. Figure out a different way to expose 461 // ProfileSyncServiceHarness. Figure out a different way to expose
463 // this info to that class, and remove these functions. 462 // this info to that class, and remove these functions.
464 463
465 // Returns whether or not the underlying sync engine has made any 464 // Returns whether or not the underlying sync engine has made any
466 // local changes to items that have not yet been synced with the 465 // local changes to items that have not yet been synced with the
467 // server. 466 // server.
468 bool HasUnsyncedItems() const; 467 bool HasUnsyncedItems() const;
469 468
470 // Used by ProfileSyncServiceHarness. May return null. 469 // Used by ProfileSyncServiceHarness. May return null.
471 syncer::BackendMigrator* GetBackendMigratorForTest(); 470 syncer::BackendMigrator* GetBackendMigratorForTest();
skym 2016/12/05 19:38:56 Does this need to be renamed? What does the Backen
maxbogue 2016/12/05 22:17:11 I don't know, I'm ignoring it for now.
472 471
473 // Used by tests to inspect interaction with OAuth2TokenService. 472 // Used by tests to inspect interaction with OAuth2TokenService.
474 bool IsRetryingAccessTokenFetchForTest() const; 473 bool IsRetryingAccessTokenFetchForTest() const;
475 474
476 // Used by tests to inspect the OAuth2 access tokens used by PSS. 475 // Used by tests to inspect the OAuth2 access tokens used by PSS.
477 std::string GetAccessTokenForTest() const; 476 std::string GetAccessTokenForTest() const;
478 477
479 // TODO(sync): This is only used in tests. Can we remove it? 478 // TODO(sync): This is only used in tests. Can we remove it?
480 void GetModelSafeRoutingInfo(syncer::ModelSafeRoutingInfo* out) const; 479 void GetModelSafeRoutingInfo(syncer::ModelSafeRoutingInfo* out) const;
481 480
482 // SyncPrefObserver implementation. 481 // SyncPrefObserver implementation.
483 void OnSyncManagedPrefChange(bool is_sync_managed) override; 482 void OnSyncManagedPrefChange(bool is_sync_managed) override;
484 483
485 // Changes which data types we're going to be syncing to |preferred_types|. 484 // Changes which data types we're going to be syncing to |preferred_types|.
486 // If it is running, the DataTypeManager will be instructed to reconfigure 485 // If it is running, the DataTypeManager will be instructed to reconfigure
487 // the sync backend so that exactly these datatypes are actively synced. See 486 // the sync engine so that exactly these datatypes are actively synced. See
488 // class comment for more on what it means for a datatype to be Preferred. 487 // class comment for more on what it means for a datatype to be Preferred.
489 virtual void ChangePreferredDataTypes(syncer::ModelTypeSet preferred_types); 488 virtual void ChangePreferredDataTypes(syncer::ModelTypeSet preferred_types);
490 489
491 // Returns the set of types which are enforced programmatically and can not 490 // Returns the set of types which are enforced programmatically and can not
492 // be disabled by the user. 491 // be disabled by the user.
493 virtual syncer::ModelTypeSet GetForcedDataTypes() const; 492 virtual syncer::ModelTypeSet GetForcedDataTypes() const;
494 493
495 // Gets the set of all data types that could be allowed (the set that 494 // Gets the set of all data types that could be allowed (the set that
496 // should be advertised to the user). These will typically only change 495 // should be advertised to the user). These will typically only change
497 // via a command-line option. See class comment for more on what it means 496 // via a command-line option. See class comment for more on what it means
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 // Sometimes we need to wait for tasks on the sync thread in tests. 584 // Sometimes we need to wait for tasks on the sync thread in tests.
586 base::MessageLoop* GetSyncLoopForTest() const; 585 base::MessageLoop* GetSyncLoopForTest() const;
587 586
588 // Triggers sync cycle with request to update specified |types|. 587 // Triggers sync cycle with request to update specified |types|.
589 void RefreshTypesForTest(syncer::ModelTypeSet types); 588 void RefreshTypesForTest(syncer::ModelTypeSet types);
590 589
591 private: 590 private:
592 enum UnrecoverableErrorReason { 591 enum UnrecoverableErrorReason {
593 ERROR_REASON_UNSET, 592 ERROR_REASON_UNSET,
594 ERROR_REASON_SYNCER, 593 ERROR_REASON_SYNCER,
595 ERROR_REASON_BACKEND_INIT_FAILURE, 594 ERROR_REASON_ENGINE_INIT_FAILURE,
596 ERROR_REASON_CONFIGURATION_RETRY, 595 ERROR_REASON_CONFIGURATION_RETRY,
597 ERROR_REASON_CONFIGURATION_FAILURE, 596 ERROR_REASON_CONFIGURATION_FAILURE,
598 ERROR_REASON_ACTIONABLE_ERROR, 597 ERROR_REASON_ACTIONABLE_ERROR,
599 ERROR_REASON_LIMIT 598 ERROR_REASON_LIMIT
600 }; 599 };
601 600
602 enum AuthErrorMetric { 601 enum AuthErrorMetric {
603 AUTH_ERROR_ENCOUNTERED, 602 AUTH_ERROR_ENCOUNTERED,
604 AUTH_ERROR_FIXED, 603 AUTH_ERROR_FIXED,
605 AUTH_ERROR_LIMIT 604 AUTH_ERROR_LIMIT
(...skipping 14 matching lines...) Expand all
620 IS_MANAGED, // Sync is disallowed by enterprise policy. 619 IS_MANAGED, // Sync is disallowed by enterprise policy.
621 NOT_ALLOWED_BY_PLATFORM, // Sync is disallowed by the platform. 620 NOT_ALLOWED_BY_PLATFORM, // Sync is disallowed by the platform.
622 SYNC_INITIAL_STATE_LIMIT 621 SYNC_INITIAL_STATE_LIMIT
623 }; 622 };
624 623
625 friend class TestProfileSyncService; 624 friend class TestProfileSyncService;
626 625
627 // Helper to install and configure a data type manager. 626 // Helper to install and configure a data type manager.
628 void ConfigureDataTypeManager(); 627 void ConfigureDataTypeManager();
629 628
630 // Shuts down the backend sync components. 629 // Shuts down the engine sync components.
631 // |reason| dictates if syncing is being disabled or not, and whether 630 // |reason| dictates if syncing is being disabled or not, and whether
632 // to claim ownership of sync thread from backend. 631 // to claim ownership of sync thread from engine.
633 void ShutdownImpl(syncer::ShutdownReason reason); 632 void ShutdownImpl(syncer::ShutdownReason reason);
634 633
635 // Return SyncCredentials from the OAuth2TokenService. 634 // Return SyncCredentials from the OAuth2TokenService.
636 syncer::SyncCredentials GetCredentials(); 635 syncer::SyncCredentials GetCredentials();
637 636
638 virtual syncer::WeakHandle<syncer::JsEventHandler> GetJsEventHandler(); 637 virtual syncer::WeakHandle<syncer::JsEventHandler> GetJsEventHandler();
639 638
640 // Helper method for managing encryption UI. 639 // Helper method for managing encryption UI.
641 bool IsEncryptedDatatypeEnabled() const; 640 bool IsEncryptedDatatypeEnabled() const;
642 641
643 // Helper for OnUnrecoverableError. 642 // Helper for OnUnrecoverableError.
644 // TODO(tim): Use an enum for |delete_sync_database| here, in ShutdownImpl, 643 // TODO(tim): Use an enum for |delete_sync_database| here, in ShutdownImpl,
645 // and in SyncEngine::Shutdown. 644 // and in SyncEngine::Shutdown.
646 void OnUnrecoverableErrorImpl(const tracked_objects::Location& from_here, 645 void OnUnrecoverableErrorImpl(const tracked_objects::Location& from_here,
647 const std::string& message, 646 const std::string& message,
648 bool delete_sync_database); 647 bool delete_sync_database);
649 648
650 // Stops the sync engine. Does NOT set IsSyncRequested to false. Use 649 // Stops the sync engine. Does NOT set IsSyncRequested to false. Use
651 // RequestStop for that. |data_fate| controls whether the local sync data is 650 // RequestStop for that. |data_fate| controls whether the local sync data is
652 // deleted or kept when the engine shuts down. 651 // deleted or kept when the engine shuts down.
653 void StopImpl(SyncStopDataFate data_fate); 652 void StopImpl(SyncStopDataFate data_fate);
654 653
655 // Update the last auth error and notify observers of error state. 654 // Update the last auth error and notify observers of error state.
656 void UpdateAuthErrorState(const GoogleServiceAuthError& error); 655 void UpdateAuthErrorState(const GoogleServiceAuthError& error);
657 656
658 // Puts the backend's sync scheduler into NORMAL mode. 657 // Puts the engine's sync scheduler into NORMAL mode.
659 // Called when configuration is complete. 658 // Called when configuration is complete.
660 void StartSyncingWithServer(); 659 void StartSyncingWithServer();
661 660
662 // During initial signin, ProfileSyncService caches the user's signin 661 // During initial signin, ProfileSyncService caches the user's signin
663 // passphrase so it can be used to encrypt/decrypt data after sync starts up. 662 // passphrase so it can be used to encrypt/decrypt data after sync starts up.
664 // This routine is invoked once the backend has started up to use the 663 // This routine is invoked once the engine has started up to use the
665 // cached passphrase and clear it out when it is done. 664 // cached passphrase and clear it out when it is done.
666 void ConsumeCachedPassphraseIfPossible(); 665 void ConsumeCachedPassphraseIfPossible();
667 666
668 // RequestAccessToken initiates RPC to request downscoped access token from 667 // RequestAccessToken initiates RPC to request downscoped access token from
669 // refresh token. This happens when a new OAuth2 login token is loaded and 668 // refresh token. This happens when a new OAuth2 login token is loaded and
670 // when sync server returns AUTH_ERROR which indicates it is time to refresh 669 // when sync server returns AUTH_ERROR which indicates it is time to refresh
671 // token. 670 // token.
672 void RequestAccessToken(); 671 void RequestAccessToken();
673 672
674 // Return true if backend should start from a fresh sync DB. 673 // Return true if engine should start from a fresh sync DB.
675 bool ShouldDeleteSyncFolder(); 674 bool ShouldDeleteSyncFolder();
676 675
677 // If |delete_sync_data_folder| is true, then this method will delete all 676 // If |delete_sync_data_folder| is true, then this method will delete all
678 // previous "Sync Data" folders. (useful if the folder is partial/corrupt). 677 // previous "Sync Data" folders. (useful if the folder is partial/corrupt).
679 void InitializeBackend(bool delete_sync_data_folder); 678 void InitializeEngine(bool delete_sync_data_folder);
680 679
681 // Sets the last synced time to the current time. 680 // Sets the last synced time to the current time.
682 void UpdateLastSyncedTime(); 681 void UpdateLastSyncedTime();
683 682
684 void NotifyObservers(); 683 void NotifyObservers();
685 void NotifySyncCycleCompleted(); 684 void NotifySyncCycleCompleted();
686 void NotifyForeignSessionUpdated(); 685 void NotifyForeignSessionUpdated();
687 686
688 void ClearStaleErrors(); 687 void ClearStaleErrors();
689 688
690 void ClearUnrecoverableError(); 689 void ClearUnrecoverableError();
691 690
692 // Starts up the backend sync components. 691 // Starts up the engine sync components.
693 void StartUpSlowBackendComponents(); 692 virtual void StartUpSlowEngineComponents();
694 693
695 // Collects preferred sync data types from |preference_providers_|. 694 // Collects preferred sync data types from |preference_providers_|.
696 syncer::ModelTypeSet GetDataTypesFromPreferenceProviders() const; 695 syncer::ModelTypeSet GetDataTypesFromPreferenceProviders() const;
697 696
698 // Called when the user changes the sync configuration, to update the UMA 697 // Called when the user changes the sync configuration, to update the UMA
699 // stats. 698 // stats.
700 void UpdateSelectedTypesHistogram( 699 void UpdateSelectedTypesHistogram(
701 bool sync_everything, 700 bool sync_everything,
702 const syncer::ModelTypeSet chosen_types) const; 701 const syncer::ModelTypeSet chosen_types) const;
703 702
704 #if defined(OS_CHROMEOS) 703 #if defined(OS_CHROMEOS)
705 // Refresh spare sync bootstrap token for re-enabling the sync service. 704 // Refresh spare sync bootstrap token for re-enabling the sync service.
706 // Called on successful sign-in notifications. 705 // Called on successful sign-in notifications.
707 void RefreshSpareBootstrapToken(const std::string& passphrase); 706 void RefreshSpareBootstrapToken(const std::string& passphrase);
708 #endif 707 #endif
709 708
710 // Internal unrecoverable error handler. Used to track error reason via 709 // Internal unrecoverable error handler. Used to track error reason via
711 // Sync.UnrecoverableErrors histogram. 710 // Sync.UnrecoverableErrors histogram.
712 void OnInternalUnrecoverableError(const tracked_objects::Location& from_here, 711 void OnInternalUnrecoverableError(const tracked_objects::Location& from_here,
713 const std::string& message, 712 const std::string& message,
714 bool delete_sync_database, 713 bool delete_sync_database,
715 UnrecoverableErrorReason reason); 714 UnrecoverableErrorReason reason);
716 715
717 // Update UMA for syncing backend. 716 // Update UMA for syncing engine.
718 void UpdateBackendInitUMA(bool success); 717 void UpdateEngineInitUMA(bool success);
719 718
720 // Various setup following backend initialization, mostly for syncing backend. 719 // Various setup following engine initialization, mostly for syncing engine.
721 void PostBackendInitialization(); 720 void PostEngineInitialization();
722 721
723 // Whether sync has been authenticated with an account ID. 722 // Whether sync has been authenticated with an account ID.
724 bool IsSignedIn() const; 723 bool IsSignedIn() const;
725 724
726 // The backend can only start if sync can start and has an auth token. This is 725 // The engine can only start if sync can start and has an auth token. This is
727 // different fron CanSyncStart because it represents whether the backend can 726 // different fron CanSyncStart because it represents whether the engine can
728 // be started at this moment, whereas CanSyncStart represents whether sync can 727 // be started at this moment, whereas CanSyncStart represents whether sync can
729 // conceptually start without further user action (acquiring a token is an 728 // conceptually start without further user action (acquiring a token is an
730 // automatic process). 729 // automatic process).
731 bool CanBackendStart() const; 730 bool CanEngineStart() const;
732 731
733 // True if a syncing backend exists. 732 // True if a syncing engine exists.
734 bool HasSyncingBackend() const; 733 bool HasSyncingEngine() const;
735 734
736 // Update first sync time stored in preferences 735 // Update first sync time stored in preferences
737 void UpdateFirstSyncTimePref(); 736 void UpdateFirstSyncTimePref();
738 737
739 // Tell the sync server that this client has disabled sync. 738 // Tell the sync server that this client has disabled sync.
740 void RemoveClientFromServer() const; 739 void RemoveClientFromServer() const;
741 740
742 // Called when the system is under memory pressure. 741 // Called when the system is under memory pressure.
743 void OnMemoryPressure( 742 void OnMemoryPressure(
744 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level); 743 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level);
745 744
746 // Check if previous shutdown is shutdown cleanly. 745 // Check if previous shutdown is shutdown cleanly.
747 void ReportPreviousSessionMemoryWarningCount(); 746 void ReportPreviousSessionMemoryWarningCount();
748 747
749 // After user switches to custom passphrase encryption a set of steps needs to 748 // After user switches to custom passphrase encryption a set of steps needs to
750 // be performed: 749 // be performed:
751 // - Download all latest updates from server (catch up configure). 750 // - Download all latest updates from server (catch up configure).
752 // - Clear user data on server. 751 // - Clear user data on server.
753 // - Clear directory so that data is merged from model types and encrypted. 752 // - Clear directory so that data is merged from model types and encrypted.
754 // Following three functions perform these steps. 753 // Following three functions perform these steps.
755 754
756 // Calls data type manager to start catch up configure. 755 // Calls data type manager to start catch up configure.
757 void BeginConfigureCatchUpBeforeClear(); 756 void BeginConfigureCatchUpBeforeClear();
758 757
759 // Calls sync backend to send ClearServerDataMessage to server. 758 // Calls sync engine to send ClearServerDataMessage to server.
760 void ClearAndRestartSyncForPassphraseEncryption(); 759 void ClearAndRestartSyncForPassphraseEncryption();
761 760
762 // Restarts sync clearing directory in the process. 761 // Restarts sync clearing directory in the process.
763 void OnClearServerDataDone(); 762 void OnClearServerDataDone();
764 763
765 // True if setup has been completed at least once and is not in progress. 764 // True if setup has been completed at least once and is not in progress.
766 bool CanConfigureDataTypes() const; 765 bool CanConfigureDataTypes() const;
767 766
768 // Called when a SetupInProgressHandle issued by this instance is destroyed. 767 // Called when a SetupInProgressHandle issued by this instance is destroyed.
769 virtual void OnSetupInProgressHandleDestroyed(); 768 virtual void OnSetupInProgressHandleDestroyed();
770 769
771 // This is a cache of the last authentication response we received from the 770 // This is a cache of the last authentication response we received from the
772 // sync server. The UI queries this to display appropriate messaging to the 771 // sync server. The UI queries this to display appropriate messaging to the
773 // user. 772 // user.
774 GoogleServiceAuthError last_auth_error_; 773 GoogleServiceAuthError last_auth_error_;
775 774
776 // Our asynchronous backend to communicate with sync components living on 775 // Our asynchronous engine to communicate with sync components living on
777 // other threads. 776 // other threads.
778 std::unique_ptr<syncer::SyncEngine> backend_; 777 std::unique_ptr<syncer::SyncEngine> engine_;
779 778
780 // Was the last SYNC_PASSPHRASE_REQUIRED notification sent because it 779 // Was the last SYNC_PASSPHRASE_REQUIRED notification sent because it
781 // was required for encryption, decryption with a cached passphrase, or 780 // was required for encryption, decryption with a cached passphrase, or
782 // because a new passphrase is required? 781 // because a new passphrase is required?
783 syncer::PassphraseRequiredReason passphrase_required_reason_; 782 syncer::PassphraseRequiredReason passphrase_required_reason_;
784 783
785 // This profile's SyncClient, which abstracts away non-Sync dependencies and 784 // This profile's SyncClient, which abstracts away non-Sync dependencies and
786 // the Sync API component factory. 785 // the Sync API component factory.
787 std::unique_ptr<syncer::SyncClient> sync_client_; 786 std::unique_ptr<syncer::SyncClient> sync_client_;
788 787
789 // The class that handles getting, setting, and persisting sync 788 // The class that handles getting, setting, and persisting sync
790 // preferences. 789 // preferences.
791 syncer::SyncPrefs sync_prefs_; 790 syncer::SyncPrefs sync_prefs_;
792 791
793 // TODO(ncarter): Put this in a profile, once there is UI for it. 792 // TODO(ncarter): Put this in a profile, once there is UI for it.
794 // This specifies where to find the sync server. 793 // This specifies where to find the sync server.
795 const GURL sync_service_url_; 794 const GURL sync_service_url_;
796 795
797 // The time that OnConfigureStart is called. This member is zero if 796 // The time that OnConfigureStart is called. This member is zero if
798 // OnConfigureStart has not yet been called, and is reset to zero once 797 // OnConfigureStart has not yet been called, and is reset to zero once
799 // OnConfigureDone is called. 798 // OnConfigureDone is called.
800 base::Time sync_configure_start_time_; 799 base::Time sync_configure_start_time_;
801 800
802 // Callback to update the network time; used for initializing the backend. 801 // Callback to update the network time; used for initializing the engine.
803 syncer::NetworkTimeUpdateCallback network_time_update_callback_; 802 syncer::NetworkTimeUpdateCallback network_time_update_callback_;
804 803
805 // The path to the base directory under which sync should store its 804 // The path to the base directory under which sync should store its
806 // information. 805 // information.
807 base::FilePath base_directory_; 806 base::FilePath base_directory_;
808 807
809 // The request context in which sync should operate. 808 // The request context in which sync should operate.
810 scoped_refptr<net::URLRequestContextGetter> url_request_context_; 809 scoped_refptr<net::URLRequestContextGetter> url_request_context_;
811 810
812 // An identifier representing this instance for debugging purposes. 811 // An identifier representing this instance for debugging purposes.
813 std::string debug_identifier_; 812 std::string debug_identifier_;
814 813
815 // The product channel of the embedder. 814 // The product channel of the embedder.
816 version_info::Channel channel_; 815 version_info::Channel channel_;
817 816
818 // Threading context. 817 // Threading context.
819 base::SequencedWorkerPool* blocking_pool_; 818 base::SequencedWorkerPool* blocking_pool_;
820 819
821 // Indicates if this is the first time sync is being configured. This value 820 // Indicates if this is the first time sync is being configured. This value
822 // is equal to !IsFirstSetupComplete() at the time of OnBackendInitialized(). 821 // is equal to !IsFirstSetupComplete() at the time of OnEngineInitialized().
823 bool is_first_time_sync_configure_; 822 bool is_first_time_sync_configure_;
824 823
825 // Number of UIs currently configuring the Sync service. When this number 824 // Number of UIs currently configuring the Sync service. When this number
826 // is decremented back to zero, Sync setup is marked no longer in progress. 825 // is decremented back to zero, Sync setup is marked no longer in progress.
827 int outstanding_setup_in_progress_handles_ = 0; 826 int outstanding_setup_in_progress_handles_ = 0;
828 827
829 // List of available data type controllers. 828 // List of available data type controllers.
830 syncer::DataTypeController::TypeMap data_type_controllers_; 829 syncer::DataTypeController::TypeMap data_type_controllers_;
831 830
832 // Whether the SyncEngine has been initialized. 831 // Whether the SyncEngine has been initialized.
833 bool backend_initialized_; 832 bool engine_initialized_;
834 833
835 // Set when sync receives DISABLED_BY_ADMIN error from server. Prevents 834 // Set when sync receives DISABLED_BY_ADMIN error from server. Prevents
836 // ProfileSyncService from starting backend till browser restarted or user 835 // ProfileSyncService from starting engine till browser restarted or user
837 // signed out. 836 // signed out.
838 bool sync_disabled_by_admin_; 837 bool sync_disabled_by_admin_;
839 838
840 // Set to true if a signin has completed but we're still waiting for the 839 // Set to true if a signin has completed but we're still waiting for the
841 // backend to refresh its credentials. 840 // engine to refresh its credentials.
842 bool is_auth_in_progress_; 841 bool is_auth_in_progress_;
843 842
844 // Encapsulates user signin - used to set/get the user's authenticated 843 // Encapsulates user signin - used to set/get the user's authenticated
845 // email address. 844 // email address.
846 const std::unique_ptr<SigninManagerWrapper> signin_; 845 const std::unique_ptr<SigninManagerWrapper> signin_;
847 846
848 // Information describing an unrecoverable error. 847 // Information describing an unrecoverable error.
849 UnrecoverableErrorReason unrecoverable_error_reason_; 848 UnrecoverableErrorReason unrecoverable_error_reason_;
850 std::string unrecoverable_error_message_; 849 std::string unrecoverable_error_message_;
851 tracked_objects::Location unrecoverable_error_location_; 850 tracked_objects::Location unrecoverable_error_location_;
852 851
853 // Manages the start and stop of the data types. 852 // Manages the start and stop of the data types.
854 std::unique_ptr<syncer::DataTypeManager> data_type_manager_; 853 std::unique_ptr<syncer::DataTypeManager> data_type_manager_;
855 854
856 base::ObserverList<syncer::SyncServiceObserver> observers_; 855 base::ObserverList<syncer::SyncServiceObserver> observers_;
857 base::ObserverList<syncer::ProtocolEventObserver> protocol_event_observers_; 856 base::ObserverList<syncer::ProtocolEventObserver> protocol_event_observers_;
858 base::ObserverList<syncer::TypeDebugInfoObserver> type_debug_info_observers_; 857 base::ObserverList<syncer::TypeDebugInfoObserver> type_debug_info_observers_;
859 858
860 std::set<syncer::SyncTypePreferenceProvider*> preference_providers_; 859 std::set<syncer::SyncTypePreferenceProvider*> preference_providers_;
861 860
862 syncer::SyncJsController sync_js_controller_; 861 syncer::SyncJsController sync_js_controller_;
863 862
864 // This allows us to gracefully handle an ABORTED return code from the 863 // This allows us to gracefully handle an ABORTED return code from the
865 // DataTypeManager in the event that the server informed us to cease and 864 // DataTypeManager in the event that the server informed us to cease and
866 // desist syncing immediately. 865 // desist syncing immediately.
867 bool expect_sync_configuration_aborted_; 866 bool expect_sync_configuration_aborted_;
868 867
869 // Sometimes we need to temporarily hold on to a passphrase because we don't 868 // Sometimes we need to temporarily hold on to a passphrase because we don't
870 // yet have a backend to send it to. This happens during initialization as 869 // yet have a engine to send it to. This happens during initialization as
871 // we don't StartUp until we have a valid token, which happens after valid 870 // we don't StartUp until we have a valid token, which happens after valid
872 // credentials were provided. 871 // credentials were provided.
873 std::string cached_passphrase_; 872 std::string cached_passphrase_;
874 873
875 // The current set of encrypted types. Always a superset of 874 // The current set of encrypted types. Always a superset of
876 // syncer::Cryptographer::SensitiveTypes(). 875 // syncer::Cryptographer::SensitiveTypes().
877 syncer::ModelTypeSet encrypted_types_; 876 syncer::ModelTypeSet encrypted_types_;
878 877
879 // Whether encrypting everything is allowed. 878 // Whether encrypting everything is allowed.
880 bool encrypt_everything_allowed_; 879 bool encrypt_everything_allowed_;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
957 956
958 // The full path to the sync data directory. 957 // The full path to the sync data directory.
959 base::FilePath directory_path_; 958 base::FilePath directory_path_;
960 959
961 std::unique_ptr<syncer::SyncStoppedReporter> sync_stopped_reporter_; 960 std::unique_ptr<syncer::SyncStoppedReporter> sync_stopped_reporter_;
962 961
963 // Listens for the system being under memory pressure. 962 // Listens for the system being under memory pressure.
964 std::unique_ptr<base::MemoryPressureListener> memory_pressure_listener_; 963 std::unique_ptr<base::MemoryPressureListener> memory_pressure_listener_;
965 964
966 // Nigori state after user switching to custom passphrase, saved until 965 // Nigori state after user switching to custom passphrase, saved until
967 // transition steps complete. It will be injected into new backend after sync 966 // transition steps complete. It will be injected into new engine after sync
968 // restart. 967 // restart.
969 std::unique_ptr<syncer::SyncEncryptionHandler::NigoriState> 968 std::unique_ptr<syncer::SyncEncryptionHandler::NigoriState>
970 saved_nigori_state_; 969 saved_nigori_state_;
971 970
972 // When BeginConfigureCatchUpBeforeClear is called it will set 971 // When BeginConfigureCatchUpBeforeClear is called it will set
973 // catch_up_configure_in_progress_ to true. This is needed to detect that call 972 // catch_up_configure_in_progress_ to true. This is needed to detect that call
974 // to OnConfigureDone originated from BeginConfigureCatchUpBeforeClear and 973 // to OnConfigureDone originated from BeginConfigureCatchUpBeforeClear and
975 // needs to be followed by ClearAndRestartSyncForPassphraseEncryption(). 974 // needs to be followed by ClearAndRestartSyncForPassphraseEncryption().
976 bool catch_up_configure_in_progress_; 975 bool catch_up_configure_in_progress_;
977 976
(...skipping 17 matching lines...) Expand all
995 base::WeakPtrFactory<ProfileSyncService> weak_factory_; 994 base::WeakPtrFactory<ProfileSyncService> weak_factory_;
996 995
997 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); 996 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService);
998 }; 997 };
999 998
1000 bool ShouldShowActionOnUI(const syncer::SyncProtocolError& error); 999 bool ShouldShowActionOnUI(const syncer::SyncProtocolError& error);
1001 1000
1002 } // namespace browser_sync 1001 } // namespace browser_sync
1003 1002
1004 #endif // COMPONENTS_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ 1003 #endif // COMPONENTS_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698