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

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

Issue 2489433002: [Sync] Move thread checking into the ModelSafeWorker interface. (Closed)
Patch Set: Improve/add comments. Created 4 years, 1 month 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
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/profile_sync_service.h" 5 #include "components/browser_sync/profile_sync_service.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 bool setup_in_progress_; 97 bool setup_in_progress_;
98 }; 98 };
99 99
100 // A variant of the SyncBackendHostMock that won't automatically 100 // A variant of the SyncBackendHostMock that won't automatically
101 // call back when asked to initialized. Allows us to test things 101 // call back when asked to initialized. Allows us to test things
102 // that could happen while backend init is in progress. 102 // that could happen while backend init is in progress.
103 class SyncBackendHostNoReturn : public SyncBackendHostMock { 103 class SyncBackendHostNoReturn : public SyncBackendHostMock {
104 void Initialize( 104 void Initialize(
105 syncer::SyncFrontend* frontend, 105 syncer::SyncFrontend* frontend,
106 base::Thread* sync_thread, 106 base::Thread* sync_thread,
107 const scoped_refptr<base::SingleThreadTaskRunner>& db_thread,
108 const scoped_refptr<base::SingleThreadTaskRunner>& file_thread,
109 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, 107 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler,
110 const GURL& service_url, 108 const GURL& service_url,
111 const std::string& sync_user_agent, 109 const std::string& sync_user_agent,
112 const syncer::SyncCredentials& credentials, 110 const syncer::SyncCredentials& credentials,
113 bool delete_sync_data_folder, 111 bool delete_sync_data_folder,
114 bool enable_local_sync_backend, 112 bool enable_local_sync_backend,
115 const base::FilePath& local_sync_backend_folder, 113 const base::FilePath& local_sync_backend_folder,
116 std::unique_ptr<syncer::SyncManagerFactory> sync_manager_factory, 114 std::unique_ptr<syncer::SyncManagerFactory> sync_manager_factory,
117 const syncer::WeakHandle<syncer::UnrecoverableErrorHandler>& 115 const syncer::WeakHandle<syncer::UnrecoverableErrorHandler>&
118 unrecoverable_error_handler, 116 unrecoverable_error_handler,
119 const base::Closure& report_unrecoverable_error_function, 117 const base::Closure& report_unrecoverable_error_function,
120 const HttpPostProviderFactoryGetter& http_post_provider_factory_getter, 118 const HttpPostProviderFactoryGetter& http_post_provider_factory_getter,
121 std::unique_ptr<syncer::SyncEncryptionHandler::NigoriState> 119 std::unique_ptr<syncer::SyncEncryptionHandler::NigoriState>
122 saved_nigori_state) override {} 120 saved_nigori_state) override {}
123 }; 121 };
124 122
125 class SyncBackendHostMockCollectDeleteDirParam : public SyncBackendHostMock { 123 class SyncBackendHostMockCollectDeleteDirParam : public SyncBackendHostMock {
126 public: 124 public:
127 explicit SyncBackendHostMockCollectDeleteDirParam( 125 explicit SyncBackendHostMockCollectDeleteDirParam(
128 std::vector<bool>* delete_dir_param) 126 std::vector<bool>* delete_dir_param)
129 : delete_dir_param_(delete_dir_param) {} 127 : delete_dir_param_(delete_dir_param) {}
130 128
131 void Initialize( 129 void Initialize(
132 syncer::SyncFrontend* frontend, 130 syncer::SyncFrontend* frontend,
133 base::Thread* sync_thread, 131 base::Thread* sync_thread,
134 const scoped_refptr<base::SingleThreadTaskRunner>& db_thread,
135 const scoped_refptr<base::SingleThreadTaskRunner>& file_thread,
136 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, 132 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler,
137 const GURL& service_url, 133 const GURL& service_url,
138 const std::string& sync_user_agent, 134 const std::string& sync_user_agent,
139 const syncer::SyncCredentials& credentials, 135 const syncer::SyncCredentials& credentials,
140 bool delete_sync_data_folder, 136 bool delete_sync_data_folder,
141 bool enable_local_sync_backend, 137 bool enable_local_sync_backend,
142 const base::FilePath& local_sync_backend_folder, 138 const base::FilePath& local_sync_backend_folder,
143 std::unique_ptr<syncer::SyncManagerFactory> sync_manager_factory, 139 std::unique_ptr<syncer::SyncManagerFactory> sync_manager_factory,
144 const syncer::WeakHandle<syncer::UnrecoverableErrorHandler>& 140 const syncer::WeakHandle<syncer::UnrecoverableErrorHandler>&
145 unrecoverable_error_handler, 141 unrecoverable_error_handler,
146 const base::Closure& report_unrecoverable_error_function, 142 const base::Closure& report_unrecoverable_error_function,
147 const HttpPostProviderFactoryGetter& http_post_provider_factory_getter, 143 const HttpPostProviderFactoryGetter& http_post_provider_factory_getter,
148 std::unique_ptr<syncer::SyncEncryptionHandler::NigoriState> 144 std::unique_ptr<syncer::SyncEncryptionHandler::NigoriState>
149 saved_nigori_state) override { 145 saved_nigori_state) override {
150 delete_dir_param_->push_back(delete_sync_data_folder); 146 delete_dir_param_->push_back(delete_sync_data_folder);
151 SyncBackendHostMock::Initialize( 147 SyncBackendHostMock::Initialize(
152 frontend, sync_thread, db_thread, file_thread, event_handler, 148 frontend, sync_thread, event_handler, service_url, sync_user_agent,
153 service_url, sync_user_agent, credentials, delete_sync_data_folder, 149 credentials, delete_sync_data_folder, enable_local_sync_backend,
154 enable_local_sync_backend, local_sync_backend_folder, 150 local_sync_backend_folder, std::move(sync_manager_factory),
155 std::move(sync_manager_factory), unrecoverable_error_handler, 151 unrecoverable_error_handler, report_unrecoverable_error_function,
156 report_unrecoverable_error_function, http_post_provider_factory_getter, 152 http_post_provider_factory_getter, std::move(saved_nigori_state));
157 std::move(saved_nigori_state));
158 } 153 }
159 154
160 private: 155 private:
161 std::vector<bool>* delete_dir_param_; 156 std::vector<bool>* delete_dir_param_;
162 }; 157 };
163 158
164 // SyncBackendHostMock that calls an external callback when ClearServerData is 159 // SyncBackendHostMock that calls an external callback when ClearServerData is
165 // called. 160 // called.
166 class SyncBackendHostCaptureClearServerData : public SyncBackendHostMock { 161 class SyncBackendHostCaptureClearServerData : public SyncBackendHostMock {
167 public: 162 public:
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after
952 // dereferenced in OnSyncCycleCompleted. The fix is to use find() to check if 947 // dereferenced in OnSyncCycleCompleted. The fix is to use find() to check if
953 // entry for sessions exists in map. 948 // entry for sessions exists in map.
954 TEST_F(ProfileSyncServiceTest, ValidPointersInDTCMap) { 949 TEST_F(ProfileSyncServiceTest, ValidPointersInDTCMap) {
955 CreateService(ProfileSyncService::AUTO_START); 950 CreateService(ProfileSyncService::AUTO_START);
956 service()->OnSessionRestoreComplete(); 951 service()->OnSessionRestoreComplete();
957 service()->OnSyncCycleCompleted(); 952 service()->OnSyncCycleCompleted();
958 } 953 }
959 954
960 } // namespace 955 } // namespace
961 } // namespace browser_sync 956 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698