| 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 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 namespace browser_sync { | 35 namespace browser_sync { |
| 36 | 36 |
| 37 class SyncBackendHostForProfileSyncTest : public SyncBackendHostImpl { | 37 class SyncBackendHostForProfileSyncTest : public SyncBackendHostImpl { |
| 38 public: | 38 public: |
| 39 SyncBackendHostForProfileSyncTest( | 39 SyncBackendHostForProfileSyncTest( |
| 40 Profile* profile, | 40 Profile* profile, |
| 41 invalidation::InvalidationService* invalidator, | 41 invalidation::InvalidationService* invalidator, |
| 42 const base::WeakPtr<sync_driver::SyncPrefs>& sync_prefs, | 42 const base::WeakPtr<sync_driver::SyncPrefs>& sync_prefs, |
| 43 base::Closure callback); | 43 base::Closure callback); |
| 44 virtual ~SyncBackendHostForProfileSyncTest(); | 44 ~SyncBackendHostForProfileSyncTest() override; |
| 45 | 45 |
| 46 virtual void RequestConfigureSyncer( | 46 void RequestConfigureSyncer( |
| 47 syncer::ConfigureReason reason, | 47 syncer::ConfigureReason reason, |
| 48 syncer::ModelTypeSet to_download, | 48 syncer::ModelTypeSet to_download, |
| 49 syncer::ModelTypeSet to_purge, | 49 syncer::ModelTypeSet to_purge, |
| 50 syncer::ModelTypeSet to_journal, | 50 syncer::ModelTypeSet to_journal, |
| 51 syncer::ModelTypeSet to_unapply, | 51 syncer::ModelTypeSet to_unapply, |
| 52 syncer::ModelTypeSet to_ignore, | 52 syncer::ModelTypeSet to_ignore, |
| 53 const syncer::ModelSafeRoutingInfo& routing_info, | 53 const syncer::ModelSafeRoutingInfo& routing_info, |
| 54 const base::Callback<void(syncer::ModelTypeSet, | 54 const base::Callback<void(syncer::ModelTypeSet, syncer::ModelTypeSet)>& |
| 55 syncer::ModelTypeSet)>& ready_task, | 55 ready_task, |
| 56 const base::Closure& retry_callback) override; | 56 const base::Closure& retry_callback) override; |
| 57 | 57 |
| 58 protected: | 58 protected: |
| 59 virtual void InitCore(scoped_ptr<DoInitializeOptions> options) override; | 59 void InitCore(scoped_ptr<DoInitializeOptions> options) override; |
| 60 | 60 |
| 61 private: | 61 private: |
| 62 // Invoked at the start of HandleSyncManagerInitializationOnFrontendLoop. | 62 // Invoked at the start of HandleSyncManagerInitializationOnFrontendLoop. |
| 63 // Allows extra initialization work to be performed before the backend comes | 63 // Allows extra initialization work to be performed before the backend comes |
| 64 // up. | 64 // up. |
| 65 base::Closure callback_; | 65 base::Closure callback_; |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 } // namespace browser_sync | 68 } // namespace browser_sync |
| 69 | 69 |
| 70 class TestProfileSyncService : public ProfileSyncService { | 70 class TestProfileSyncService : public ProfileSyncService { |
| 71 public: | 71 public: |
| 72 // TODO(tim): Add ability to inject TokenService alongside SigninManager. | 72 // TODO(tim): Add ability to inject TokenService alongside SigninManager. |
| 73 // TODO(rogerta): what does above comment mean? | 73 // TODO(rogerta): what does above comment mean? |
| 74 TestProfileSyncService( | 74 TestProfileSyncService( |
| 75 scoped_ptr<ProfileSyncComponentsFactory> factory, | 75 scoped_ptr<ProfileSyncComponentsFactory> factory, |
| 76 Profile* profile, | 76 Profile* profile, |
| 77 SigninManagerBase* signin, | 77 SigninManagerBase* signin, |
| 78 ProfileOAuth2TokenService* oauth2_token_service, | 78 ProfileOAuth2TokenService* oauth2_token_service, |
| 79 browser_sync::ProfileSyncServiceStartBehavior behavior); | 79 browser_sync::ProfileSyncServiceStartBehavior behavior); |
| 80 | 80 |
| 81 virtual ~TestProfileSyncService(); | 81 ~TestProfileSyncService() override; |
| 82 | 82 |
| 83 virtual void OnConfigureDone( | 83 void OnConfigureDone( |
| 84 const sync_driver::DataTypeManager::ConfigureResult& result) override; | 84 const sync_driver::DataTypeManager::ConfigureResult& result) override; |
| 85 | 85 |
| 86 // We implement our own version to avoid some DCHECKs. | 86 // We implement our own version to avoid some DCHECKs. |
| 87 virtual syncer::UserShare* GetUserShare() const override; | 87 syncer::UserShare* GetUserShare() const override; |
| 88 | 88 |
| 89 static TestProfileSyncService* BuildAutoStartAsyncInit( | 89 static TestProfileSyncService* BuildAutoStartAsyncInit( |
| 90 Profile* profile, base::Closure callback); | 90 Profile* profile, base::Closure callback); |
| 91 | 91 |
| 92 ProfileSyncComponentsFactoryMock* components_factory_mock(); | 92 ProfileSyncComponentsFactoryMock* components_factory_mock(); |
| 93 | 93 |
| 94 syncer::TestIdFactory* id_factory(); | 94 syncer::TestIdFactory* id_factory(); |
| 95 | 95 |
| 96 // Raise visibility to ease testing. | 96 // Raise visibility to ease testing. |
| 97 using ProfileSyncService::NotifyObservers; | 97 using ProfileSyncService::NotifyObservers; |
| 98 | 98 |
| 99 protected: | 99 protected: |
| 100 static KeyedService* TestFactoryFunction(content::BrowserContext* profile); | 100 static KeyedService* TestFactoryFunction(content::BrowserContext* profile); |
| 101 | 101 |
| 102 // Return NULL handle to use in backend initialization to avoid receiving | 102 // Return NULL handle to use in backend initialization to avoid receiving |
| 103 // js messages on UI loop when it's being destroyed, which are not deleted | 103 // js messages on UI loop when it's being destroyed, which are not deleted |
| 104 // and cause memory leak in test. | 104 // and cause memory leak in test. |
| 105 virtual syncer::WeakHandle<syncer::JsEventHandler> GetJsEventHandler() | 105 syncer::WeakHandle<syncer::JsEventHandler> GetJsEventHandler() override; |
| 106 override; | |
| 107 | 106 |
| 108 virtual bool NeedBackup() const override; | 107 bool NeedBackup() const override; |
| 109 | 108 |
| 110 private: | 109 private: |
| 111 syncer::TestIdFactory id_factory_; | 110 syncer::TestIdFactory id_factory_; |
| 112 }; | 111 }; |
| 113 | 112 |
| 114 #endif // CHROME_BROWSER_SYNC_TEST_PROFILE_SYNC_SERVICE_H_ | 113 #endif // CHROME_BROWSER_SYNC_TEST_PROFILE_SYNC_SERVICE_H_ |
| OLD | NEW |