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

Side by Side Diff: chrome/browser/sync/glue/sync_backend_host.cc

Issue 6812004: sync: Make nudge + config jobs reliable in SyncerThread2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix sync backend host to call configure on right thread. Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 { 405 {
406 base::AutoLock lock(registrar_lock_); 406 base::AutoLock lock(registrar_lock_);
407 pending_config_mode_state_.reset( 407 pending_config_mode_state_.reset(
408 MakePendingConfigModeState(data_type_controllers, types, ready_task, 408 MakePendingConfigModeState(data_type_controllers, types, ready_task,
409 &registrar_.routing_info)); 409 &registrar_.routing_info));
410 } 410 }
411 411
412 // If we're doing the first configure (at startup) this is redundant as the 412 // If we're doing the first configure (at startup) this is redundant as the
413 // syncer thread always must start in config mode. 413 // syncer thread always must start in config mode.
414 if (using_new_syncer_thread_) { 414 if (using_new_syncer_thread_) {
415 core_->syncapi()->StartConfigurationMode(NewCallback(core_.get(), 415 core_thread_.message_loop()->PostTask(
416 &SyncBackendHost::Core::FinishConfigureDataTypes)); 416 FROM_HERE,
417 NewRunnableMethod(core_.get(),
418 &SyncBackendHost::Core::StartConfigurationMode));
417 } else { 419 } else {
418 FinishConfigureDataTypesOnFrontendLoop(); 420 FinishConfigureDataTypesOnFrontendLoop();
419 } 421 }
420 } 422 }
421 423
422 void SyncBackendHost::FinishConfigureDataTypesOnFrontendLoop() { 424 void SyncBackendHost::FinishConfigureDataTypesOnFrontendLoop() {
423 DCHECK_EQ(MessageLoop::current(), frontend_loop_); 425 DCHECK_EQ(MessageLoop::current(), frontend_loop_);
424 // Nudge the syncer. This is necessary for both datatype addition/deletion. 426 // Nudge the syncer. This is necessary for both datatype addition/deletion.
425 // 427 //
426 // Deletions need a nudge in order to ensure the deletion occurs in a timely 428 // Deletions need a nudge in order to ensure the deletion occurs in a timely
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 648
647 void SyncBackendHost::Core::CreateSyncNotifier( 649 void SyncBackendHost::Core::CreateSyncNotifier(
648 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter) { 650 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter) {
649 const std::string& client_info = webkit_glue::GetUserAgent(GURL()); 651 const std::string& client_info = webkit_glue::GetUserAgent(GURL());
650 SyncNotifierFactory sync_notifier_factory(client_info); 652 SyncNotifierFactory sync_notifier_factory(client_info);
651 sync_notifier_.reset(sync_notifier_factory.CreateSyncNotifier( 653 sync_notifier_.reset(sync_notifier_factory.CreateSyncNotifier(
652 *CommandLine::ForCurrentProcess(), 654 *CommandLine::ForCurrentProcess(),
653 request_context_getter)); 655 request_context_getter));
654 } 656 }
655 657
658 void SyncBackendHost::Core::StartConfigurationMode() {
tim (not reviewing) 2011/04/15 00:21:43 should call this 'DoStartConfigurationMode'
lipalani1 2011/04/15 01:24:39 Done.
659 syncapi_->StartConfigurationMode(NewCallback(this,
660 &SyncBackendHost::Core::FinishConfigureDataTypes));
661 }
662
656 SyncBackendHost::Core::DoInitializeOptions::DoInitializeOptions( 663 SyncBackendHost::Core::DoInitializeOptions::DoInitializeOptions(
657 const GURL& service_url, 664 const GURL& service_url,
658 sync_api::HttpPostProviderFactory* http_bridge_factory, 665 sync_api::HttpPostProviderFactory* http_bridge_factory,
659 const sync_api::SyncCredentials& credentials, 666 const sync_api::SyncCredentials& credentials,
660 bool delete_sync_data_folder, 667 bool delete_sync_data_folder,
661 const std::string& restored_key_for_bootstrapping, 668 const std::string& restored_key_for_bootstrapping,
662 bool setup_for_test_mode) 669 bool setup_for_test_mode)
663 : service_url(service_url), 670 : service_url(service_url),
664 http_bridge_factory(http_bridge_factory), 671 http_bridge_factory(http_bridge_factory),
665 credentials(credentials), 672 credentials(credentials),
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
1210 DCHECK_EQ(MessageLoop::current(), host_->core_thread_.message_loop()); 1217 DCHECK_EQ(MessageLoop::current(), host_->core_thread_.message_loop());
1211 syncapi_->GetJsBackend()->ProcessMessage(name, args, sender); 1218 syncapi_->GetJsBackend()->ProcessMessage(name, args, sender);
1212 } 1219 }
1213 1220
1214 void SyncBackendHost::Core::DeferNudgeForCleanup() { 1221 void SyncBackendHost::Core::DeferNudgeForCleanup() {
1215 DCHECK_EQ(MessageLoop::current(), host_->core_thread_.message_loop()); 1222 DCHECK_EQ(MessageLoop::current(), host_->core_thread_.message_loop());
1216 deferred_nudge_for_cleanup_requested_ = true; 1223 deferred_nudge_for_cleanup_requested_ = true;
1217 } 1224 }
1218 1225
1219 } // namespace browser_sync 1226 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698