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

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

Issue 2799653006: Revert of [Sync] Stop accessing BrowserContextKeyedServiceFactory on non-UI thread. (Closed)
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.
235 base::Bind( 231 base::Bind(
236 &SharedChangeProcessor::StartAssociation, shared_change_processor_, 232 &SharedChangeProcessor::StartAssociation, shared_change_processor_,
237 BindToCurrentThread(base::Bind( 233 BindToCurrentThread(base::Bind(
238 &AsyncDirectoryTypeController::StartDone, base::AsWeakPtr(this))), 234 &AsyncDirectoryTypeController::StartDone, base::AsWeakPtr(this))),
239 sync_client_->GetSyncableServiceForType(type()), 235 sync_client_, processor_factory_.get(), user_share_,
240 sync_client_->GetSyncApiComponentFactory(), processor_factory_.get(), 236 base::Passed(CreateErrorHandler())));
241 user_share_, base::Passed(CreateErrorHandler())));
242 } 237 }
243 238
244 ChangeProcessor* AsyncDirectoryTypeController::GetChangeProcessor() const { 239 ChangeProcessor* AsyncDirectoryTypeController::GetChangeProcessor() const {
245 DCHECK(CalledOnValidThread()); 240 DCHECK(CalledOnValidThread());
246 DCHECK_EQ(state_, RUNNING); 241 DCHECK_EQ(state_, RUNNING);
247 return shared_change_processor_->generic_change_processor(); 242 return shared_change_processor_->generic_change_processor();
248 } 243 }
249 244
250 void AsyncDirectoryTypeController::DisconnectSharedChangeProcessor() { 245 void AsyncDirectoryTypeController::DisconnectSharedChangeProcessor() {
251 DCHECK(CalledOnValidThread()); 246 DCHECK(CalledOnValidThread());
(...skipping 16 matching lines...) Expand all
268 std::unique_ptr<DataTypeErrorHandler> 263 std::unique_ptr<DataTypeErrorHandler>
269 AsyncDirectoryTypeController::CreateErrorHandler() { 264 AsyncDirectoryTypeController::CreateErrorHandler() {
270 DCHECK(CalledOnValidThread()); 265 DCHECK(CalledOnValidThread());
271 return base::MakeUnique<DataTypeErrorHandlerImpl>( 266 return base::MakeUnique<DataTypeErrorHandlerImpl>(
272 base::ThreadTaskRunnerHandle::Get(), dump_stack_, 267 base::ThreadTaskRunnerHandle::Get(), dump_stack_,
273 base::Bind(&AsyncDirectoryTypeController::DisableImpl, 268 base::Bind(&AsyncDirectoryTypeController::DisableImpl,
274 base::AsWeakPtr(this))); 269 base::AsWeakPtr(this)));
275 } 270 }
276 271
277 } // namespace syncer 272 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698