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

Side by Side Diff: sync/internal_api/sync_manager_impl.cc

Issue 10823061: Revert 148792 - [Sync] Remove CleanupDisabledTypes command and move purge logic into SyncManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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
« no previous file with comments | « sync/internal_api/sync_manager_impl.h ('k') | sync/internal_api/syncapi_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "sync/internal_api/sync_manager_impl.h" 5 #include "sync/internal_api/sync_manager_impl.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 void SyncManagerImpl::ConfigureSyncer( 333 void SyncManagerImpl::ConfigureSyncer(
334 ConfigureReason reason, 334 ConfigureReason reason,
335 const ModelTypeSet& types_to_config, 335 const ModelTypeSet& types_to_config,
336 const ModelSafeRoutingInfo& new_routing_info, 336 const ModelSafeRoutingInfo& new_routing_info,
337 const base::Closure& ready_task, 337 const base::Closure& ready_task,
338 const base::Closure& retry_task) { 338 const base::Closure& retry_task) {
339 DCHECK(thread_checker_.CalledOnValidThread()); 339 DCHECK(thread_checker_.CalledOnValidThread());
340 DCHECK(!ready_task.is_null()); 340 DCHECK(!ready_task.is_null());
341 DCHECK(!retry_task.is_null()); 341 DCHECK(!retry_task.is_null());
342 342
343 // Cleanup any types that might have just been disabled.
344 ModelTypeSet previous_types = ModelTypeSet::All();
345 if (!session_context_->routing_info().empty())
346 previous_types = GetRoutingInfoTypes(session_context_->routing_info());
347 if (!PurgeDisabledTypes(previous_types,
348 GetRoutingInfoTypes(new_routing_info))) {
349 // We failed to cleanup the types. Invoke the ready task without actually
350 // configuring any types. The caller should detect this as a configuration
351 // failure and act appropriately.
352 ready_task.Run();
353 return;
354 }
355
356 // TODO(zea): set this based on whether cryptographer has keystore 343 // TODO(zea): set this based on whether cryptographer has keystore
357 // encryption key or not (requires opening a transaction). crbug.com/129665. 344 // encryption key or not (requires opening a transaction). crbug.com/129665.
358 ConfigurationParams::KeystoreKeyStatus keystore_key_status = 345 ConfigurationParams::KeystoreKeyStatus keystore_key_status =
359 ConfigurationParams::KEYSTORE_KEY_UNNECESSARY; 346 ConfigurationParams::KEYSTORE_KEY_UNNECESSARY;
360 347
361 ConfigurationParams params(GetSourceFromReason(reason), 348 ConfigurationParams params(GetSourceFromReason(reason),
362 types_to_config, 349 types_to_config,
363 new_routing_info, 350 new_routing_info,
364 keystore_key_status, 351 keystore_key_status,
365 ready_task); 352 ready_task);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 // re-downloaded during any configuration. But, it's possible for a datatype 451 // re-downloaded during any configuration. But, it's possible for a datatype
465 // to have a progress marker but not have initial sync ended yet, making 452 // to have a progress marker but not have initial sync ended yet, making
466 // it a candidate for migration. This is a problem, as the DataTypeManager 453 // it a candidate for migration. This is a problem, as the DataTypeManager
467 // does not support a migration while it's already in the middle of a 454 // does not support a migration while it's already in the middle of a
468 // configuration. As a result, any partially synced datatype can stall the 455 // configuration. As a result, any partially synced datatype can stall the
469 // DTM, waiting for the configuration to complete, which it never will due 456 // DTM, waiting for the configuration to complete, which it never will due
470 // to the migration error. In addition, a partially synced nigori will 457 // to the migration error. In addition, a partially synced nigori will
471 // trigger the migration logic before the backend is initialized, resulting 458 // trigger the migration logic before the backend is initialized, resulting
472 // in crashes. We therefore detect and purge any partially synced types as 459 // in crashes. We therefore detect and purge any partially synced types as
473 // part of initialization. 460 // part of initialization.
474 // 461 if (!PurgePartiallySyncedTypes())
475 // Similarly, a type may have been disabled previously, but we didn't
476 // manage to purge. Ensure we cleanup any disabled types before starting up.
477 //
478 // Note: If either of these methods fail, we have directory corruption and
479 // cannot continue.
480 // TODO(rlarocque): remove the PurgeDisabledTypes call once we no longer
481 // initialize the session context with the enabled types (purging disabled
482 // types will be done within ConfigureSyncer).
483 if (!PurgePartiallySyncedTypes() ||
484 !PurgeDisabledTypes(
485 ModelTypeSet::All(),
486 GetRoutingInfoTypes(session_context_->routing_info())))
487 success = false; 462 success = false;
488 463
489 // Cryptographer should only be accessed while holding a 464 // Cryptographer should only be accessed while holding a
490 // transaction. Grabbing the user share for the transaction 465 // transaction. Grabbing the user share for the transaction
491 // checks the initialization state, so this must come after 466 // checks the initialization state, so this must come after
492 // |initialized_| is set to true. 467 // |initialized_| is set to true.
493 ReadTransaction trans(FROM_HERE, GetUserShare()); 468 ReadTransaction trans(FROM_HERE, GetUserShare());
494 trans.GetCryptographer()->Bootstrap(restored_key_for_bootstrapping); 469 trans.GetCryptographer()->Bootstrap(restored_key_for_bootstrapping);
495 trans.GetCryptographer()->AddObserver(this); 470 trans.GetCryptographer()->AddObserver(this);
496 } 471 }
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 partially_synced_types.RemoveAll(GetTypesWithEmptyProgressMarkerToken( 697 partially_synced_types.RemoveAll(GetTypesWithEmptyProgressMarkerToken(
723 ModelTypeSet::All())); 698 ModelTypeSet::All()));
724 699
725 UMA_HISTOGRAM_COUNTS("Sync.PartiallySyncedTypes", 700 UMA_HISTOGRAM_COUNTS("Sync.PartiallySyncedTypes",
726 partially_synced_types.Size()); 701 partially_synced_types.Size());
727 if (partially_synced_types.Empty()) 702 if (partially_synced_types.Empty())
728 return true; 703 return true;
729 return directory()->PurgeEntriesWithTypeIn(partially_synced_types); 704 return directory()->PurgeEntriesWithTypeIn(partially_synced_types);
730 } 705 }
731 706
732 bool SyncManagerImpl::PurgeDisabledTypes(
733 ModelTypeSet previously_enabled_types,
734 ModelTypeSet currently_enabled_types) {
735 ModelTypeSet disabled_types = Difference(previously_enabled_types,
736 currently_enabled_types);
737 if (disabled_types.Empty())
738 return true;
739
740 DVLOG(1) << "Purging disabled types "
741 << ModelTypeSetToString(disabled_types);
742 return directory()->PurgeEntriesWithTypeIn(disabled_types);
743 }
744
745 void SyncManagerImpl::UpdateCredentials( 707 void SyncManagerImpl::UpdateCredentials(
746 const SyncCredentials& credentials) { 708 const SyncCredentials& credentials) {
747 DCHECK(thread_checker_.CalledOnValidThread()); 709 DCHECK(thread_checker_.CalledOnValidThread());
748 DCHECK_EQ(credentials.email, share_.name); 710 DCHECK_EQ(credentials.email, share_.name);
749 DCHECK(!credentials.email.empty()); 711 DCHECK(!credentials.email.empty());
750 DCHECK(!credentials.sync_token.empty()); 712 DCHECK(!credentials.sync_token.empty());
751 713
752 observing_ip_address_changes_ = true; 714 observing_ip_address_changes_ = true;
753 if (connection_manager_->set_auth_token(credentials.sync_token)) { 715 if (connection_manager_->set_auth_token(credentials.sync_token)) {
754 sync_notifier_->UpdateCredentials( 716 sync_notifier_->UpdateCredentials(
(...skipping 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1901 int SyncManagerImpl::GetDefaultNudgeDelay() { 1863 int SyncManagerImpl::GetDefaultNudgeDelay() {
1902 return kDefaultNudgeDelayMilliseconds; 1864 return kDefaultNudgeDelayMilliseconds;
1903 } 1865 }
1904 1866
1905 // static. 1867 // static.
1906 int SyncManagerImpl::GetPreferencesNudgeDelay() { 1868 int SyncManagerImpl::GetPreferencesNudgeDelay() {
1907 return kPreferencesNudgeDelayMilliseconds; 1869 return kPreferencesNudgeDelayMilliseconds;
1908 } 1870 }
1909 1871
1910 } // namespace syncer 1872 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/internal_api/sync_manager_impl.h ('k') | sync/internal_api/syncapi_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698