| OLD | NEW |
| 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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 new_routing_info, ready_task, retry_task); | 220 new_routing_info, ready_task, retry_task); |
| 221 | 221 |
| 222 scheduler_->Start(SyncScheduler::CONFIGURATION_MODE, base::Time()); | 222 scheduler_->Start(SyncScheduler::CONFIGURATION_MODE, base::Time()); |
| 223 scheduler_->ScheduleConfiguration(params); | 223 scheduler_->ScheduleConfiguration(params); |
| 224 } | 224 } |
| 225 | 225 |
| 226 void SyncManagerImpl::Init(InitArgs* args) { | 226 void SyncManagerImpl::Init(InitArgs* args) { |
| 227 CHECK(!initialized_); | 227 CHECK(!initialized_); |
| 228 DCHECK(thread_checker_.CalledOnValidThread()); | 228 DCHECK(thread_checker_.CalledOnValidThread()); |
| 229 DCHECK(args->post_factory.get()); | 229 DCHECK(args->post_factory.get()); |
| 230 DCHECK(!args->credentials.account_id.empty()); | 230 if (!args->enable_local_sync_backend) { |
| 231 DCHECK(!args->credentials.sync_token.empty()); | 231 DCHECK(!args->credentials.account_id.empty()); |
| 232 DCHECK(!args->credentials.scope_set.empty()); | 232 DCHECK(!args->credentials.sync_token.empty()); |
| 233 DCHECK(!args->credentials.scope_set.empty()); |
| 234 } |
| 233 DCHECK(args->cancelation_signal); | 235 DCHECK(args->cancelation_signal); |
| 234 DVLOG(1) << "SyncManager starting Init..."; | 236 DVLOG(1) << "SyncManager starting Init..."; |
| 235 | 237 |
| 236 weak_handle_this_ = MakeWeakHandle(weak_ptr_factory_.GetWeakPtr()); | 238 weak_handle_this_ = MakeWeakHandle(weak_ptr_factory_.GetWeakPtr()); |
| 237 | 239 |
| 238 change_delegate_ = args->change_delegate; | 240 change_delegate_ = args->change_delegate; |
| 239 | 241 |
| 240 AddObserver(&js_sync_manager_observer_); | 242 AddObserver(&js_sync_manager_observer_); |
| 241 SetJsEventHandler(args->event_handler); | 243 SetJsEventHandler(args->event_handler); |
| 242 | 244 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 // Build a SyncCycleContext and store the worker in it. | 326 // Build a SyncCycleContext and store the worker in it. |
| 325 DVLOG(1) << "Sync is bringing up SyncCycleContext."; | 327 DVLOG(1) << "Sync is bringing up SyncCycleContext."; |
| 326 std::vector<SyncEngineEventListener*> listeners; | 328 std::vector<SyncEngineEventListener*> listeners; |
| 327 listeners.push_back(&allstatus_); | 329 listeners.push_back(&allstatus_); |
| 328 listeners.push_back(this); | 330 listeners.push_back(this); |
| 329 cycle_context_ = args->engine_components_factory->BuildContext( | 331 cycle_context_ = args->engine_components_factory->BuildContext( |
| 330 connection_manager_.get(), directory(), args->extensions_activity, | 332 connection_manager_.get(), directory(), args->extensions_activity, |
| 331 listeners, &debug_info_event_listener_, model_type_registry_.get(), | 333 listeners, &debug_info_event_listener_, model_type_registry_.get(), |
| 332 args->invalidator_client_id); | 334 args->invalidator_client_id); |
| 333 scheduler_ = args->engine_components_factory->BuildScheduler( | 335 scheduler_ = args->engine_components_factory->BuildScheduler( |
| 334 name_, cycle_context_.get(), args->cancelation_signal); | 336 name_, cycle_context_.get(), args->cancelation_signal, |
| 337 args->enable_local_sync_backend); |
| 335 | 338 |
| 336 scheduler_->Start(SyncScheduler::CONFIGURATION_MODE, base::Time()); | 339 scheduler_->Start(SyncScheduler::CONFIGURATION_MODE, base::Time()); |
| 337 | 340 |
| 338 initialized_ = true; | 341 initialized_ = true; |
| 339 | 342 |
| 340 net::NetworkChangeNotifier::AddIPAddressObserver(this); | 343 if (!args->enable_local_sync_backend) { |
| 341 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); | 344 net::NetworkChangeNotifier::AddIPAddressObserver(this); |
| 342 observing_network_connectivity_changes_ = true; | 345 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); |
| 346 observing_network_connectivity_changes_ = true; |
| 343 | 347 |
| 344 UpdateCredentials(args->credentials); | 348 UpdateCredentials(args->credentials); |
| 349 } else { |
| 350 scheduler_->OnCredentialsUpdated(); |
| 351 } |
| 345 | 352 |
| 346 NotifyInitializationSuccess(); | 353 NotifyInitializationSuccess(); |
| 347 } | 354 } |
| 348 | 355 |
| 349 void SyncManagerImpl::NotifyInitializationSuccess() { | 356 void SyncManagerImpl::NotifyInitializationSuccess() { |
| 350 for (auto& observer : observers_) { | 357 for (auto& observer : observers_) { |
| 351 observer.OnInitializationComplete( | 358 observer.OnInitializationComplete( |
| 352 MakeWeakHandle(weak_ptr_factory_.GetWeakPtr()), | 359 MakeWeakHandle(weak_ptr_factory_.GetWeakPtr()), |
| 353 MakeWeakHandle(debug_info_event_listener_.GetWeakPtr()), true, | 360 MakeWeakHandle(debug_info_event_listener_.GetWeakPtr()), true, |
| 354 InitialSyncEndedTypes()); | 361 InitialSyncEndedTypes()); |
| (...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1022 DCHECK(thread_checker_.CalledOnValidThread()); | 1029 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1023 cycle_context_->set_cookie_jar_mismatch(account_mismatch); | 1030 cycle_context_->set_cookie_jar_mismatch(account_mismatch); |
| 1024 cycle_context_->set_cookie_jar_empty(empty_jar); | 1031 cycle_context_->set_cookie_jar_empty(empty_jar); |
| 1025 } | 1032 } |
| 1026 | 1033 |
| 1027 void SyncManagerImpl::OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd) { | 1034 void SyncManagerImpl::OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd) { |
| 1028 directory()->OnMemoryDump(pmd); | 1035 directory()->OnMemoryDump(pmd); |
| 1029 } | 1036 } |
| 1030 | 1037 |
| 1031 } // namespace syncer | 1038 } // namespace syncer |
| OLD | NEW |