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

Side by Side Diff: components/browser_sync/abstract_profile_sync_service_test.cc

Issue 2559123002: [Sync] SyncEngine refactor part 2: SyncServiceBase. (Closed)
Patch Set: Address comments. Created 4 years 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
« no previous file with comments | « no previous file | components/browser_sync/profile_sync_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "components/browser_sync/abstract_profile_sync_service_test.h" 5 #include "components/browser_sync/abstract_profile_sync_service_test.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 13 matching lines...) Expand all
24 24
25 using syncer::SyncBackendHostImpl; 25 using syncer::SyncBackendHostImpl;
26 using syncer::ModelType; 26 using syncer::ModelType;
27 using testing::_; 27 using testing::_;
28 using testing::Return; 28 using testing::Return;
29 29
30 namespace browser_sync { 30 namespace browser_sync {
31 31
32 namespace { 32 namespace {
33 33
34 std::unique_ptr<syncer::HttpPostProviderFactory> GetHttpPostProviderFactory(
35 syncer::CancelationSignal* signal) {
36 return base::MakeUnique<TestHttpBridgeFactory>();
37 }
38
34 class SyncEngineForProfileSyncTest : public SyncBackendHostImpl { 39 class SyncEngineForProfileSyncTest : public SyncBackendHostImpl {
35 public: 40 public:
36 SyncEngineForProfileSyncTest( 41 SyncEngineForProfileSyncTest(
37 const base::FilePath& temp_dir, 42 const base::FilePath& temp_dir,
38 syncer::SyncClient* sync_client, 43 syncer::SyncClient* sync_client,
39 invalidation::InvalidationService* invalidator, 44 invalidation::InvalidationService* invalidator,
40 const base::WeakPtr<syncer::SyncPrefs>& sync_prefs, 45 const base::WeakPtr<syncer::SyncPrefs>& sync_prefs,
41 const base::Closure& callback); 46 const base::Closure& callback);
42 ~SyncEngineForProfileSyncTest() override; 47 ~SyncEngineForProfileSyncTest() override;
43 48
49 void Initialize(InitParams params) override;
50
44 void RequestConfigureSyncer( 51 void RequestConfigureSyncer(
45 syncer::ConfigureReason reason, 52 syncer::ConfigureReason reason,
46 syncer::ModelTypeSet to_download, 53 syncer::ModelTypeSet to_download,
47 const syncer::ModelSafeRoutingInfo& routing_info, 54 const syncer::ModelSafeRoutingInfo& routing_info,
48 const base::Callback<void(syncer::ModelTypeSet, syncer::ModelTypeSet)>& 55 const base::Callback<void(syncer::ModelTypeSet, syncer::ModelTypeSet)>&
49 ready_task, 56 ready_task,
50 const base::Closure& retry_callback) override; 57 const base::Closure& retry_callback) override;
51 58
52 protected:
53 void InitCore(std::unique_ptr<syncer::DoInitializeOptions> options) override;
54
55 private: 59 private:
56 // Invoked at the start of HandleSyncManagerInitializationOnFrontendLoop. 60 // Invoked at the start of HandleSyncManagerInitializationOnFrontendLoop.
57 // Allows extra initialization work to be performed before the engine comes 61 // Allows extra initialization work to be performed before the engine comes
58 // up. 62 // up.
59 base::Closure callback_; 63 base::Closure callback_;
60 64
61 DISALLOW_COPY_AND_ASSIGN(SyncEngineForProfileSyncTest); 65 DISALLOW_COPY_AND_ASSIGN(SyncEngineForProfileSyncTest);
62 }; 66 };
63 67
64 SyncEngineForProfileSyncTest::SyncEngineForProfileSyncTest( 68 SyncEngineForProfileSyncTest::SyncEngineForProfileSyncTest(
65 const base::FilePath& temp_dir, 69 const base::FilePath& temp_dir,
66 syncer::SyncClient* sync_client, 70 syncer::SyncClient* sync_client,
67 invalidation::InvalidationService* invalidator, 71 invalidation::InvalidationService* invalidator,
68 const base::WeakPtr<syncer::SyncPrefs>& sync_prefs, 72 const base::WeakPtr<syncer::SyncPrefs>& sync_prefs,
69 const base::Closure& callback) 73 const base::Closure& callback)
70 : SyncBackendHostImpl( 74 : SyncBackendHostImpl(
71 "dummy_debug_name", 75 "dummy_debug_name",
72 sync_client, 76 sync_client,
73 invalidator, 77 invalidator,
74 sync_prefs, 78 sync_prefs,
75 temp_dir.Append(base::FilePath(FILE_PATH_LITERAL("test")))), 79 temp_dir.Append(base::FilePath(FILE_PATH_LITERAL("test")))),
76 callback_(callback) {} 80 callback_(callback) {}
77 81
78 SyncEngineForProfileSyncTest::~SyncEngineForProfileSyncTest() {} 82 SyncEngineForProfileSyncTest::~SyncEngineForProfileSyncTest() {}
79 83
80 void SyncEngineForProfileSyncTest::InitCore( 84 void SyncEngineForProfileSyncTest::Initialize(InitParams params) {
81 std::unique_ptr<syncer::DoInitializeOptions> options) { 85 params.http_factory_getter = base::Bind(&GetHttpPostProviderFactory);
82 options->http_bridge_factory = base::MakeUnique<TestHttpBridgeFactory>(); 86 params.sync_manager_factory =
83 options->sync_manager_factory =
84 base::MakeUnique<syncer::SyncManagerFactoryForProfileSyncTest>(callback_); 87 base::MakeUnique<syncer::SyncManagerFactoryForProfileSyncTest>(callback_);
85 options->credentials.email = "testuser@gmail.com"; 88 params.credentials.email = "testuser@gmail.com";
86 options->credentials.sync_token = "token"; 89 params.credentials.sync_token = "token";
87 options->credentials.scope_set.insert(GaiaConstants::kChromeSyncOAuth2Scope); 90 params.credentials.scope_set.insert(GaiaConstants::kChromeSyncOAuth2Scope);
88 options->restored_key_for_bootstrapping.clear(); 91 params.restored_key_for_bootstrapping.clear();
89 92
90 // It'd be nice if we avoided creating the EngineComponentsFactory in the 93 // It'd be nice if we avoided creating the EngineComponentsFactory in the
91 // first place, but SyncEngine will have created one by now so we must free 94 // first place, but SyncEngine will have created one by now so we must free
92 // it. Grab the switches to pass on first. 95 // it. Grab the switches to pass on first.
93 syncer::EngineComponentsFactory::Switches factory_switches = 96 syncer::EngineComponentsFactory::Switches factory_switches =
94 options->engine_components_factory->GetSwitches(); 97 params.engine_components_factory->GetSwitches();
95 options->engine_components_factory = 98 params.engine_components_factory =
96 base::MakeUnique<syncer::TestEngineComponentsFactory>( 99 base::MakeUnique<syncer::TestEngineComponentsFactory>(
97 factory_switches, syncer::EngineComponentsFactory::STORAGE_IN_MEMORY, 100 factory_switches, syncer::EngineComponentsFactory::STORAGE_IN_MEMORY,
98 nullptr); 101 nullptr);
99 102
100 SyncBackendHostImpl::InitCore(std::move(options)); 103 SyncBackendHostImpl::Initialize(std::move(params));
101 } 104 }
102 105
103 void SyncEngineForProfileSyncTest::RequestConfigureSyncer( 106 void SyncEngineForProfileSyncTest::RequestConfigureSyncer(
104 syncer::ConfigureReason reason, 107 syncer::ConfigureReason reason,
105 syncer::ModelTypeSet to_download, 108 syncer::ModelTypeSet to_download,
106 const syncer::ModelSafeRoutingInfo& routing_info, 109 const syncer::ModelSafeRoutingInfo& routing_info,
107 const base::Callback<void(syncer::ModelTypeSet, syncer::ModelTypeSet)>& 110 const base::Callback<void(syncer::ModelTypeSet, syncer::ModelTypeSet)>&
108 ready_task, 111 ready_task,
109 const base::Closure& retry_callback) { 112 const base::Closure& retry_callback) {
110 syncer::ModelTypeSet failed_configuration_types; 113 syncer::ModelTypeSet failed_configuration_types;
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 219
217 bool CreateRootHelper::success() { 220 bool CreateRootHelper::success() {
218 return success_; 221 return success_;
219 } 222 }
220 223
221 void CreateRootHelper::CreateRootCallback() { 224 void CreateRootHelper::CreateRootCallback() {
222 success_ = test_->CreateRoot(model_type_); 225 success_ = test_->CreateRoot(model_type_);
223 } 226 }
224 227
225 } // namespace browser_sync 228 } // namespace browser_sync
OLDNEW
« no previous file with comments | « no previous file | components/browser_sync/profile_sync_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698