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

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

Issue 10829086: Reland 148792 (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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 void SyncManagerImpl::ConfigureSyncer( 331 void SyncManagerImpl::ConfigureSyncer(
332 ConfigureReason reason, 332 ConfigureReason reason,
333 const ModelTypeSet& types_to_config, 333 const ModelTypeSet& types_to_config,
334 const ModelSafeRoutingInfo& new_routing_info, 334 const ModelSafeRoutingInfo& new_routing_info,
335 const base::Closure& ready_task, 335 const base::Closure& ready_task,
336 const base::Closure& retry_task) { 336 const base::Closure& retry_task) {
337 DCHECK(thread_checker_.CalledOnValidThread()); 337 DCHECK(thread_checker_.CalledOnValidThread());
338 DCHECK(!ready_task.is_null()); 338 DCHECK(!ready_task.is_null());
339 DCHECK(!retry_task.is_null()); 339 DCHECK(!retry_task.is_null());
340 340
341 // Cleanup any types that might have just been disabled.
342 ModelTypeSet previous_types = ModelTypeSet::All();
343 if (!session_context_->routing_info().empty())
344 previous_types = GetRoutingInfoTypes(session_context_->routing_info());
345 if (!PurgeDisabledTypes(previous_types,
346 GetRoutingInfoTypes(new_routing_info))) {
347 // We failed to cleanup the types. Invoke the ready task without actually
348 // configuring any types. The caller should detect this as a configuration
349 // failure and act appropriately.
350 ready_task.Run();
351 return;
352 }
353
341 // TODO(zea): set this based on whether cryptographer has keystore 354 // TODO(zea): set this based on whether cryptographer has keystore
342 // encryption key or not (requires opening a transaction). crbug.com/129665. 355 // encryption key or not (requires opening a transaction). crbug.com/129665.
343 ConfigurationParams::KeystoreKeyStatus keystore_key_status = 356 ConfigurationParams::KeystoreKeyStatus keystore_key_status =
344 ConfigurationParams::KEYSTORE_KEY_UNNECESSARY; 357 ConfigurationParams::KEYSTORE_KEY_UNNECESSARY;
345 358
346 ConfigurationParams params(GetSourceFromReason(reason), 359 ConfigurationParams params(GetSourceFromReason(reason),
347 types_to_config, 360 types_to_config,
348 new_routing_info, 361 new_routing_info,
349 keystore_key_status, 362 keystore_key_status,
350 ready_task); 363 ready_task);
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 partially_synced_types.RemoveAll(GetTypesWithEmptyProgressMarkerToken( 695 partially_synced_types.RemoveAll(GetTypesWithEmptyProgressMarkerToken(
683 ModelTypeSet::All())); 696 ModelTypeSet::All()));
684 697
685 UMA_HISTOGRAM_COUNTS("Sync.PartiallySyncedTypes", 698 UMA_HISTOGRAM_COUNTS("Sync.PartiallySyncedTypes",
686 partially_synced_types.Size()); 699 partially_synced_types.Size());
687 if (partially_synced_types.Empty()) 700 if (partially_synced_types.Empty())
688 return true; 701 return true;
689 return directory()->PurgeEntriesWithTypeIn(partially_synced_types); 702 return directory()->PurgeEntriesWithTypeIn(partially_synced_types);
690 } 703 }
691 704
705 bool SyncManagerImpl::PurgeDisabledTypes(
706 ModelTypeSet previously_enabled_types,
707 ModelTypeSet currently_enabled_types) {
708 ModelTypeSet disabled_types = Difference(previously_enabled_types,
709 currently_enabled_types);
710 if (disabled_types.Empty())
711 return true;
712
713 DVLOG(1) << "Purging disabled types "
714 << ModelTypeSetToString(disabled_types);
715 return directory()->PurgeEntriesWithTypeIn(disabled_types);
716 }
717
692 void SyncManagerImpl::UpdateCredentials( 718 void SyncManagerImpl::UpdateCredentials(
693 const SyncCredentials& credentials) { 719 const SyncCredentials& credentials) {
694 DCHECK(thread_checker_.CalledOnValidThread()); 720 DCHECK(thread_checker_.CalledOnValidThread());
695 DCHECK(initialized_); 721 DCHECK(initialized_);
696 DCHECK_EQ(credentials.email, share_.name); 722 DCHECK_EQ(credentials.email, share_.name);
697 DCHECK(!credentials.email.empty()); 723 DCHECK(!credentials.email.empty());
698 DCHECK(!credentials.sync_token.empty()); 724 DCHECK(!credentials.sync_token.empty());
699 725
700 observing_ip_address_changes_ = true; 726 observing_ip_address_changes_ = true;
701 if (!connection_manager_->set_auth_token(credentials.sync_token)) 727 if (!connection_manager_->set_auth_token(credentials.sync_token))
(...skipping 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1847 int SyncManagerImpl::GetDefaultNudgeDelay() { 1873 int SyncManagerImpl::GetDefaultNudgeDelay() {
1848 return kDefaultNudgeDelayMilliseconds; 1874 return kDefaultNudgeDelayMilliseconds;
1849 } 1875 }
1850 1876
1851 // static. 1877 // static.
1852 int SyncManagerImpl::GetPreferencesNudgeDelay() { 1878 int SyncManagerImpl::GetPreferencesNudgeDelay() {
1853 return kPreferencesNudgeDelayMilliseconds; 1879 return kPreferencesNudgeDelayMilliseconds;
1854 } 1880 }
1855 1881
1856 } // namespace syncer 1882 } // 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