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> |
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/sequenced_worker_pool.h" | |
23 #include "base/threading/thread.h" | 24 #include "base/threading/thread.h" |
24 #include "base/time/time.h" | 25 #include "base/time/time.h" |
25 #include "base/timer/timer.h" | 26 #include "base/timer/timer.h" |
26 #include "build/build_config.h" | 27 #include "build/build_config.h" |
27 #include "components/keyed_service/core/keyed_service.h" | 28 #include "components/keyed_service/core/keyed_service.h" |
28 #include "components/signin/core/browser/gaia_cookie_manager_service.h" | 29 #include "components/signin/core/browser/gaia_cookie_manager_service.h" |
29 #include "components/signin/core/browser/signin_manager_base.h" | 30 #include "components/signin/core/browser/signin_manager_base.h" |
30 #include "components/sync/base/experiments.h" | 31 #include "components/sync/base/experiments.h" |
31 #include "components/sync/base/model_type.h" | 32 #include "components/sync/base/model_type.h" |
32 #include "components/sync/base/sync_prefs.h" | 33 #include "components/sync/base/sync_prefs.h" |
(...skipping 16 matching lines...) Expand all Loading... | |
49 #include "components/sync/engine/sync_manager_factory.h" | 50 #include "components/sync/engine/sync_manager_factory.h" |
50 #include "components/sync/js/sync_js_controller.h" | 51 #include "components/sync/js/sync_js_controller.h" |
51 #include "components/sync/model/model_type_store.h" | 52 #include "components/sync/model/model_type_store.h" |
52 #include "components/sync/syncable/user_share.h" | 53 #include "components/sync/syncable/user_share.h" |
53 #include "components/version_info/version_info.h" | 54 #include "components/version_info/version_info.h" |
54 #include "google_apis/gaia/google_service_auth_error.h" | 55 #include "google_apis/gaia/google_service_auth_error.h" |
55 #include "google_apis/gaia/oauth2_token_service.h" | 56 #include "google_apis/gaia/oauth2_token_service.h" |
56 #include "net/base/backoff_entry.h" | 57 #include "net/base/backoff_entry.h" |
57 #include "url/gurl.h" | 58 #include "url/gurl.h" |
58 | 59 |
59 class Profile; | |
60 class ProfileOAuth2TokenService; | 60 class ProfileOAuth2TokenService; |
61 class SigninManagerWrapper; | 61 class SigninManagerWrapper; |
62 | 62 |
63 namespace sync_sessions { | 63 namespace sync_sessions { |
64 class FaviconCache; | 64 class FaviconCache; |
65 class OpenTabsUIDelegate; | 65 class OpenTabsUIDelegate; |
66 class SessionsSyncManager; | 66 class SessionsSyncManager; |
67 } // namespace sync_sessions | 67 } // namespace sync_sessions |
68 | 68 |
69 namespace syncer { | 69 namespace syncer { |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
233 std::unique_ptr<syncer::SyncClient> sync_client; | 233 std::unique_ptr<syncer::SyncClient> sync_client; |
234 std::unique_ptr<SigninManagerWrapper> signin_wrapper; | 234 std::unique_ptr<SigninManagerWrapper> signin_wrapper; |
235 ProfileOAuth2TokenService* oauth2_token_service = nullptr; | 235 ProfileOAuth2TokenService* oauth2_token_service = nullptr; |
236 GaiaCookieManagerService* gaia_cookie_manager_service = nullptr; | 236 GaiaCookieManagerService* gaia_cookie_manager_service = nullptr; |
237 StartBehavior start_behavior = MANUAL_START; | 237 StartBehavior start_behavior = MANUAL_START; |
238 syncer::NetworkTimeUpdateCallback network_time_update_callback; | 238 syncer::NetworkTimeUpdateCallback network_time_update_callback; |
239 base::FilePath base_directory; | 239 base::FilePath base_directory; |
240 scoped_refptr<net::URLRequestContextGetter> url_request_context; | 240 scoped_refptr<net::URLRequestContextGetter> url_request_context; |
241 std::string debug_identifier; | 241 std::string debug_identifier; |
242 version_info::Channel channel = version_info::Channel::UNKNOWN; | 242 version_info::Channel channel = version_info::Channel::UNKNOWN; |
243 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner; | |
244 | 243 |
245 private: | 244 private: |
246 DISALLOW_COPY_AND_ASSIGN(InitParams); | 245 DISALLOW_COPY_AND_ASSIGN(InitParams); |
247 }; | 246 }; |
248 | 247 |
249 explicit ProfileSyncService(InitParams init_params); | 248 explicit ProfileSyncService(InitParams init_params); |
250 | 249 |
251 ~ProfileSyncService() override; | 250 ~ProfileSyncService() override; |
252 | 251 |
253 // Initializes the object. This must be called at most once, and | 252 // Initializes the object. This must be called at most once, and |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
545 | 544 |
546 // Returns a serialized NigoriKey proto generated from the bootstrap token in | 545 // Returns a serialized NigoriKey proto generated from the bootstrap token in |
547 // SyncPrefs. Will return the empty string if no bootstrap token exists. | 546 // SyncPrefs. Will return the empty string if no bootstrap token exists. |
548 std::string GetCustomPassphraseKey() const; | 547 std::string GetCustomPassphraseKey() const; |
549 | 548 |
550 // Set the provider for whether sync is currently allowed by the platform. | 549 // Set the provider for whether sync is currently allowed by the platform. |
551 void SetPlatformSyncAllowedProvider( | 550 void SetPlatformSyncAllowedProvider( |
552 const PlatformSyncAllowedProvider& platform_sync_allowed_provider); | 551 const PlatformSyncAllowedProvider& platform_sync_allowed_provider); |
553 | 552 |
554 // Returns a function for |type| that will create a ModelTypeStore that shares | 553 // Returns a function for |type| that will create a ModelTypeStore that shares |
555 // the sync LevelDB backend. | 554 // the sync LevelDB backend. |base_path| should be set to profile path. |
skym
2017/03/08 19:28:15
And what should |sequenced_worker_pool| be?
pavely
2017/03/08 20:41:12
Done.
| |
556 syncer::ModelTypeStoreFactory GetModelTypeStoreFactory( | 555 static syncer::ModelTypeStoreFactory GetModelTypeStoreFactory( |
557 syncer::ModelType type); | 556 syncer::ModelType type, |
557 const base::FilePath& base_path, | |
558 base::SequencedWorkerPool* sequenced_worker_pool); | |
558 | 559 |
559 // Needed to test whether the directory is deleted properly. | 560 // Needed to test whether the directory is deleted properly. |
560 base::FilePath GetDirectoryPathForTest() const; | 561 base::FilePath GetDirectoryPathForTest() const; |
561 | 562 |
562 // 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. |
563 base::MessageLoop* GetSyncLoopForTest() const; | 564 base::MessageLoop* GetSyncLoopForTest() const; |
564 | 565 |
565 // Some tests rely on injecting calls to the encryption observer. | 566 // Some tests rely on injecting calls to the encryption observer. |
566 syncer::SyncEncryptionHandler::Observer* GetEncryptionObserverForTest() const; | 567 syncer::SyncEncryptionHandler::Observer* GetEncryptionObserverForTest() const; |
567 | 568 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
752 // OnConfigureStart has not yet been called, and is reset to zero once | 753 // OnConfigureStart has not yet been called, and is reset to zero once |
753 // OnConfigureDone is called. | 754 // OnConfigureDone is called. |
754 base::Time sync_configure_start_time_; | 755 base::Time sync_configure_start_time_; |
755 | 756 |
756 // Callback to update the network time; used for initializing the engine. | 757 // Callback to update the network time; used for initializing the engine. |
757 syncer::NetworkTimeUpdateCallback network_time_update_callback_; | 758 syncer::NetworkTimeUpdateCallback network_time_update_callback_; |
758 | 759 |
759 // The request context in which sync should operate. | 760 // The request context in which sync should operate. |
760 scoped_refptr<net::URLRequestContextGetter> url_request_context_; | 761 scoped_refptr<net::URLRequestContextGetter> url_request_context_; |
761 | 762 |
762 // The task runner to use for blocking IO operations. | |
763 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; | |
764 | |
765 // Indicates if this is the first time sync is being configured. This value | 763 // Indicates if this is the first time sync is being configured. This value |
766 // is equal to !IsFirstSetupComplete() at the time of OnEngineInitialized(). | 764 // is equal to !IsFirstSetupComplete() at the time of OnEngineInitialized(). |
767 bool is_first_time_sync_configure_; | 765 bool is_first_time_sync_configure_; |
768 | 766 |
769 // Number of UIs currently configuring the Sync service. When this number | 767 // Number of UIs currently configuring the Sync service. When this number |
770 // is decremented back to zero, Sync setup is marked no longer in progress. | 768 // is decremented back to zero, Sync setup is marked no longer in progress. |
771 int outstanding_setup_in_progress_handles_ = 0; | 769 int outstanding_setup_in_progress_handles_ = 0; |
772 | 770 |
773 // List of available data type controllers. | 771 // List of available data type controllers. |
774 syncer::DataTypeController::TypeMap data_type_controllers_; | 772 syncer::DataTypeController::TypeMap data_type_controllers_; |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
888 base::WeakPtrFactory<ProfileSyncService> weak_factory_; | 886 base::WeakPtrFactory<ProfileSyncService> weak_factory_; |
889 | 887 |
890 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); | 888 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); |
891 }; | 889 }; |
892 | 890 |
893 bool ShouldShowActionOnUI(const syncer::SyncProtocolError& error); | 891 bool ShouldShowActionOnUI(const syncer::SyncProtocolError& error); |
894 | 892 |
895 } // namespace browser_sync | 893 } // namespace browser_sync |
896 | 894 |
897 #endif // COMPONENTS_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ | 895 #endif // COMPONENTS_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
OLD | NEW |