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

Side by Side Diff: components/sync/engine_impl/sync_manager_impl.cc

Issue 2494873003: [Sync] Allow sync start without sign-in if the local sync backend is on. (Closed)
Patch Set: Rebased on ToT. Created 4 years, 1 month 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
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 "components/sync/engine_impl/sync_manager_impl.h" 5 #include "components/sync/engine_impl/sync_manager_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 new_routing_info, ready_task, retry_task); 216 new_routing_info, ready_task, retry_task);
217 217
218 scheduler_->Start(SyncScheduler::CONFIGURATION_MODE, base::Time()); 218 scheduler_->Start(SyncScheduler::CONFIGURATION_MODE, base::Time());
219 scheduler_->ScheduleConfiguration(params); 219 scheduler_->ScheduleConfiguration(params);
220 } 220 }
221 221
222 void SyncManagerImpl::Init(InitArgs* args) { 222 void SyncManagerImpl::Init(InitArgs* args) {
223 CHECK(!initialized_); 223 CHECK(!initialized_);
224 DCHECK(thread_checker_.CalledOnValidThread()); 224 DCHECK(thread_checker_.CalledOnValidThread());
225 DCHECK(args->post_factory.get()); 225 DCHECK(args->post_factory.get());
226 DCHECK(!args->credentials.account_id.empty()); 226 if (!args->enable_local_sync_backend) {
227 DCHECK(!args->credentials.sync_token.empty()); 227 DCHECK(!args->credentials.account_id.empty());
228 DCHECK(!args->credentials.scope_set.empty()); 228 DCHECK(!args->credentials.sync_token.empty());
229 DCHECK(!args->credentials.scope_set.empty());
230 }
229 DCHECK(args->cancelation_signal); 231 DCHECK(args->cancelation_signal);
230 DVLOG(1) << "SyncManager starting Init..."; 232 DVLOG(1) << "SyncManager starting Init...";
231 233
232 weak_handle_this_ = MakeWeakHandle(weak_ptr_factory_.GetWeakPtr()); 234 weak_handle_this_ = MakeWeakHandle(weak_ptr_factory_.GetWeakPtr());
233 235
234 change_delegate_ = args->change_delegate; 236 change_delegate_ = args->change_delegate;
235 237
236 AddObserver(&js_sync_manager_observer_); 238 AddObserver(&js_sync_manager_observer_);
237 SetJsEventHandler(args->event_handler); 239 SetJsEventHandler(args->event_handler);
238 240
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 // Build a SyncCycleContext and store the worker in it. 322 // Build a SyncCycleContext and store the worker in it.
321 DVLOG(1) << "Sync is bringing up SyncCycleContext."; 323 DVLOG(1) << "Sync is bringing up SyncCycleContext.";
322 std::vector<SyncEngineEventListener*> listeners; 324 std::vector<SyncEngineEventListener*> listeners;
323 listeners.push_back(&allstatus_); 325 listeners.push_back(&allstatus_);
324 listeners.push_back(this); 326 listeners.push_back(this);
325 cycle_context_ = args->engine_components_factory->BuildContext( 327 cycle_context_ = args->engine_components_factory->BuildContext(
326 connection_manager_.get(), directory(), args->extensions_activity, 328 connection_manager_.get(), directory(), args->extensions_activity,
327 listeners, &debug_info_event_listener_, model_type_registry_.get(), 329 listeners, &debug_info_event_listener_, model_type_registry_.get(),
328 args->invalidator_client_id); 330 args->invalidator_client_id);
329 scheduler_ = args->engine_components_factory->BuildScheduler( 331 scheduler_ = args->engine_components_factory->BuildScheduler(
330 name_, cycle_context_.get(), args->cancelation_signal); 332 name_, cycle_context_.get(), args->cancelation_signal,
333 args->enable_local_sync_backend);
331 334
332 scheduler_->Start(SyncScheduler::CONFIGURATION_MODE, base::Time()); 335 scheduler_->Start(SyncScheduler::CONFIGURATION_MODE, base::Time());
333 336
334 initialized_ = true; 337 initialized_ = true;
335 338
336 net::NetworkChangeNotifier::AddIPAddressObserver(this); 339 if (!args->enable_local_sync_backend) {
337 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); 340 net::NetworkChangeNotifier::AddIPAddressObserver(this);
338 observing_network_connectivity_changes_ = true; 341 net::NetworkChangeNotifier::AddConnectionTypeObserver(this);
342 observing_network_connectivity_changes_ = true;
339 343
340 UpdateCredentials(args->credentials); 344 UpdateCredentials(args->credentials);
345 } else {
346 scheduler_->OnCredentialsUpdated();
347 }
341 348
342 NotifyInitializationSuccess(); 349 NotifyInitializationSuccess();
343 } 350 }
344 351
345 void SyncManagerImpl::NotifyInitializationSuccess() { 352 void SyncManagerImpl::NotifyInitializationSuccess() {
346 for (auto& observer : observers_) { 353 for (auto& observer : observers_) {
347 observer.OnInitializationComplete( 354 observer.OnInitializationComplete(
348 MakeWeakHandle(weak_ptr_factory_.GetWeakPtr()), 355 MakeWeakHandle(weak_ptr_factory_.GetWeakPtr()),
349 MakeWeakHandle(debug_info_event_listener_.GetWeakPtr()), true, 356 MakeWeakHandle(debug_info_event_listener_.GetWeakPtr()), true,
350 InitialSyncEndedTypes()); 357 InitialSyncEndedTypes());
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 } 1021 }
1015 1022
1016 void SyncManagerImpl::OnCookieJarChanged(bool account_mismatch, 1023 void SyncManagerImpl::OnCookieJarChanged(bool account_mismatch,
1017 bool empty_jar) { 1024 bool empty_jar) {
1018 DCHECK(thread_checker_.CalledOnValidThread()); 1025 DCHECK(thread_checker_.CalledOnValidThread());
1019 cycle_context_->set_cookie_jar_mismatch(account_mismatch); 1026 cycle_context_->set_cookie_jar_mismatch(account_mismatch);
1020 cycle_context_->set_cookie_jar_empty(empty_jar); 1027 cycle_context_->set_cookie_jar_empty(empty_jar);
1021 } 1028 }
1022 1029
1023 } // namespace syncer 1030 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698