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

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: Created 9 years, 5 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 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 // profile node. 334 // profile node.
335 DCHECK(false); 335 DCHECK(false);
336 336
337 // just set it as not migrated. 337 // just set it as not migrated.
338 SetAutofillMigrationState(syncable::NOT_MIGRATED); 338 SetAutofillMigrationState(syncable::NOT_MIGRATED);
339 return; 339 return;
340 } 340 }
341 } 341 }
342 342
343 SyncBackendHost::PendingConfigureDataTypesState:: 343 SyncBackendHost::PendingConfigureDataTypesState::
344 PendingConfigureDataTypesState() : deleted_type(false), 344 PendingConfigureDataTypesState()
345 reason(sync_api::CONFIGURE_REASON_UNKNOWN) {} 345 : reason(sync_api::CONFIGURE_REASON_UNKNOWN) {}
346 346
347 SyncBackendHost::PendingConfigureDataTypesState:: 347 SyncBackendHost::PendingConfigureDataTypesState::
348 ~PendingConfigureDataTypesState() {} 348 ~PendingConfigureDataTypesState() {}
349 349
350 SyncBackendHost::PendingConfigureDataTypesState* 350 SyncBackendHost::PendingConfigureDataTypesState*
351 SyncBackendHost::MakePendingConfigModeState( 351 SyncBackendHost::MakePendingConfigModeState(
352 const DataTypeController::TypeMap& data_type_controllers, 352 const DataTypeController::TypeMap& data_type_controllers,
353 const syncable::ModelTypeSet& types, 353 const syncable::ModelTypeSet& types,
354 CancelableTask* ready_task, 354 CancelableTask* ready_task,
355 ModelSafeRoutingInfo* routing_info, 355 ModelSafeRoutingInfo* routing_info,
356 sync_api::ConfigureReason reason, 356 sync_api::ConfigureReason reason,
357 bool nigori_enabled) { 357 bool nigori_enabled) {
358 PendingConfigureDataTypesState* state = new PendingConfigureDataTypesState(); 358 PendingConfigureDataTypesState* state = new PendingConfigureDataTypesState();
359 for (DataTypeController::TypeMap::const_iterator it = 359 for (DataTypeController::TypeMap::const_iterator it =
360 data_type_controllers.begin(); 360 data_type_controllers.begin();
361 it != data_type_controllers.end(); ++it) { 361 it != data_type_controllers.end(); ++it) {
362 syncable::ModelType type = it->first; 362 syncable::ModelType type = it->first;
363 // If a type is not specified, remove it from the routing_info. 363 // If a type is not specified, remove it from the routing_info.
364 if (types.count(type) == 0) { 364 if (types.count(type) == 0) {
365 state->deleted_type = true;
366 routing_info->erase(type); 365 routing_info->erase(type);
367 } else { 366 } else {
368 // Add a newly specified data type as GROUP_PASSIVE into the 367 // Add a newly specified data type as GROUP_PASSIVE into the
369 // routing_info, if it does not already exist. 368 // routing_info, if it does not already exist.
370 if (routing_info->count(type) == 0) { 369 if (routing_info->count(type) == 0) {
371 (*routing_info)[type] = GROUP_PASSIVE; 370 (*routing_info)[type] = GROUP_PASSIVE;
372 state->added_types.set(type); 371 state->added_types.set(type);
373 } 372 }
374 } 373 }
375 } 374 }
376 375
377 // We must handle NIGORI separately as it has no DataTypeController. 376 // We must handle NIGORI separately as it has no DataTypeController.
378 if (types.count(syncable::NIGORI) == 0) { 377 if (types.count(syncable::NIGORI) == 0) {
379 if (nigori_enabled) { // Nigori is currently enabled. 378 if (nigori_enabled) { // Nigori is currently enabled.
380 state->deleted_type = true;
381 routing_info->erase(syncable::NIGORI); 379 routing_info->erase(syncable::NIGORI);
382 // IsNigoriEnabled is now false. 380 // IsNigoriEnabled is now false.
383 } 381 }
384 } else { // Nigori needs to be enabled. 382 } else { // Nigori needs to be enabled.
385 if (!nigori_enabled) { 383 if (!nigori_enabled) {
386 // Currently it is disabled. So enable it. 384 // Currently it is disabled. So enable it.
387 (*routing_info)[syncable::NIGORI] = GROUP_PASSIVE; 385 (*routing_info)[syncable::NIGORI] = GROUP_PASSIVE;
388 state->added_types.set(syncable::NIGORI); 386 state->added_types.set(syncable::NIGORI);
389 } 387 }
390 } 388 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 // manner (see issue 56416). 441 // manner (see issue 56416).
444 // 442 //
445 // In the case of additions, on the next sync cycle, the syncer should 443 // In the case of additions, on the next sync cycle, the syncer should
446 // notice that the routing info has changed and start the process of 444 // notice that the routing info has changed and start the process of
447 // downloading updates for newly added data types. Once this is 445 // downloading updates for newly added data types. Once this is
448 // complete, the configure_state_.ready_task_ is run via an 446 // complete, the configure_state_.ready_task_ is run via an
449 // OnInitializationComplete notification. 447 // OnInitializationComplete notification.
450 448
451 VLOG(1) << "Syncer in config mode. SBH executing" 449 VLOG(1) << "Syncer in config mode. SBH executing"
452 << "FinishConfigureDataTypesOnFrontendLoop"; 450 << "FinishConfigureDataTypesOnFrontendLoop";
453 if (pending_config_mode_state_->deleted_type) {
454 sync_thread_.message_loop()->PostTask(FROM_HERE,
455 NewRunnableMethod(core_.get(),
456 &SyncBackendHost::Core::DeferNudgeForCleanup));
457 }
458 451
459 if (pending_config_mode_state_->added_types.none() && 452 if (pending_config_mode_state_->added_types.none() &&
460 !core_->sync_manager()->InitialSyncEndedForAllEnabledTypes()) { 453 !core_->sync_manager()->InitialSyncEndedForAllEnabledTypes()) {
461 LOG(WARNING) << "No new types, but initial sync not finished." 454 LOG(WARNING) << "No new types, but initial sync not finished."
462 << "Possible sync db corruption / removal."; 455 << "Possible sync db corruption / removal.";
463 // TODO(tim): Log / UMA / count this somehow? 456 // TODO(tim): Log / UMA / count this somehow?
464 // TODO(tim): If no added types, we could (should?) config only for 457 // TODO(tim): If no added types, we could (should?) config only for
465 // types that are needed... but this is a rare corruption edge case or 458 // types that are needed... but this is a rare corruption edge case or
466 // implies the user mucked around with their syncdb, so for now do all. 459 // implies the user mucked around with their syncdb, so for now do all.
467 pending_config_mode_state_->added_types = 460 pending_config_mode_state_->added_types =
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 void SyncBackendHost::LogUnsyncedItems(int level) const { 688 void SyncBackendHost::LogUnsyncedItems(int level) const {
696 DCHECK(initialized()); 689 DCHECK(initialized());
697 return core_->sync_manager()->LogUnsyncedItems(level); 690 return core_->sync_manager()->LogUnsyncedItems(level);
698 } 691 }
699 692
700 SyncBackendHost::Core::Core(const std::string& name, SyncBackendHost* backend) 693 SyncBackendHost::Core::Core(const std::string& name, SyncBackendHost* backend)
701 : name_(name), 694 : name_(name),
702 host_(backend), 695 host_(backend),
703 sync_manager_observer_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 696 sync_manager_observer_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
704 parent_router_(NULL), 697 parent_router_(NULL),
705 processing_passphrase_(false), 698 processing_passphrase_(false) {}
706 deferred_nudge_for_cleanup_requested_(false) {
707 }
708 699
709 // Helper to construct a user agent string (ASCII) suitable for use by 700 // Helper to construct a user agent string (ASCII) suitable for use by
710 // the syncapi for any HTTP communication. This string is used by the sync 701 // the syncapi for any HTTP communication. This string is used by the sync
711 // backend for classifying client types when calculating statistics. 702 // backend for classifying client types when calculating statistics.
712 std::string MakeUserAgentForSyncApi() { 703 std::string MakeUserAgentForSyncApi() {
713 std::string user_agent; 704 std::string user_agent;
714 user_agent = "Chrome "; 705 user_agent = "Chrome ";
715 #if defined(OS_WIN) 706 #if defined(OS_WIN)
716 user_agent += "WIN "; 707 user_agent += "WIN ";
717 #elif defined(OS_LINUX) 708 #elif defined(OS_LINUX)
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 } 767 }
777 768
778 void SyncBackendHost::Core::DoUpdateEnabledTypes() { 769 void SyncBackendHost::Core::DoUpdateEnabledTypes() {
779 DCHECK(MessageLoop::current() == host_->sync_thread_.message_loop()); 770 DCHECK(MessageLoop::current() == host_->sync_thread_.message_loop());
780 sync_manager_->UpdateEnabledTypes(); 771 sync_manager_->UpdateEnabledTypes();
781 } 772 }
782 773
783 void SyncBackendHost::Core::DoStartSyncing() { 774 void SyncBackendHost::Core::DoStartSyncing() {
784 DCHECK(MessageLoop::current() == host_->sync_thread_.message_loop()); 775 DCHECK(MessageLoop::current() == host_->sync_thread_.message_loop());
785 sync_manager_->StartSyncingNormally(); 776 sync_manager_->StartSyncingNormally();
786 if (deferred_nudge_for_cleanup_requested_)
787 sync_manager_->RequestNudge(FROM_HERE);
788 deferred_nudge_for_cleanup_requested_ = false;
789 } 777 }
790 778
791 void SyncBackendHost::Core::DoSetPassphrase(const std::string& passphrase, 779 void SyncBackendHost::Core::DoSetPassphrase(const std::string& passphrase,
792 bool is_explicit) { 780 bool is_explicit) {
793 DCHECK(MessageLoop::current() == host_->sync_thread_.message_loop()); 781 DCHECK(MessageLoop::current() == host_->sync_thread_.message_loop());
794 sync_manager_->SetPassphrase(passphrase, is_explicit); 782 sync_manager_->SetPassphrase(passphrase, is_explicit);
795 } 783 }
796 784
797 bool SyncBackendHost::Core::processing_passphrase() const { 785 bool SyncBackendHost::Core::processing_passphrase() const {
798 DCHECK(MessageLoop::current() == host_->frontend_loop_); 786 DCHECK(MessageLoop::current() == host_->frontend_loop_);
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
1218 sync_manager_->RemoveObserver(&sync_manager_observer_); 1206 sync_manager_->RemoveObserver(&sync_manager_observer_);
1219 } 1207 }
1220 1208
1221 void SyncBackendHost::Core::DoProcessMessage( 1209 void SyncBackendHost::Core::DoProcessMessage(
1222 const std::string& name, const JsArgList& args, 1210 const std::string& name, const JsArgList& args,
1223 const JsEventHandler* sender) { 1211 const JsEventHandler* sender) {
1224 DCHECK_EQ(MessageLoop::current(), host_->sync_thread_.message_loop()); 1212 DCHECK_EQ(MessageLoop::current(), host_->sync_thread_.message_loop());
1225 sync_manager_->GetJsBackend()->ProcessMessage(name, args, sender); 1213 sync_manager_->GetJsBackend()->ProcessMessage(name, args, sender);
1226 } 1214 }
1227 1215
1228 void SyncBackendHost::Core::DeferNudgeForCleanup() {
1229 DCHECK_EQ(MessageLoop::current(), host_->sync_thread_.message_loop());
1230 deferred_nudge_for_cleanup_requested_ = true;
1231 }
1232
1233 } // namespace browser_sync 1216 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698