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

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

Issue 7281017: [Sync] Add RequestCleanupDisabledTypes() method to SyncManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Replaced with TODOs Created 9 years, 4 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/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 // notice that the routing info has changed and start the process of 381 // notice that the routing info has changed and start the process of
382 // downloading updates for newly added data types. Once this is 382 // downloading updates for newly added data types. Once this is
383 // complete, the configure_state_.ready_task_ is run via an 383 // complete, the configure_state_.ready_task_ is run via an
384 // OnInitializationComplete notification. 384 // OnInitializationComplete notification.
385 385
386 VLOG(1) << "Syncer in config mode. SBH executing" 386 VLOG(1) << "Syncer in config mode. SBH executing"
387 << "FinishConfigureDataTypesOnFrontendLoop"; 387 << "FinishConfigureDataTypesOnFrontendLoop";
388 if (pending_config_mode_state_->deleted_type) { 388 if (pending_config_mode_state_->deleted_type) {
389 sync_thread_.message_loop()->PostTask(FROM_HERE, 389 sync_thread_.message_loop()->PostTask(FROM_HERE,
390 NewRunnableMethod(core_.get(), 390 NewRunnableMethod(core_.get(),
391 &SyncBackendHost::Core::DeferNudgeForCleanup)); 391 &SyncBackendHost::Core::DeferCleanup));
392 } 392 }
393 393
394 if (pending_config_mode_state_->added_types.none() && 394 if (pending_config_mode_state_->added_types.none() &&
395 !core_->sync_manager()->InitialSyncEndedForAllEnabledTypes()) { 395 !core_->sync_manager()->InitialSyncEndedForAllEnabledTypes()) {
396 LOG(WARNING) << "No new types, but initial sync not finished." 396 LOG(WARNING) << "No new types, but initial sync not finished."
397 << "Possible sync db corruption / removal."; 397 << "Possible sync db corruption / removal.";
398 // TODO(tim): Log / UMA / count this somehow? 398 // TODO(tim): Log / UMA / count this somehow?
399 // TODO(tim): If no added types, we could (should?) config only for 399 // TODO(tim): If no added types, we could (should?) config only for
400 // types that are needed... but this is a rare corruption edge case or 400 // types that are needed... but this is a rare corruption edge case or
401 // implies the user mucked around with their syncdb, so for now do all. 401 // implies the user mucked around with their syncdb, so for now do all.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 NewRunnableMethod(core_.get(), 440 NewRunnableMethod(core_.get(),
441 &SyncBackendHost::Core::DoEncryptDataTypes, 441 &SyncBackendHost::Core::DoEncryptDataTypes,
442 encrypted_types)); 442 encrypted_types));
443 } 443 }
444 444
445 syncable::ModelTypeSet SyncBackendHost::GetEncryptedDataTypes() const { 445 syncable::ModelTypeSet SyncBackendHost::GetEncryptedDataTypes() const {
446 DCHECK_GT(initialization_state_, NOT_INITIALIZED); 446 DCHECK_GT(initialization_state_, NOT_INITIALIZED);
447 return core_->sync_manager()->GetEncryptedDataTypes(); 447 return core_->sync_manager()->GetEncryptedDataTypes();
448 } 448 }
449 449
450 void SyncBackendHost::RequestNudge(const tracked_objects::Location& location) {
451 sync_thread_.message_loop()->PostTask(FROM_HERE,
452 NewRunnableMethod(core_.get(), &SyncBackendHost::Core::DoRequestNudge,
453 location));
454 }
455
456 void SyncBackendHost::ActivateDataType( 450 void SyncBackendHost::ActivateDataType(
457 DataTypeController* data_type_controller, 451 DataTypeController* data_type_controller,
458 ChangeProcessor* change_processor) { 452 ChangeProcessor* change_processor) {
459 base::AutoLock lock(registrar_lock_); 453 base::AutoLock lock(registrar_lock_);
460 454
461 // Ensure that the given data type is in the PASSIVE group. 455 // Ensure that the given data type is in the PASSIVE group.
462 browser_sync::ModelSafeRoutingInfo::iterator i = 456 browser_sync::ModelSafeRoutingInfo::iterator i =
463 registrar_.routing_info.find(data_type_controller->type()); 457 registrar_.routing_info.find(data_type_controller->type());
464 DCHECK(i != registrar_.routing_info.end()); 458 DCHECK(i != registrar_.routing_info.end());
465 DCHECK((*i).second == GROUP_PASSIVE); 459 DCHECK((*i).second == GROUP_PASSIVE);
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 DCHECK(initialized()); 625 DCHECK(initialized());
632 return core_->sync_manager()->LogUnsyncedItems(level); 626 return core_->sync_manager()->LogUnsyncedItems(level);
633 } 627 }
634 628
635 SyncBackendHost::Core::Core(const std::string& name, SyncBackendHost* backend) 629 SyncBackendHost::Core::Core(const std::string& name, SyncBackendHost* backend)
636 : name_(name), 630 : name_(name),
637 host_(backend), 631 host_(backend),
638 sync_manager_observer_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 632 sync_manager_observer_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
639 parent_router_(NULL), 633 parent_router_(NULL),
640 processing_passphrase_(false), 634 processing_passphrase_(false),
641 deferred_nudge_for_cleanup_requested_(false) { 635 deferred_cleanup_requested_(false) {
642 } 636 }
643 637
644 // Helper to construct a user agent string (ASCII) suitable for use by 638 // Helper to construct a user agent string (ASCII) suitable for use by
645 // the syncapi for any HTTP communication. This string is used by the sync 639 // the syncapi for any HTTP communication. This string is used by the sync
646 // backend for classifying client types when calculating statistics. 640 // backend for classifying client types when calculating statistics.
647 std::string MakeUserAgentForSyncApi() { 641 std::string MakeUserAgentForSyncApi() {
648 std::string user_agent; 642 std::string user_agent;
649 user_agent = "Chrome "; 643 user_agent = "Chrome ";
650 #if defined(OS_WIN) 644 #if defined(OS_WIN)
651 user_agent += "WIN "; 645 user_agent += "WIN ";
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 } 705 }
712 706
713 void SyncBackendHost::Core::DoUpdateEnabledTypes() { 707 void SyncBackendHost::Core::DoUpdateEnabledTypes() {
714 DCHECK(MessageLoop::current() == host_->sync_thread_.message_loop()); 708 DCHECK(MessageLoop::current() == host_->sync_thread_.message_loop());
715 sync_manager_->UpdateEnabledTypes(); 709 sync_manager_->UpdateEnabledTypes();
716 } 710 }
717 711
718 void SyncBackendHost::Core::DoStartSyncing() { 712 void SyncBackendHost::Core::DoStartSyncing() {
719 DCHECK(MessageLoop::current() == host_->sync_thread_.message_loop()); 713 DCHECK(MessageLoop::current() == host_->sync_thread_.message_loop());
720 sync_manager_->StartSyncingNormally(); 714 sync_manager_->StartSyncingNormally();
721 if (deferred_nudge_for_cleanup_requested_) 715 if (deferred_cleanup_requested_)
722 sync_manager_->RequestNudge(FROM_HERE); 716 sync_manager_->RequestCleanupDisabledTypes();
723 deferred_nudge_for_cleanup_requested_ = false; 717 deferred_cleanup_requested_ = false;
724 } 718 }
725 719
726 void SyncBackendHost::Core::DoSetPassphrase(const std::string& passphrase, 720 void SyncBackendHost::Core::DoSetPassphrase(const std::string& passphrase,
727 bool is_explicit) { 721 bool is_explicit) {
728 DCHECK(MessageLoop::current() == host_->sync_thread_.message_loop()); 722 DCHECK(MessageLoop::current() == host_->sync_thread_.message_loop());
729 sync_manager_->SetPassphrase(passphrase, is_explicit); 723 sync_manager_->SetPassphrase(passphrase, is_explicit);
730 } 724 }
731 725
732 bool SyncBackendHost::Core::processing_passphrase() const { 726 bool SyncBackendHost::Core::processing_passphrase() const {
733 DCHECK(MessageLoop::current() == host_->frontend_loop_); 727 DCHECK(MessageLoop::current() == host_->frontend_loop_);
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
1073 1067
1074 parent_router_->RouteJsMessageReply(name, args, target); 1068 parent_router_->RouteJsMessageReply(name, args, target);
1075 } 1069 }
1076 1070
1077 void SyncBackendHost::Core::StartSavingChanges() { 1071 void SyncBackendHost::Core::StartSavingChanges() {
1078 save_changes_timer_.Start( 1072 save_changes_timer_.Start(
1079 base::TimeDelta::FromSeconds(kSaveChangesIntervalSeconds), 1073 base::TimeDelta::FromSeconds(kSaveChangesIntervalSeconds),
1080 this, &Core::SaveChanges); 1074 this, &Core::SaveChanges);
1081 } 1075 }
1082 1076
1083 void SyncBackendHost::Core::DoRequestNudge(
1084 const tracked_objects::Location& nudge_location) {
1085 sync_manager_->RequestNudge(nudge_location);
1086 }
1087
1088 void SyncBackendHost::Core::DoRequestClearServerData() { 1077 void SyncBackendHost::Core::DoRequestClearServerData() {
1089 sync_manager_->RequestClearServerData(); 1078 sync_manager_->RequestClearServerData();
1090 } 1079 }
1091 1080
1092 void SyncBackendHost::Core::SaveChanges() { 1081 void SyncBackendHost::Core::SaveChanges() {
1093 sync_manager_->SaveChanges(); 1082 sync_manager_->SaveChanges();
1094 } 1083 }
1095 1084
1096 void SyncBackendHost::Core::DeleteSyncDataFolder() { 1085 void SyncBackendHost::Core::DeleteSyncDataFolder() {
1097 if (file_util::DirectoryExists(host_->sync_data_folder_path())) { 1086 if (file_util::DirectoryExists(host_->sync_data_folder_path())) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 sync_manager_->RemoveObserver(&sync_manager_observer_); 1146 sync_manager_->RemoveObserver(&sync_manager_observer_);
1158 } 1147 }
1159 1148
1160 void SyncBackendHost::Core::DoProcessMessage( 1149 void SyncBackendHost::Core::DoProcessMessage(
1161 const std::string& name, const JsArgList& args, 1150 const std::string& name, const JsArgList& args,
1162 const JsEventHandler* sender) { 1151 const JsEventHandler* sender) {
1163 DCHECK_EQ(MessageLoop::current(), host_->sync_thread_.message_loop()); 1152 DCHECK_EQ(MessageLoop::current(), host_->sync_thread_.message_loop());
1164 sync_manager_->GetJsBackend()->ProcessMessage(name, args, sender); 1153 sync_manager_->GetJsBackend()->ProcessMessage(name, args, sender);
1165 } 1154 }
1166 1155
1167 void SyncBackendHost::Core::DeferNudgeForCleanup() { 1156 void SyncBackendHost::Core::DeferCleanup() {
1168 DCHECK_EQ(MessageLoop::current(), host_->sync_thread_.message_loop()); 1157 DCHECK_EQ(MessageLoop::current(), host_->sync_thread_.message_loop());
1169 deferred_nudge_for_cleanup_requested_ = true; 1158 deferred_cleanup_requested_ = true;
1170 } 1159 }
1171 1160
1172 } // namespace browser_sync 1161 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/sync_backend_host.h ('k') | chrome/browser/sync/test_profile_sync_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698