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 CHROME_BROWSER_SYNC_TEST_PROFILE_SYNC_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SYNC_TEST_PROFILE_SYNC_SERVICE_H_ |
6 #define CHROME_BROWSER_SYNC_TEST_PROFILE_SYNC_SERVICE_H_ | 6 #define CHROME_BROWSER_SYNC_TEST_PROFILE_SYNC_SERVICE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 namespace browser_sync { | 29 namespace browser_sync { |
30 | 30 |
31 class SyncBackendHostForProfileSyncTest : public SyncBackendHost { | 31 class SyncBackendHostForProfileSyncTest : public SyncBackendHost { |
32 public: | 32 public: |
33 // |synchronous_init| causes initialization to block until the syncapi has | 33 // |synchronous_init| causes initialization to block until the syncapi has |
34 // completed setting itself up and called us back. | 34 // completed setting itself up and called us back. |
35 SyncBackendHostForProfileSyncTest( | 35 SyncBackendHostForProfileSyncTest( |
36 Profile* profile, | 36 Profile* profile, |
37 const base::WeakPtr<SyncPrefs>& sync_prefs, | 37 const base::WeakPtr<SyncPrefs>& sync_prefs, |
38 const base::WeakPtr<InvalidatorStorage>& invalidator_storage, | 38 const base::WeakPtr<InvalidatorStorage>& invalidator_storage, |
| 39 syncer::TestIdFactory& id_factory, |
| 40 base::Callback<void(syncer::UserShare*)>& callback, |
39 bool set_initial_sync_ended_on_init, | 41 bool set_initial_sync_ended_on_init, |
40 bool synchronous_init, | 42 bool synchronous_init, |
41 bool fail_initial_download, | 43 bool fail_initial_download, |
42 bool use_real_database); | 44 bool use_real_database); |
43 virtual ~SyncBackendHostForProfileSyncTest(); | 45 virtual ~SyncBackendHostForProfileSyncTest(); |
44 | 46 |
45 MOCK_METHOD1(RequestNudge, void(const tracked_objects::Location&)); | 47 MOCK_METHOD1(RequestNudge, void(const tracked_objects::Location&)); |
46 | 48 |
47 virtual void RequestConfigureSyncer( | 49 virtual void RequestConfigureSyncer( |
48 syncer::ConfigureReason reason, | 50 syncer::ConfigureReason reason, |
49 syncer::ModelTypeSet types_to_config, | 51 syncer::ModelTypeSet types_to_config, |
50 const syncer::ModelSafeRoutingInfo& routing_info, | 52 const syncer::ModelSafeRoutingInfo& routing_info, |
51 const base::Callback<void(syncer::ModelTypeSet)>& ready_task, | 53 const base::Callback<void(syncer::ModelTypeSet)>& ready_task, |
52 const base::Closure& retry_callback) OVERRIDE; | 54 const base::Closure& retry_callback) OVERRIDE; |
53 | 55 |
| 56 virtual void HandleSyncManagerInitializationOnFrontendLoop( |
| 57 const syncer::WeakHandle<syncer::JsBackend>& js_backend, bool success, |
| 58 syncer::ModelTypeSet restored_types) OVERRIDE; |
| 59 |
54 static void SetHistoryServiceExpectations(ProfileMock* profile); | 60 static void SetHistoryServiceExpectations(ProfileMock* profile); |
55 | 61 |
| 62 void SetInitialSyncEndedForAllTypes(); |
| 63 void dont_set_initial_sync_ended_on_init(); |
| 64 |
56 protected: | 65 protected: |
57 virtual void InitCore(const DoInitializeOptions& options) OVERRIDE; | 66 virtual void InitCore(const DoInitializeOptions& options) OVERRIDE; |
58 | 67 |
59 private: | 68 private: |
| 69 syncer::TestIdFactory& id_factory_; |
| 70 base::Callback<void(syncer::UserShare*)>& callback_; |
| 71 |
| 72 bool set_initial_sync_ended_on_init_; |
60 bool synchronous_init_; | 73 bool synchronous_init_; |
61 bool fail_initial_download_; | 74 bool fail_initial_download_; |
62 bool use_real_database_; | 75 bool use_real_database_; |
63 }; | 76 }; |
64 | 77 |
65 } // namespace browser_sync | 78 } // namespace browser_sync |
66 | 79 |
67 class TestProfileSyncService : public ProfileSyncService { | 80 class TestProfileSyncService : public ProfileSyncService { |
68 public: | 81 public: |
| 82 // A no-op callback for clients that don't need to inject code into the |
| 83 // intialization process. |
| 84 static base::Callback<void(syncer::UserShare*)> NullCallback(); |
| 85 |
69 // |callback| can be used to populate nodes before the OnBackendInitialized | 86 // |callback| can be used to populate nodes before the OnBackendInitialized |
70 // callback fires. | 87 // callback fires. |
71 // TODO(tim): Remove |synchronous_backend_initialization|, and add ability to | 88 // TODO(tim): Remove |synchronous_backend_initialization|, and add ability to |
72 // inject TokenService alongside SigninManager. | 89 // inject TokenService alongside SigninManager. |
73 TestProfileSyncService(ProfileSyncComponentsFactory* factory, | 90 TestProfileSyncService( |
74 Profile* profile, | 91 ProfileSyncComponentsFactory* factory, |
75 SigninManager* signin, | 92 Profile* profile, |
76 ProfileSyncService::StartBehavior behavior, | 93 SigninManager* signin, |
77 bool synchronous_backend_initialization, | 94 ProfileSyncService::StartBehavior behavior, |
78 const base::Closure& callback); | 95 bool synchronous_backend_initialization, |
| 96 const base::Callback<void(syncer::UserShare*)>& callback); |
79 | 97 |
80 virtual ~TestProfileSyncService(); | 98 virtual ~TestProfileSyncService(); |
81 | 99 |
82 void SetInitialSyncEndedForAllTypes(); | |
83 | |
84 virtual void OnBackendInitialized( | 100 virtual void OnBackendInitialized( |
85 const syncer::WeakHandle<syncer::JsBackend>& backend, | 101 const syncer::WeakHandle<syncer::JsBackend>& backend, |
86 bool success) OVERRIDE; | 102 bool success) OVERRIDE; |
87 | 103 |
88 virtual void Observe(int type, | 104 virtual void Observe(int type, |
89 const content::NotificationSource& source, | 105 const content::NotificationSource& source, |
90 const content::NotificationDetails& details) OVERRIDE; | 106 const content::NotificationDetails& details) OVERRIDE; |
91 | 107 |
92 // If this is called, configuring data types will require a syncer | 108 // If this is called, configuring data types will require a syncer |
93 // nudge. | 109 // nudge. |
(...skipping 16 matching lines...) Expand all Loading... |
110 | 126 |
111 private: | 127 private: |
112 syncer::TestIdFactory id_factory_; | 128 syncer::TestIdFactory id_factory_; |
113 | 129 |
114 bool synchronous_backend_initialization_; | 130 bool synchronous_backend_initialization_; |
115 | 131 |
116 // Set to true when a mock data type manager is being used and the configure | 132 // Set to true when a mock data type manager is being used and the configure |
117 // step is performed synchronously. | 133 // step is performed synchronously. |
118 bool synchronous_sync_configuration_; | 134 bool synchronous_sync_configuration_; |
119 | 135 |
120 base::Closure callback_; | 136 base::Callback<void(syncer::UserShare*)> callback_; |
121 bool set_initial_sync_ended_on_init_; | 137 bool set_initial_sync_ended_on_init_; |
122 | 138 |
123 bool fail_initial_download_; | 139 bool fail_initial_download_; |
124 bool use_real_database_; | 140 bool use_real_database_; |
125 }; | 141 }; |
126 | 142 |
127 | 143 |
128 | 144 |
129 #endif // CHROME_BROWSER_SYNC_TEST_PROFILE_SYNC_SERVICE_H_ | 145 #endif // CHROME_BROWSER_SYNC_TEST_PROFILE_SYNC_SERVICE_H_ |
OLD | NEW |