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

Unified Diff: sync/internal_api/sync_manager_impl.cc

Issue 10804039: Make SyncBackendRegistrar aware of loaded data (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Inline SignIn and UpdateCredentials Created 8 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/internal_api/sync_manager_impl.cc
diff --git a/sync/internal_api/sync_manager_impl.cc b/sync/internal_api/sync_manager_impl.cc
index 6a164d8f0ff2aac4ff56893cfc13914c323e1737..a170d01861925ef78a30e44df29e2d11cba95e3a 100644
--- a/sync/internal_api/sync_manager_impl.cc
+++ b/sync/internal_api/sync_manager_impl.cc
@@ -369,7 +369,6 @@ bool SyncManagerImpl::Init(
bool use_ssl,
const scoped_refptr<base::TaskRunner>& blocking_task_runner,
scoped_ptr<HttpPostProviderFactory> post_factory,
- const ModelSafeRoutingInfo& model_safe_routing_info,
const std::vector<ModelSafeWorker*>& workers,
ExtensionsActivityMonitor* extensions_activity_monitor,
SyncManager::ChangeDelegate* change_delegate,
@@ -383,6 +382,8 @@ bool SyncManagerImpl::Init(
CHECK(!initialized_);
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(post_factory.get());
+ DCHECK(!credentials.email.empty());
+ DCHECK(!credentials.sync_token.empty());
DVLOG(1) << "SyncManager starting Init...";
weak_handle_this_ = MakeWeakHandle(weak_ptr_factory_.GetWeakPtr());
@@ -411,6 +412,7 @@ bool SyncManagerImpl::Init(
credentials.email, absolute_db_path).Pass();
DCHECK(backing_store.get());
+ share_.name = credentials.email;
rlarocque 2012/07/25 18:45:08 Formerly part of SignIn()
share_.directory.reset(
new syncable::Directory(encryptor_,
unrecoverable_error_handler_,
@@ -425,28 +427,48 @@ bool SyncManagerImpl::Init(
connection_manager_->AddListener(this);
- // Build a SyncSessionContext and store the worker in it.
- DVLOG(1) << "Sync is bringing up SyncSessionContext.";
- std::vector<SyncEngineEventListener*> listeners;
- listeners.push_back(&allstatus_);
- listeners.push_back(this);
- session_context_ = internal_components_factory->BuildContext(
- connection_manager_.get(),
- directory(),
- model_safe_routing_info,
- workers,
- extensions_activity_monitor,
- &throttled_data_type_tracker_,
- listeners,
- &debug_info_event_listener_,
- &traffic_recorder_).Pass();
- session_context_->set_account_name(credentials.email);
- scheduler_ = internal_components_factory->BuildScheduler(
- name_, session_context_.get()).Pass();
-
- bool success = SignIn(credentials);
-
+ DVLOG(1) << "Username: " << username_for_share();
rlarocque 2012/07/25 18:45:08 Inlined SignIn code begins here.
+ bool success = OpenDirectory();
if (success) {
tim (not reviewing) 2012/07/26 18:48:05 I know this code did if (success) { before, but no
rlarocque 2012/07/26 21:59:54 Good idea.
+ // Retrieve and set the sync notifier state.
+ std::string unique_id = directory()->cache_guid();
+ DVLOG(1) << "Read notification unique ID: " << unique_id;
+ allstatus_.SetUniqueId(unique_id);
+ sync_notifier_->SetUniqueId(unique_id);
+
+ std::string state = directory()->GetNotificationState();
+ if (VLOG_IS_ON(1)) {
+ std::string encoded_state;
+ base::Base64Encode(state, &encoded_state);
+ DVLOG(1) << "Read notification state: " << encoded_state;
+ }
+
+ // TODO(tim): Remove once invalidation state has been migrated to new
+ // InvalidationStateTracker store. Bug 124140.
+ sync_notifier_->SetStateDeprecated(state);
+
+ connection_manager_->set_auth_token(credentials.sync_token);
rlarocque 2012/07/25 18:45:08 These two lines are effectively what UpdateCredent
tim (not reviewing) 2012/07/26 18:48:05 What is the benefit of not calling UpdateCredentia
rlarocque 2012/07/26 21:59:54 It's debatable. The arguments for are: - UpdateCr
+ sync_notifier_->UpdateCredentials(credentials.email,
rlarocque 2012/07/25 18:45:08 I think it's safe to initialize the sync_notifier
tim (not reviewing) 2012/07/26 18:48:05 I think this is okay too - the call to AddObserver
+ credentials.sync_token);
+
+ // Build a SyncSessionContext and store the worker in it.
+ DVLOG(1) << "Sync is bringing up SyncSessionContext.";
+ std::vector<SyncEngineEventListener*> listeners;
+ listeners.push_back(&allstatus_);
+ listeners.push_back(this);
+ session_context_ = internal_components_factory->BuildContext(
rlarocque 2012/07/25 18:45:08 Warning: Real code change here. We used to create
tim (not reviewing) 2012/07/26 18:48:05 Agreed, it would be strange if we were relying on
+ connection_manager_.get(),
+ directory(),
+ workers,
+ extensions_activity_monitor,
+ &throttled_data_type_tracker_,
+ listeners,
+ &debug_info_event_listener_,
+ &traffic_recorder_).Pass();
+ session_context_->set_account_name(credentials.email);
+ scheduler_ = internal_components_factory->BuildScheduler(
+ name_, session_context_.get()).Pass();
+
scheduler_->Start(SyncScheduler::CONFIGURATION_MODE);
initialized_ = true;
@@ -482,7 +504,8 @@ bool SyncManagerImpl::Init(
FOR_EACH_OBSERVER(SyncManager::Observer, observers_,
OnInitializationComplete(
MakeWeakHandle(weak_ptr_factory_.GetWeakPtr()),
- success));
+ success, success ? InitialSyncEndedTypes()
+ : syncer::ModelTypeSet()));
if (!success)
return false;
@@ -668,35 +691,6 @@ bool SyncManagerImpl::OpenDirectory() {
return true;
}
-bool SyncManagerImpl::SignIn(const SyncCredentials& credentials) {
- DCHECK(thread_checker_.CalledOnValidThread());
- DCHECK(share_.name.empty());
- share_.name = credentials.email;
-
- DVLOG(1) << "Signing in user: " << username_for_share();
- if (!OpenDirectory())
- return false;
-
- // Retrieve and set the sync notifier state. This should be done
- // only after OpenDirectory is called.
- std::string unique_id = directory()->cache_guid();
- std::string state = directory()->GetNotificationState();
- DVLOG(1) << "Read notification unique ID: " << unique_id;
- if (VLOG_IS_ON(1)) {
- std::string encoded_state;
- base::Base64Encode(state, &encoded_state);
- DVLOG(1) << "Read notification state: " << encoded_state;
- }
- allstatus_.SetUniqueId(unique_id);
- sync_notifier_->SetUniqueId(unique_id);
- // TODO(tim): Remove once invalidation state has been migrated to new
- // InvalidationStateTracker store. Bug 124140.
- sync_notifier_->SetStateDeprecated(state);
-
- UpdateCredentials(credentials);
- return true;
-}
-
bool SyncManagerImpl::PurgePartiallySyncedTypes() {
ModelTypeSet partially_synced_types = ModelTypeSet::All();
partially_synced_types.RemoveAll(InitialSyncEndedTypes());
« 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