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

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

Issue 7655055: [Sync] Make BackendMigrator not wait for full sync cycles (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync to head 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 #include <map> 8 #include <map>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 using sessions::SyncSessionSnapshot; 59 using sessions::SyncSessionSnapshot;
60 using sync_api::SyncCredentials; 60 using sync_api::SyncCredentials;
61 61
62 SyncBackendHost::SyncBackendHost(Profile* profile) 62 SyncBackendHost::SyncBackendHost(Profile* profile)
63 : core_(new Core(profile, 63 : core_(new Core(profile,
64 ALLOW_THIS_IN_INITIALIZER_LIST(this))), 64 ALLOW_THIS_IN_INITIALIZER_LIST(this))),
65 initialization_state_(NOT_INITIALIZED), 65 initialization_state_(NOT_INITIALIZED),
66 sync_thread_("Chrome_SyncThread"), 66 sync_thread_("Chrome_SyncThread"),
67 frontend_loop_(MessageLoop::current()), 67 frontend_loop_(MessageLoop::current()),
68 profile_(profile), 68 profile_(profile),
69 name_(profile_->GetDebugName()),
69 sync_notifier_factory_(webkit_glue::GetUserAgent(GURL()), 70 sync_notifier_factory_(webkit_glue::GetUserAgent(GURL()),
70 profile_->GetRequestContext(), 71 profile_->GetRequestContext(),
71 *CommandLine::ForCurrentProcess()), 72 *CommandLine::ForCurrentProcess()),
72 frontend_(NULL), 73 frontend_(NULL),
73 sync_data_folder_path_( 74 sync_data_folder_path_(
74 profile_->GetPath().Append(kSyncDataFolderName)), 75 profile_->GetPath().Append(kSyncDataFolderName)),
75 last_auth_error_(AuthError::None()) { 76 last_auth_error_(AuthError::None()) {
76 } 77 }
77 78
78 SyncBackendHost::SyncBackendHost() 79 SyncBackendHost::SyncBackendHost()
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 (*routing_info)[type] = GROUP_PASSIVE; 314 (*routing_info)[type] = GROUP_PASSIVE;
314 state->added_types.insert(type); 315 state->added_types.insert(type);
315 } 316 }
316 } 317 }
317 318
318 for (syncable::ModelTypeSet::const_iterator it = types_to_remove.begin(); 319 for (syncable::ModelTypeSet::const_iterator it = types_to_remove.begin();
319 it != types_to_remove.end(); ++it) { 320 it != types_to_remove.end(); ++it) {
320 routing_info->erase(*it); 321 routing_info->erase(*it);
321 } 322 }
322 323
324 VLOG(1) << "Adding types " << syncable::ModelTypeSetToString(types_to_add)
325 << " and removing types "
326 << syncable::ModelTypeSetToString(types_to_remove)
327 << " to get new routing info "
328 << ModelSafeRoutingInfoToString(*routing_info);
329
323 state->ready_task = ready_task; 330 state->ready_task = ready_task;
324 state->types_to_add = types_to_add; 331 state->types_to_add = types_to_add;
325 state->reason = reason; 332 state->reason = reason;
326 } 333 }
327 334
328 void SyncBackendHost::ConfigureDataTypes( 335 void SyncBackendHost::ConfigureDataTypes(
329 const syncable::ModelTypeSet& types_to_add, 336 const syncable::ModelTypeSet& types_to_add,
330 const syncable::ModelTypeSet& types_to_remove, 337 const syncable::ModelTypeSet& types_to_remove,
331 sync_api::ConfigureReason reason, 338 sync_api::ConfigureReason reason,
332 base::Callback<void(bool)> ready_task, 339 base::Callback<void(bool)> ready_task,
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 // TODO(tim): If no added types, we could (should?) config only for 409 // TODO(tim): If no added types, we could (should?) config only for
403 // types that are needed... but this is a rare corruption edge case or 410 // types that are needed... but this is a rare corruption edge case or
404 // implies the user mucked around with their syncdb, so for now do all. 411 // implies the user mucked around with their syncdb, so for now do all.
405 pending_config_mode_state_->added_types = 412 pending_config_mode_state_->added_types =
406 pending_config_mode_state_->types_to_add; 413 pending_config_mode_state_->types_to_add;
407 } 414 }
408 415
409 // If we've added types, we always want to request a nudge/config (even if 416 // If we've added types, we always want to request a nudge/config (even if
410 // the initial sync is ended), in case we could not decrypt the data. 417 // the initial sync is ended), in case we could not decrypt the data.
411 if (pending_config_mode_state_->added_types.empty()) { 418 if (pending_config_mode_state_->added_types.empty()) {
412 VLOG(1) << "SyncBackendHost(" << this << "): No new types added. " 419 VLOG(1) << name_ << ": No new types added; calling ready_task directly";
413 << "Calling ready_task directly";
414 // No new types - just notify the caller that the types are available. 420 // No new types - just notify the caller that the types are available.
415 pending_config_mode_state_->ready_task.Run(true); 421 pending_config_mode_state_->ready_task.Run(true);
416 } else { 422 } else {
417 pending_download_state_.reset(pending_config_mode_state_.release()); 423 pending_download_state_.reset(pending_config_mode_state_.release());
418 424
419 // Always configure nigori if it's enabled. 425 // Always configure nigori if it's enabled.
420 syncable::ModelTypeSet types_to_config = 426 syncable::ModelTypeSet types_to_config =
421 pending_download_state_->added_types; 427 pending_download_state_->added_types;
422 if (IsNigoriEnabled()) { 428 if (IsNigoriEnabled()) {
423 types_to_config.insert(syncable::NIGORI); 429 types_to_config.insert(syncable::NIGORI);
424 } 430 }
425 VLOG(1) << "SyncBackendHost(" << this << "):New Types added. " 431 VLOG(1) << name_ << ": types " << ModelTypeSetToString(types_to_config)
426 << "Calling DoRequestConfig"; 432 << "added; calling DoRequestConfig";
427 sync_thread_.message_loop()->PostTask(FROM_HERE, 433 sync_thread_.message_loop()->PostTask(FROM_HERE,
428 NewRunnableMethod(core_.get(), 434 NewRunnableMethod(core_.get(),
429 &SyncBackendHost::Core::DoRequestConfig, 435 &SyncBackendHost::Core::DoRequestConfig,
430 syncable::ModelTypeBitSetFromSet(types_to_config), 436 syncable::ModelTypeBitSetFromSet(types_to_config),
431 pending_download_state_->reason)); 437 pending_download_state_->reason));
432 } 438 }
433 439
434 pending_config_mode_state_.reset(); 440 pending_config_mode_state_.reset();
435 441
436 // Notify the SyncManager about the new types. 442 // Notify the SyncManager about the new types.
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 875
870 // If we are waiting for a configuration change, check here to see 876 // If we are waiting for a configuration change, check here to see
871 // if this sync cycle has initialized all of the types we've been 877 // if this sync cycle has initialized all of the types we've been
872 // waiting for. 878 // waiting for.
873 if (host_->pending_download_state_.get()) { 879 if (host_->pending_download_state_.get()) {
874 scoped_ptr<PendingConfigureDataTypesState> state( 880 scoped_ptr<PendingConfigureDataTypesState> state(
875 host_->pending_download_state_.release()); 881 host_->pending_download_state_.release());
876 DCHECK( 882 DCHECK(
877 std::includes(state->types_to_add.begin(), state->types_to_add.end(), 883 std::includes(state->types_to_add.begin(), state->types_to_add.end(),
878 state->added_types.begin(), state->added_types.end())); 884 state->added_types.begin(), state->added_types.end()));
885 VLOG(1)
886 << "Added types: "
887 << syncable::ModelTypeSetToString(state->added_types)
888 << ", configured types: "
889 << syncable::ModelTypeBitSetToString(snapshot->initial_sync_ended);
879 syncable::ModelTypeBitSet added_types = 890 syncable::ModelTypeBitSet added_types =
880 syncable::ModelTypeBitSetFromSet(state->added_types); 891 syncable::ModelTypeBitSetFromSet(state->added_types);
881 bool found_all_added = 892 bool found_all_added =
882 (added_types & snapshot->initial_sync_ended) == added_types; 893 (added_types & snapshot->initial_sync_ended) == added_types;
883 state->ready_task.Run(found_all_added); 894 state->ready_task.Run(found_all_added);
884 if (!found_all_added) 895 if (!found_all_added)
885 return; 896 return;
886 } 897 }
887 898
888 if (host_->initialized()) 899 if (host_->initialized())
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 } 1072 }
1062 1073
1063 void SyncBackendHost::Core::DeleteSyncDataFolder() { 1074 void SyncBackendHost::Core::DeleteSyncDataFolder() {
1064 if (file_util::DirectoryExists(host_->sync_data_folder_path())) { 1075 if (file_util::DirectoryExists(host_->sync_data_folder_path())) {
1065 if (!file_util::Delete(host_->sync_data_folder_path(), true)) 1076 if (!file_util::Delete(host_->sync_data_folder_path(), true))
1066 LOG(DFATAL) << "Could not delete the Sync Data folder."; 1077 LOG(DFATAL) << "Could not delete the Sync Data folder.";
1067 } 1078 }
1068 } 1079 }
1069 1080
1070 } // namespace browser_sync 1081 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698