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

Side by Side Diff: components/sync/driver/async_directory_type_controller.cc

Issue 2769113002: [Sync] Stop accessing BrowserContextKeyedServiceFactory on non-UI thread. (Closed)
Patch Set: Rebase and removing dependent patch set. Created 3 years, 8 months 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/sync/driver/async_directory_type_controller.h" 5 #include "components/sync/driver/async_directory_type_controller.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 if (!model_load_callback_.is_null()) { 221 if (!model_load_callback_.is_null()) {
222 model_load_callback_.Run(type(), error); 222 model_load_callback_.Run(type(), error);
223 } 223 }
224 } 224 }
225 225
226 bool AsyncDirectoryTypeController::StartAssociationAsync() { 226 bool AsyncDirectoryTypeController::StartAssociationAsync() {
227 DCHECK(CalledOnValidThread()); 227 DCHECK(CalledOnValidThread());
228 DCHECK_EQ(state(), ASSOCIATING); 228 DCHECK_EQ(state(), ASSOCIATING);
229 return PostTaskOnModelThread( 229 return PostTaskOnModelThread(
230 FROM_HERE, 230 FROM_HERE,
231 // TODO(skym): Sending a non-owning SyncApiComponentFactory pointer across
232 // threads is less than ideal. Likely safe because of the locking and
233 // disconnect flag in SharedChangeProcessor. This object is only ever used
234 // for dead attachments code anyways.
231 base::Bind( 235 base::Bind(
232 &SharedChangeProcessor::StartAssociation, shared_change_processor_, 236 &SharedChangeProcessor::StartAssociation, shared_change_processor_,
233 BindToCurrentThread(base::Bind( 237 BindToCurrentThread(base::Bind(
234 &AsyncDirectoryTypeController::StartDone, base::AsWeakPtr(this))), 238 &AsyncDirectoryTypeController::StartDone, base::AsWeakPtr(this))),
235 sync_client_, processor_factory_.get(), user_share_, 239 sync_client_->GetSyncableServiceForType(type()),
236 base::Passed(CreateErrorHandler()))); 240 sync_client_->GetSyncApiComponentFactory(), processor_factory_.get(),
241 user_share_, base::Passed(CreateErrorHandler())));
237 } 242 }
238 243
239 ChangeProcessor* AsyncDirectoryTypeController::GetChangeProcessor() const { 244 ChangeProcessor* AsyncDirectoryTypeController::GetChangeProcessor() const {
240 DCHECK(CalledOnValidThread()); 245 DCHECK(CalledOnValidThread());
241 DCHECK_EQ(state_, RUNNING); 246 DCHECK_EQ(state_, RUNNING);
242 return shared_change_processor_->generic_change_processor(); 247 return shared_change_processor_->generic_change_processor();
243 } 248 }
244 249
245 void AsyncDirectoryTypeController::DisconnectSharedChangeProcessor() { 250 void AsyncDirectoryTypeController::DisconnectSharedChangeProcessor() {
246 DCHECK(CalledOnValidThread()); 251 DCHECK(CalledOnValidThread());
(...skipping 16 matching lines...) Expand all
263 std::unique_ptr<DataTypeErrorHandler> 268 std::unique_ptr<DataTypeErrorHandler>
264 AsyncDirectoryTypeController::CreateErrorHandler() { 269 AsyncDirectoryTypeController::CreateErrorHandler() {
265 DCHECK(CalledOnValidThread()); 270 DCHECK(CalledOnValidThread());
266 return base::MakeUnique<DataTypeErrorHandlerImpl>( 271 return base::MakeUnique<DataTypeErrorHandlerImpl>(
267 base::ThreadTaskRunnerHandle::Get(), dump_stack_, 272 base::ThreadTaskRunnerHandle::Get(), dump_stack_,
268 base::Bind(&AsyncDirectoryTypeController::DisableImpl, 273 base::Bind(&AsyncDirectoryTypeController::DisableImpl,
269 base::AsWeakPtr(this))); 274 base::AsWeakPtr(this)));
270 } 275 }
271 276
272 } // namespace syncer 277 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698