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

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

Issue 1418513005: [sync] Set up notification-free infra for triggering local sync refresh (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/sync/glue/sync_backend_host_impl.h" 5 #include "chrome/browser/sync/glue/sync_backend_host_impl.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 sync_prefs_->GetEncryptionBootstrapToken(), 167 sync_prefs_->GetEncryptionBootstrapToken(),
168 sync_prefs_->GetKeystoreEncryptionBootstrapToken(), 168 sync_prefs_->GetKeystoreEncryptionBootstrapToken(),
169 scoped_ptr<InternalComponentsFactory>( 169 scoped_ptr<InternalComponentsFactory>(
170 new syncer::InternalComponentsFactoryImpl(factory_switches)) 170 new syncer::InternalComponentsFactoryImpl(factory_switches))
171 .Pass(), 171 .Pass(),
172 unrecoverable_error_handler, report_unrecoverable_error_function, 172 unrecoverable_error_handler, report_unrecoverable_error_function,
173 saved_nigori_state.Pass(), clear_data_option, invalidation_versions)); 173 saved_nigori_state.Pass(), clear_data_option, invalidation_versions));
174 InitCore(init_opts.Pass()); 174 InitCore(init_opts.Pass());
175 } 175 }
176 176
177 void SyncBackendHostImpl::TriggerRefresh(const syncer::ModelTypeSet& types) {
178 DCHECK(ui_thread_->BelongsToCurrentThread());
179 registrar_->sync_thread()->task_runner()->PostTask(
180 FROM_HERE,
181 base::Bind(&SyncBackendHostCore::DoRefreshTypes, core_.get(), types));
182 }
183
177 void SyncBackendHostImpl::UpdateCredentials( 184 void SyncBackendHostImpl::UpdateCredentials(
178 const syncer::SyncCredentials& credentials) { 185 const syncer::SyncCredentials& credentials) {
179 DCHECK(registrar_->sync_thread()->IsRunning()); 186 DCHECK(registrar_->sync_thread()->IsRunning());
180 registrar_->sync_thread()->task_runner()->PostTask( 187 registrar_->sync_thread()->task_runner()->PostTask(
181 FROM_HERE, base::Bind(&SyncBackendHostCore::DoUpdateCredentials, 188 FROM_HERE, base::Bind(&SyncBackendHostCore::DoUpdateCredentials,
182 core_.get(), credentials)); 189 core_.get(), credentials));
183 } 190 }
184 191
185 void SyncBackendHostImpl::StartSyncingWithServer() { 192 void SyncBackendHostImpl::StartSyncingWithServer() {
186 SDVLOG(1) << "SyncBackendHostImpl::StartSyncingWithServer called."; 193 SDVLOG(1) << "SyncBackendHostImpl::StartSyncingWithServer called.";
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 } 629 }
623 630
624 if (!ready_task.is_null()) 631 if (!ready_task.is_null())
625 ready_task.Run(succeeded_configuration_types, failed_configuration_types); 632 ready_task.Run(succeeded_configuration_types, failed_configuration_types);
626 } 633 }
627 634
628 void SyncBackendHostImpl::Observe( 635 void SyncBackendHostImpl::Observe(
629 int type, 636 int type,
630 const content::NotificationSource& source, 637 const content::NotificationSource& source,
631 const content::NotificationDetails& details) { 638 const content::NotificationDetails& details) {
632 DCHECK(ui_thread_->BelongsToCurrentThread());
633 DCHECK_EQ(type, chrome::NOTIFICATION_SYNC_REFRESH_LOCAL); 639 DCHECK_EQ(type, chrome::NOTIFICATION_SYNC_REFRESH_LOCAL);
634 640
635 content::Details<const syncer::ModelTypeSet> state_details(details); 641 content::Details<const syncer::ModelTypeSet> state_details(details);
636 const syncer::ModelTypeSet& types = *(state_details.ptr()); 642 const syncer::ModelTypeSet& types = *(state_details.ptr());
637 registrar_->sync_thread()->task_runner()->PostTask( 643 TriggerRefresh(types);
638 FROM_HERE,
639 base::Bind(&SyncBackendHostCore::DoRefreshTypes, core_.get(), types));
640 } 644 }
641 645
642 void SyncBackendHostImpl::AddExperimentalTypes() { 646 void SyncBackendHostImpl::AddExperimentalTypes() {
643 CHECK(initialized()); 647 CHECK(initialized());
644 syncer::Experiments experiments; 648 syncer::Experiments experiments;
645 if (core_->sync_manager()->ReceivedExperiment(&experiments)) 649 if (core_->sync_manager()->ReceivedExperiment(&experiments))
646 frontend_->OnExperimentsChanged(experiments); 650 frontend_->OnExperimentsChanged(experiments);
647 } 651 }
648 652
649 void SyncBackendHostImpl::HandleInitializationSuccessOnFrontendLoop( 653 void SyncBackendHostImpl::HandleInitializationSuccessOnFrontendLoop(
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 const syncer::SyncManager::ClearServerDataCallback& frontend_callback) { 918 const syncer::SyncManager::ClearServerDataCallback& frontend_callback) {
915 DCHECK(ui_thread_->BelongsToCurrentThread()); 919 DCHECK(ui_thread_->BelongsToCurrentThread());
916 frontend_callback.Run(); 920 frontend_callback.Run();
917 } 921 }
918 922
919 } // namespace browser_sync 923 } // namespace browser_sync
920 924
921 #undef SDVLOG 925 #undef SDVLOG
922 926
923 #undef SLOG 927 #undef SLOG
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698