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

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

Issue 2663783002: [Sync] Split encryption state and logic out of PSS and SBHI. (Closed)
Patch Set: Tweak comment. Created 3 years, 10 months 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>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/gtest_prod_util.h" 15 #include "base/gtest_prod_util.h"
16 #include "base/location.h" 16 #include "base/location.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/memory/memory_pressure_listener.h" 18 #include "base/memory/memory_pressure_listener.h"
19 #include "base/memory/weak_ptr.h" 19 #include "base/memory/weak_ptr.h"
20 #include "base/message_loop/message_loop.h" 20 #include "base/message_loop/message_loop.h"
21 #include "base/observer_list.h" 21 #include "base/observer_list.h"
22 #include "base/strings/string16.h" 22 #include "base/strings/string16.h"
23 #include "base/threading/thread.h" 23 #include "base/threading/thread.h"
24 #include "base/threading/thread_checker.h"
25 #include "base/time/time.h" 24 #include "base/time/time.h"
26 #include "base/timer/timer.h" 25 #include "base/timer/timer.h"
27 #include "build/build_config.h" 26 #include "build/build_config.h"
28 #include "components/keyed_service/core/keyed_service.h" 27 #include "components/keyed_service/core/keyed_service.h"
29 #include "components/signin/core/browser/gaia_cookie_manager_service.h" 28 #include "components/signin/core/browser/gaia_cookie_manager_service.h"
30 #include "components/signin/core/browser/signin_manager_base.h" 29 #include "components/signin/core/browser/signin_manager_base.h"
31 #include "components/sync/base/experiments.h" 30 #include "components/sync/base/experiments.h"
32 #include "components/sync/base/model_type.h" 31 #include "components/sync/base/model_type.h"
33 #include "components/sync/base/sync_prefs.h" 32 #include "components/sync/base/sync_prefs.h"
34 #include "components/sync/base/unrecoverable_error_handler.h" 33 #include "components/sync/base/unrecoverable_error_handler.h"
(...skipping 19 matching lines...) Expand all
54 #include "components/version_info/version_info.h" 53 #include "components/version_info/version_info.h"
55 #include "google_apis/gaia/google_service_auth_error.h" 54 #include "google_apis/gaia/google_service_auth_error.h"
56 #include "google_apis/gaia/oauth2_token_service.h" 55 #include "google_apis/gaia/oauth2_token_service.h"
57 #include "net/base/backoff_entry.h" 56 #include "net/base/backoff_entry.h"
58 #include "url/gurl.h" 57 #include "url/gurl.h"
59 58
60 class Profile; 59 class Profile;
61 class ProfileOAuth2TokenService; 60 class ProfileOAuth2TokenService;
62 class SigninManagerWrapper; 61 class SigninManagerWrapper;
63 62
64 namespace sync_pb {
65 class EncryptedData;
66 } // namespace sync_pb
67
68 namespace sync_sessions { 63 namespace sync_sessions {
69 class FaviconCache; 64 class FaviconCache;
70 class OpenTabsUIDelegate; 65 class OpenTabsUIDelegate;
71 class SessionsSyncManager; 66 class SessionsSyncManager;
72 } // namespace sync_sessions 67 } // namespace sync_sessions
73 68
74 namespace syncer { 69 namespace syncer {
75 class BackendMigrator; 70 class BackendMigrator;
76 class BaseTransaction; 71 class BaseTransaction;
77 class DataTypeManager; 72 class DataTypeManager;
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 void EnableEncryptEverything() override; 286 void EnableEncryptEverything() override;
292 bool IsEncryptEverythingEnabled() const override; 287 bool IsEncryptEverythingEnabled() const override;
293 void SetEncryptionPassphrase(const std::string& passphrase, 288 void SetEncryptionPassphrase(const std::string& passphrase,
294 PassphraseType type) override; 289 PassphraseType type) override;
295 bool SetDecryptionPassphrase(const std::string& passphrase) override 290 bool SetDecryptionPassphrase(const std::string& passphrase) override
296 WARN_UNUSED_RESULT; 291 WARN_UNUSED_RESULT;
297 bool IsCryptographerReady( 292 bool IsCryptographerReady(
298 const syncer::BaseTransaction* trans) const override; 293 const syncer::BaseTransaction* trans) const override;
299 syncer::UserShare* GetUserShare() const override; 294 syncer::UserShare* GetUserShare() const override;
300 syncer::LocalDeviceInfoProvider* GetLocalDeviceInfoProvider() const override; 295 syncer::LocalDeviceInfoProvider* GetLocalDeviceInfoProvider() const override;
301 void AddObserver(syncer::SyncServiceObserver* observer) override;
302 void RemoveObserver(syncer::SyncServiceObserver* observer) override;
303 bool HasObserver(const syncer::SyncServiceObserver* observer) const override;
304 void RegisterDataTypeController(std::unique_ptr<syncer::DataTypeController> 296 void RegisterDataTypeController(std::unique_ptr<syncer::DataTypeController>
305 data_type_controller) override; 297 data_type_controller) override;
306 void ReenableDatatype(syncer::ModelType type) override; 298 void ReenableDatatype(syncer::ModelType type) override;
307 SyncTokenStatus GetSyncTokenStatus() const override; 299 SyncTokenStatus GetSyncTokenStatus() const override;
308 std::string QuerySyncStatusSummaryString() override; 300 std::string QuerySyncStatusSummaryString() override;
309 bool QueryDetailedSyncStatus(syncer::SyncStatus* result) override; 301 bool QueryDetailedSyncStatus(syncer::SyncStatus* result) override;
310 base::string16 GetLastSyncedTimeString() const override; 302 base::string16 GetLastSyncedTimeString() const override;
311 std::string GetEngineInitializationStateString() const override; 303 std::string GetEngineInitializationStateString() const override;
312 syncer::SyncCycleSnapshot GetLastCycleSnapshot() const override; 304 syncer::SyncCycleSnapshot GetLastCycleSnapshot() const override;
313 std::unique_ptr<base::Value> GetTypeStatusMap() override; 305 std::unique_ptr<base::Value> GetTypeStatusMap() override;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 void OnDirectoryTypeCommitCounterUpdated( 364 void OnDirectoryTypeCommitCounterUpdated(
373 syncer::ModelType type, 365 syncer::ModelType type,
374 const syncer::CommitCounters& counters) override; 366 const syncer::CommitCounters& counters) override;
375 void OnDirectoryTypeUpdateCounterUpdated( 367 void OnDirectoryTypeUpdateCounterUpdated(
376 syncer::ModelType type, 368 syncer::ModelType type,
377 const syncer::UpdateCounters& counters) override; 369 const syncer::UpdateCounters& counters) override;
378 void OnDatatypeStatusCounterUpdated( 370 void OnDatatypeStatusCounterUpdated(
379 syncer::ModelType type, 371 syncer::ModelType type,
380 const syncer::StatusCounters& counters) override; 372 const syncer::StatusCounters& counters) override;
381 void OnConnectionStatusChange(syncer::ConnectionStatus status) override; 373 void OnConnectionStatusChange(syncer::ConnectionStatus status) override;
382 void OnPassphraseRequired(
383 syncer::PassphraseRequiredReason reason,
384 const sync_pb::EncryptedData& pending_keys) override;
385 void OnPassphraseAccepted() override;
386 void OnEncryptedTypesChanged(syncer::ModelTypeSet encrypted_types,
387 bool encrypt_everything) override;
388 void OnEncryptionComplete() override;
389 void OnMigrationNeededForTypes(syncer::ModelTypeSet types) override; 374 void OnMigrationNeededForTypes(syncer::ModelTypeSet types) override;
390 void OnExperimentsChanged(const syncer::Experiments& experiments) override; 375 void OnExperimentsChanged(const syncer::Experiments& experiments) override;
391 void OnActionableError(const syncer::SyncProtocolError& error) override; 376 void OnActionableError(const syncer::SyncProtocolError& error) override;
392 void OnLocalSetPassphraseEncryption(
393 const syncer::SyncEncryptionHandler::NigoriState& nigori_state) override;
394 377
395 // DataTypeManagerObserver implementation. 378 // DataTypeManagerObserver implementation.
396 void OnConfigureDone( 379 void OnConfigureDone(
397 const syncer::DataTypeManager::ConfigureResult& result) override; 380 const syncer::DataTypeManager::ConfigureResult& result) override;
398 void OnConfigureStart() override; 381 void OnConfigureStart() override;
399 382
400 // DataTypeEncryptionHandler implementation. 383 // DataTypeEncryptionHandler implementation.
401 bool IsPassphraseRequired() const override; 384 bool IsPassphraseRequired() const override;
402 syncer::ModelTypeSet GetEncryptedDataTypes() const override; 385 syncer::ModelTypeSet GetEncryptedDataTypes() const override;
403 386
(...skipping 16 matching lines...) Expand all
420 // Reconfigures the data type manager with the latest enabled types. 403 // Reconfigures the data type manager with the latest enabled types.
421 // Note: Does not initialize the engine if it is not already initialized. 404 // Note: Does not initialize the engine if it is not already initialized.
422 // This function needs to be called only after sync has been initialized 405 // This function needs to be called only after sync has been initialized
423 // (i.e.,only for reconfigurations). The reason we don't initialize the 406 // (i.e.,only for reconfigurations). The reason we don't initialize the
424 // engine is because if we had encountered an unrecoverable error we don't 407 // engine is because if we had encountered an unrecoverable error we don't
425 // want to startup once more. 408 // want to startup once more.
426 // This function is called by |SetSetupInProgress|. 409 // This function is called by |SetSetupInProgress|.
427 virtual void ReconfigureDatatypeManager(); 410 virtual void ReconfigureDatatypeManager();
428 411
429 syncer::PassphraseRequiredReason passphrase_required_reason() const { 412 syncer::PassphraseRequiredReason passphrase_required_reason() const {
430 return passphrase_required_reason_; 413 return crypto_->passphrase_required_reason();
431 } 414 }
432 415
433 // Returns true if sync is requested to be running by the user. 416 // Returns true if sync is requested to be running by the user.
434 // Note that this does not mean that sync WILL be running; e.g. if 417 // Note that this does not mean that sync WILL be running; e.g. if
435 // IsSyncAllowed() is false then sync won't start, and if the user 418 // IsSyncAllowed() is false then sync won't start, and if the user
436 // doesn't confirm their settings (IsFirstSetupComplete), sync will 419 // doesn't confirm their settings (IsFirstSetupComplete), sync will
437 // never become active. Use IsSyncActive to see if sync is running. 420 // never become active. Use IsSyncActive to see if sync is running.
438 virtual bool IsSyncRequested() const; 421 virtual bool IsSyncRequested() const;
439 422
440 // Record stats on various events. 423 // Record stats on various events.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 // Returns the set of types which are enforced programmatically and can not 476 // Returns the set of types which are enforced programmatically and can not
494 // be disabled by the user. 477 // be disabled by the user.
495 virtual syncer::ModelTypeSet GetForcedDataTypes() const; 478 virtual syncer::ModelTypeSet GetForcedDataTypes() const;
496 479
497 // Gets the set of all data types that could be allowed (the set that 480 // Gets the set of all data types that could be allowed (the set that
498 // should be advertised to the user). These will typically only change 481 // should be advertised to the user). These will typically only change
499 // via a command-line option. See class comment for more on what it means 482 // via a command-line option. See class comment for more on what it means
500 // for a datatype to be Registered. 483 // for a datatype to be Registered.
501 virtual syncer::ModelTypeSet GetRegisteredDataTypes() const; 484 virtual syncer::ModelTypeSet GetRegisteredDataTypes() const;
502 485
503 // Returns the actual passphrase type being used for encryption. 486 // See the SyncServiceCrypto header.
504 virtual syncer::PassphraseType GetPassphraseType() const; 487 virtual syncer::PassphraseType GetPassphraseType() const;
505
506 // Note about setting passphrases: There are different scenarios under which
507 // we might want to apply a passphrase. It could be for first-time encryption,
508 // re-encryption, or for decryption by clients that sign in at a later time.
509 // In addition, encryption can either be done using a custom passphrase, or by
510 // reusing the GAIA password. Depending on what is happening in the system,
511 // callers should determine which of the two methods below must be used.
512
513 // Returns true if encrypting all the sync data is allowed. If this method
514 // returns false, EnableEncryptEverything() should not be called.
515 virtual bool IsEncryptEverythingAllowed() const; 488 virtual bool IsEncryptEverythingAllowed() const;
516
517 // Sets whether encrypting all the sync data is allowed or not.
518 virtual void SetEncryptEverythingAllowed(bool allowed); 489 virtual void SetEncryptEverythingAllowed(bool allowed);
519 490
520 // Returns true if the syncer is waiting for new datatypes to be encrypted. 491 // Returns true if the syncer is waiting for new datatypes to be encrypted.
521 virtual bool encryption_pending() const; 492 virtual bool encryption_pending() const;
522 493
523 SigninManagerBase* signin() const; 494 SigninManagerBase* signin() const;
524 495
525 syncer::SyncErrorController* sync_error_controller() { 496 syncer::SyncErrorController* sync_error_controller() {
526 return sync_error_controller_.get(); 497 return sync_error_controller_.get();
527 } 498 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 // the sync LevelDB backend. 556 // the sync LevelDB backend.
586 syncer::ModelTypeStoreFactory GetModelTypeStoreFactory( 557 syncer::ModelTypeStoreFactory GetModelTypeStoreFactory(
587 syncer::ModelType type); 558 syncer::ModelType type);
588 559
589 // Needed to test whether the directory is deleted properly. 560 // Needed to test whether the directory is deleted properly.
590 base::FilePath GetDirectoryPathForTest() const; 561 base::FilePath GetDirectoryPathForTest() const;
591 562
592 // Sometimes we need to wait for tasks on the sync thread in tests. 563 // Sometimes we need to wait for tasks on the sync thread in tests.
593 base::MessageLoop* GetSyncLoopForTest() const; 564 base::MessageLoop* GetSyncLoopForTest() const;
594 565
566 // Some tests rely on injecting calls to the encryption observer.
567 syncer::SyncEncryptionHandler::Observer* GetEncryptionObserverForTest() const;
568
595 // Triggers sync cycle with request to update specified |types|. 569 // Triggers sync cycle with request to update specified |types|.
596 void RefreshTypesForTest(syncer::ModelTypeSet types); 570 void RefreshTypesForTest(syncer::ModelTypeSet types);
597 571
598 protected: 572 protected:
599 // SyncServiceBase implementation. 573 // SyncServiceBase implementation.
600 syncer::SyncCredentials GetCredentials() override; 574 syncer::SyncCredentials GetCredentials() override;
601 syncer::WeakHandle<syncer::JsEventHandler> GetJsEventHandler() override; 575 syncer::WeakHandle<syncer::JsEventHandler> GetJsEventHandler() override;
602 syncer::SyncEngine::HttpPostProviderFactoryGetter 576 syncer::SyncEngine::HttpPostProviderFactoryGetter
603 MakeHttpPostProviderFactoryGetter() override; 577 MakeHttpPostProviderFactoryGetter() override;
604 std::unique_ptr<syncer::SyncEncryptionHandler::NigoriState>
605 MoveSavedNigoriState() override;
606 syncer::WeakHandle<syncer::UnrecoverableErrorHandler> 578 syncer::WeakHandle<syncer::UnrecoverableErrorHandler>
607 GetUnrecoverableErrorHandler() override; 579 GetUnrecoverableErrorHandler() override;
608 580
609 private: 581 private:
610 enum UnrecoverableErrorReason { 582 enum UnrecoverableErrorReason {
611 ERROR_REASON_UNSET, 583 ERROR_REASON_UNSET,
612 ERROR_REASON_SYNCER, 584 ERROR_REASON_SYNCER,
613 ERROR_REASON_ENGINE_INIT_FAILURE, 585 ERROR_REASON_ENGINE_INIT_FAILURE,
614 ERROR_REASON_CONFIGURATION_RETRY, 586 ERROR_REASON_CONFIGURATION_RETRY,
615 ERROR_REASON_CONFIGURATION_FAILURE, 587 ERROR_REASON_CONFIGURATION_FAILURE,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 // deleted or kept when the engine shuts down. 637 // deleted or kept when the engine shuts down.
666 void StopImpl(SyncStopDataFate data_fate); 638 void StopImpl(SyncStopDataFate data_fate);
667 639
668 // Update the last auth error and notify observers of error state. 640 // Update the last auth error and notify observers of error state.
669 void UpdateAuthErrorState(const GoogleServiceAuthError& error); 641 void UpdateAuthErrorState(const GoogleServiceAuthError& error);
670 642
671 // Puts the engine's sync scheduler into NORMAL mode. 643 // Puts the engine's sync scheduler into NORMAL mode.
672 // Called when configuration is complete. 644 // Called when configuration is complete.
673 void StartSyncingWithServer(); 645 void StartSyncingWithServer();
674 646
675 // During initial signin, ProfileSyncService caches the user's signin
676 // passphrase so it can be used to encrypt/decrypt data after sync starts up.
677 // This routine is invoked once the engine has started up to use the
678 // cached passphrase and clear it out when it is done.
679 void ConsumeCachedPassphraseIfPossible();
680
681 // RequestAccessToken initiates RPC to request downscoped access token from 647 // RequestAccessToken initiates RPC to request downscoped access token from
682 // refresh token. This happens when a new OAuth2 login token is loaded and 648 // refresh token. This happens when a new OAuth2 login token is loaded and
683 // when sync server returns AUTH_ERROR which indicates it is time to refresh 649 // when sync server returns AUTH_ERROR which indicates it is time to refresh
684 // token. 650 // token.
685 void RequestAccessToken(); 651 void RequestAccessToken();
686 652
687 // Sets the last synced time to the current time. 653 // Sets the last synced time to the current time.
688 void UpdateLastSyncedTime(); 654 void UpdateLastSyncedTime();
689 655
690 void NotifyObservers();
691 void NotifySyncCycleCompleted(); 656 void NotifySyncCycleCompleted();
692 void NotifyForeignSessionUpdated(); 657 void NotifyForeignSessionUpdated();
693 658
694 void ClearStaleErrors(); 659 void ClearStaleErrors();
695 660
696 void ClearUnrecoverableError(); 661 void ClearUnrecoverableError();
697 662
698 // Starts up the engine sync components. 663 // Starts up the engine sync components.
699 virtual void StartUpSlowEngineComponents(); 664 virtual void StartUpSlowEngineComponents();
700 665
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 709
745 // Called when the system is under memory pressure. 710 // Called when the system is under memory pressure.
746 void OnMemoryPressure( 711 void OnMemoryPressure(
747 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level); 712 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level);
748 713
749 // Check if previous shutdown is shutdown cleanly. 714 // Check if previous shutdown is shutdown cleanly.
750 void ReportPreviousSessionMemoryWarningCount(); 715 void ReportPreviousSessionMemoryWarningCount();
751 716
752 // After user switches to custom passphrase encryption a set of steps needs to 717 // After user switches to custom passphrase encryption a set of steps needs to
753 // be performed: 718 // be performed:
719 //
754 // - Download all latest updates from server (catch up configure). 720 // - Download all latest updates from server (catch up configure).
755 // - Clear user data on server. 721 // - Clear user data on server.
756 // - Clear directory so that data is merged from model types and encrypted. 722 // - Clear directory so that data is merged from model types and encrypted.
757 // Following three functions perform these steps. 723 //
758 724 // SyncServiceCrypto::BeginConfigureCatchUpBeforeClear() and the following two
759 // Calls data type manager to start catch up configure. 725 // functions perform these steps.
760 void BeginConfigureCatchUpBeforeClear();
761 726
762 // Calls sync engine to send ClearServerDataMessage to server. 727 // Calls sync engine to send ClearServerDataMessage to server.
763 void ClearAndRestartSyncForPassphraseEncryption(); 728 void ClearAndRestartSyncForPassphraseEncryption();
764 729
765 // Restarts sync clearing directory in the process. 730 // Restarts sync clearing directory in the process.
766 void OnClearServerDataDone(); 731 void OnClearServerDataDone();
767 732
768 // True if setup has been completed at least once and is not in progress. 733 // True if setup has been completed at least once and is not in progress.
769 bool CanConfigureDataTypes() const; 734 bool CanConfigureDataTypes() const;
770 735
771 // Called when a SetupInProgressHandle issued by this instance is destroyed. 736 // Called when a SetupInProgressHandle issued by this instance is destroyed.
772 virtual void OnSetupInProgressHandleDestroyed(); 737 virtual void OnSetupInProgressHandleDestroyed();
773 738
774 // This is a cache of the last authentication response we received from the 739 // This is a cache of the last authentication response we received from the
775 // sync server. The UI queries this to display appropriate messaging to the 740 // sync server. The UI queries this to display appropriate messaging to the
776 // user. 741 // user.
777 GoogleServiceAuthError last_auth_error_; 742 GoogleServiceAuthError last_auth_error_;
778 743
779 // Cache of the last SyncCycleSnapshot received from the sync engine. 744 // Cache of the last SyncCycleSnapshot received from the sync engine.
780 syncer::SyncCycleSnapshot last_snapshot_; 745 syncer::SyncCycleSnapshot last_snapshot_;
781 746
782 // Was the last SYNC_PASSPHRASE_REQUIRED notification sent because it
783 // was required for encryption, decryption with a cached passphrase, or
784 // because a new passphrase is required?
785 syncer::PassphraseRequiredReason passphrase_required_reason_;
786
787 // TODO(ncarter): Put this in a profile, once there is UI for it. 747 // TODO(ncarter): Put this in a profile, once there is UI for it.
788 // This specifies where to find the sync server. 748 // This specifies where to find the sync server.
789 const GURL sync_service_url_; 749 const GURL sync_service_url_;
790 750
791 // The time that OnConfigureStart is called. This member is zero if 751 // The time that OnConfigureStart is called. This member is zero if
792 // OnConfigureStart has not yet been called, and is reset to zero once 752 // OnConfigureStart has not yet been called, and is reset to zero once
793 // OnConfigureDone is called. 753 // OnConfigureDone is called.
794 base::Time sync_configure_start_time_; 754 base::Time sync_configure_start_time_;
795 755
796 // Callback to update the network time; used for initializing the engine. 756 // Callback to update the network time; used for initializing the engine.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 base::FilePath local_sync_backend_folder_; 789 base::FilePath local_sync_backend_folder_;
830 790
831 // Information describing an unrecoverable error. 791 // Information describing an unrecoverable error.
832 UnrecoverableErrorReason unrecoverable_error_reason_; 792 UnrecoverableErrorReason unrecoverable_error_reason_;
833 std::string unrecoverable_error_message_; 793 std::string unrecoverable_error_message_;
834 tracked_objects::Location unrecoverable_error_location_; 794 tracked_objects::Location unrecoverable_error_location_;
835 795
836 // Manages the start and stop of the data types. 796 // Manages the start and stop of the data types.
837 std::unique_ptr<syncer::DataTypeManager> data_type_manager_; 797 std::unique_ptr<syncer::DataTypeManager> data_type_manager_;
838 798
839 base::ObserverList<syncer::SyncServiceObserver> observers_;
840 base::ObserverList<syncer::ProtocolEventObserver> protocol_event_observers_; 799 base::ObserverList<syncer::ProtocolEventObserver> protocol_event_observers_;
841 base::ObserverList<syncer::TypeDebugInfoObserver> type_debug_info_observers_; 800 base::ObserverList<syncer::TypeDebugInfoObserver> type_debug_info_observers_;
842 801
843 std::set<syncer::SyncTypePreferenceProvider*> preference_providers_; 802 std::set<syncer::SyncTypePreferenceProvider*> preference_providers_;
844 803
845 syncer::SyncJsController sync_js_controller_; 804 syncer::SyncJsController sync_js_controller_;
846 805
847 // This allows us to gracefully handle an ABORTED return code from the 806 // This allows us to gracefully handle an ABORTED return code from the
848 // DataTypeManager in the event that the server informed us to cease and 807 // DataTypeManager in the event that the server informed us to cease and
849 // desist syncing immediately. 808 // desist syncing immediately.
850 bool expect_sync_configuration_aborted_; 809 bool expect_sync_configuration_aborted_;
851 810
852 // Sometimes we need to temporarily hold on to a passphrase because we don't
853 // yet have a engine to send it to. This happens during initialization as
854 // we don't StartUp until we have a valid token, which happens after valid
855 // credentials were provided.
856 std::string cached_passphrase_;
857
858 // The current set of encrypted types. Always a superset of
859 // syncer::Cryptographer::SensitiveTypes().
860 syncer::ModelTypeSet encrypted_types_;
861
862 // Whether encrypting everything is allowed.
863 bool encrypt_everything_allowed_;
864
865 // Whether we want to encrypt everything.
866 bool encrypt_everything_;
867
868 // Whether we're waiting for an attempt to encryption all sync data to
869 // complete. We track this at this layer in order to allow the user to cancel
870 // if they e.g. don't remember their explicit passphrase.
871 bool encryption_pending_;
872
873 std::unique_ptr<syncer::BackendMigrator> migrator_; 811 std::unique_ptr<syncer::BackendMigrator> migrator_;
874 812
875 // This is the last |SyncProtocolError| we received from the server that had 813 // This is the last |SyncProtocolError| we received from the server that had
876 // an action set on it. 814 // an action set on it.
877 syncer::SyncProtocolError last_actionable_error_; 815 syncer::SyncProtocolError last_actionable_error_;
878 816
879 // Exposes sync errors to the UI. 817 // Exposes sync errors to the UI.
880 std::unique_ptr<syncer::SyncErrorController> sync_error_controller_; 818 std::unique_ptr<syncer::SyncErrorController> sync_error_controller_;
881 819
882 // Tracks the set of failed data types (those that encounter an error 820 // Tracks the set of failed data types (those that encounter an error
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 std::unique_ptr<syncer::NetworkResources> network_resources_; 868 std::unique_ptr<syncer::NetworkResources> network_resources_;
931 869
932 StartBehavior start_behavior_; 870 StartBehavior start_behavior_;
933 std::unique_ptr<syncer::StartupController> startup_controller_; 871 std::unique_ptr<syncer::StartupController> startup_controller_;
934 872
935 std::unique_ptr<syncer::SyncStoppedReporter> sync_stopped_reporter_; 873 std::unique_ptr<syncer::SyncStoppedReporter> sync_stopped_reporter_;
936 874
937 // Listens for the system being under memory pressure. 875 // Listens for the system being under memory pressure.
938 std::unique_ptr<base::MemoryPressureListener> memory_pressure_listener_; 876 std::unique_ptr<base::MemoryPressureListener> memory_pressure_listener_;
939 877
940 // Nigori state after user switching to custom passphrase, saved until
941 // transition steps complete. It will be injected into new engine after sync
942 // restart.
943 std::unique_ptr<syncer::SyncEncryptionHandler::NigoriState>
944 saved_nigori_state_;
945
946 // Whether the major version has changed since the last time Chrome ran, 878 // Whether the major version has changed since the last time Chrome ran,
947 // and therefore a passphrase required state should result in prompting 879 // and therefore a passphrase required state should result in prompting
948 // the user. This logic is only enabled on platforms that consume the 880 // the user. This logic is only enabled on platforms that consume the
949 // IsPassphrasePrompted sync preference. 881 // IsPassphrasePrompted sync preference.
950 bool passphrase_prompt_triggered_by_version_; 882 bool passphrase_prompt_triggered_by_version_;
951 883
952 // An object that lets us check whether sync is currently allowed on this 884 // An object that lets us check whether sync is currently allowed on this
953 // platform. 885 // platform.
954 PlatformSyncAllowedProvider platform_sync_allowed_provider_; 886 PlatformSyncAllowedProvider platform_sync_allowed_provider_;
955 887
956 // Used to ensure that certain operations are performed on the thread that
957 // this object was created on.
958 base::ThreadChecker thread_checker_;
959
960 // This weak factory invalidates its issued pointers when Sync is disabled. 888 // This weak factory invalidates its issued pointers when Sync is disabled.
961 base::WeakPtrFactory<ProfileSyncService> sync_enabled_weak_factory_; 889 base::WeakPtrFactory<ProfileSyncService> sync_enabled_weak_factory_;
962 890
963 base::WeakPtrFactory<ProfileSyncService> weak_factory_; 891 base::WeakPtrFactory<ProfileSyncService> weak_factory_;
964 892
965 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); 893 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService);
966 }; 894 };
967 895
968 bool ShouldShowActionOnUI(const syncer::SyncProtocolError& error); 896 bool ShouldShowActionOnUI(const syncer::SyncProtocolError& error);
969 897
970 } // namespace browser_sync 898 } // namespace browser_sync
971 899
972 #endif // COMPONENTS_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ 900 #endif // COMPONENTS_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/search_provider_unittest.cc ('k') | components/browser_sync/profile_sync_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698