| 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::Closure& 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::Closure& 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: |
| 69 // |callback| can be used to populate nodes before the OnBackendInitialized | 82 // |callback| can be used to populate nodes before the OnBackendInitialized |
| 70 // callback fires. | 83 // callback fires. |
| 71 // TODO(tim): Remove |synchronous_backend_initialization|, and add ability to | 84 // TODO(tim): Remove |synchronous_backend_initialization|, and add ability to |
| 72 // inject TokenService alongside SigninManager. | 85 // inject TokenService alongside SigninManager. |
| 73 TestProfileSyncService(ProfileSyncComponentsFactory* factory, | 86 TestProfileSyncService( |
| 74 Profile* profile, | 87 ProfileSyncComponentsFactory* factory, |
| 75 SigninManager* signin, | 88 Profile* profile, |
| 76 ProfileSyncService::StartBehavior behavior, | 89 SigninManager* signin, |
| 77 bool synchronous_backend_initialization, | 90 ProfileSyncService::StartBehavior behavior, |
| 78 const base::Closure& callback); | 91 bool synchronous_backend_initialization, |
| 92 const base::Closure& callback); |
| 79 | 93 |
| 80 virtual ~TestProfileSyncService(); | 94 virtual ~TestProfileSyncService(); |
| 81 | 95 |
| 82 void SetInitialSyncEndedForAllTypes(); | |
| 83 | |
| 84 virtual void OnBackendInitialized( | 96 virtual void OnBackendInitialized( |
| 85 const syncer::WeakHandle<syncer::JsBackend>& backend, | 97 const syncer::WeakHandle<syncer::JsBackend>& backend, |
| 86 bool success) OVERRIDE; | 98 bool success) OVERRIDE; |
| 87 | 99 |
| 88 virtual void Observe(int type, | 100 virtual void Observe(int type, |
| 89 const content::NotificationSource& source, | 101 const content::NotificationSource& source, |
| 90 const content::NotificationDetails& details) OVERRIDE; | 102 const content::NotificationDetails& details) OVERRIDE; |
| 91 | 103 |
| 104 // We implement our own version to avoid some DCHECKs. |
| 105 virtual syncer::UserShare* GetUserShare() const OVERRIDE; |
| 106 |
| 92 // If this is called, configuring data types will require a syncer | 107 // If this is called, configuring data types will require a syncer |
| 93 // nudge. | 108 // nudge. |
| 94 void dont_set_initial_sync_ended_on_init(); | 109 void dont_set_initial_sync_ended_on_init(); |
| 95 void set_synchronous_sync_configuration(); | 110 void set_synchronous_sync_configuration(); |
| 96 | 111 |
| 97 void fail_initial_download(); | 112 void fail_initial_download(); |
| 98 void set_use_real_database(); | 113 void set_use_real_database(); |
| 99 | 114 |
| 100 syncer::TestIdFactory* id_factory(); | 115 syncer::TestIdFactory* id_factory(); |
| 101 | 116 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 120 base::Closure callback_; | 135 base::Closure callback_; |
| 121 bool set_initial_sync_ended_on_init_; | 136 bool set_initial_sync_ended_on_init_; |
| 122 | 137 |
| 123 bool fail_initial_download_; | 138 bool fail_initial_download_; |
| 124 bool use_real_database_; | 139 bool use_real_database_; |
| 125 }; | 140 }; |
| 126 | 141 |
| 127 | 142 |
| 128 | 143 |
| 129 #endif // CHROME_BROWSER_SYNC_TEST_PROFILE_SYNC_SERVICE_H_ | 144 #endif // CHROME_BROWSER_SYNC_TEST_PROFILE_SYNC_SERVICE_H_ |
| OLD | NEW |