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

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: Response to review Created 5 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 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 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 } 622 }
616 623
617 if (!ready_task.is_null()) 624 if (!ready_task.is_null())
618 ready_task.Run(succeeded_configuration_types, failed_configuration_types); 625 ready_task.Run(succeeded_configuration_types, failed_configuration_types);
619 } 626 }
620 627
621 void SyncBackendHostImpl::Observe( 628 void SyncBackendHostImpl::Observe(
622 int type, 629 int type,
623 const content::NotificationSource& source, 630 const content::NotificationSource& source,
624 const content::NotificationDetails& details) { 631 const content::NotificationDetails& details) {
625 DCHECK(ui_thread_->BelongsToCurrentThread());
626 DCHECK_EQ(type, chrome::NOTIFICATION_SYNC_REFRESH_LOCAL); 632 DCHECK_EQ(type, chrome::NOTIFICATION_SYNC_REFRESH_LOCAL);
627 633
628 content::Details<const syncer::ModelTypeSet> state_details(details); 634 content::Details<const syncer::ModelTypeSet> state_details(details);
629 const syncer::ModelTypeSet& types = *(state_details.ptr()); 635 const syncer::ModelTypeSet& types = *(state_details.ptr());
630 registrar_->sync_thread()->task_runner()->PostTask( 636 TriggerRefresh(types);
631 FROM_HERE,
632 base::Bind(&SyncBackendHostCore::DoRefreshTypes, core_.get(), types));
633 } 637 }
634 638
635 void SyncBackendHostImpl::AddExperimentalTypes() { 639 void SyncBackendHostImpl::AddExperimentalTypes() {
636 CHECK(initialized()); 640 CHECK(initialized());
637 syncer::Experiments experiments; 641 syncer::Experiments experiments;
638 if (core_->sync_manager()->ReceivedExperiment(&experiments)) 642 if (core_->sync_manager()->ReceivedExperiment(&experiments))
639 frontend_->OnExperimentsChanged(experiments); 643 frontend_->OnExperimentsChanged(experiments);
640 } 644 }
641 645
642 void SyncBackendHostImpl::HandleInitializationSuccessOnFrontendLoop( 646 void SyncBackendHostImpl::HandleInitializationSuccessOnFrontendLoop(
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 const syncer::SyncManager::ClearServerDataCallback& frontend_callback) { 911 const syncer::SyncManager::ClearServerDataCallback& frontend_callback) {
908 DCHECK(ui_thread_->BelongsToCurrentThread()); 912 DCHECK(ui_thread_->BelongsToCurrentThread());
909 frontend_callback.Run(); 913 frontend_callback.Run();
910 } 914 }
911 915
912 } // namespace browser_sync 916 } // namespace browser_sync
913 917
914 #undef SDVLOG 918 #undef SDVLOG
915 919
916 #undef SLOG 920 #undef SLOG
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/sync_backend_host_impl.h ('k') | chrome/browser/sync/glue/sync_backend_host_mock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698