| 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 12 matching lines...) Expand all Loading... |
| 23 #include "components/sync/base/cancelation_signal.h" | 23 #include "components/sync/base/cancelation_signal.h" |
| 24 #include "components/sync/base/experiments.h" | 24 #include "components/sync/base/experiments.h" |
| 25 #include "components/sync/base/invalidation_interface.h" | 25 #include "components/sync/base/invalidation_interface.h" |
| 26 #include "components/sync/base/model_type.h" | 26 #include "components/sync/base/model_type.h" |
| 27 #include "components/sync/engine/configure_reason.h" | 27 #include "components/sync/engine/configure_reason.h" |
| 28 #include "components/sync/engine/engine_components_factory.h" | 28 #include "components/sync/engine/engine_components_factory.h" |
| 29 #include "components/sync/engine/engine_util.h" | 29 #include "components/sync/engine/engine_util.h" |
| 30 #include "components/sync/engine/net/http_post_provider_factory.h" | 30 #include "components/sync/engine/net/http_post_provider_factory.h" |
| 31 #include "components/sync/engine/polling_constants.h" | 31 #include "components/sync/engine/polling_constants.h" |
| 32 #include "components/sync/engine_impl/cycle/directory_type_debug_info_emitter.h" | 32 #include "components/sync/engine_impl/cycle/directory_type_debug_info_emitter.h" |
| 33 #include "components/sync/engine_impl/loopback_server/loopback_connection_manage
r.h" |
| 33 #include "components/sync/engine_impl/model_type_connector_proxy.h" | 34 #include "components/sync/engine_impl/model_type_connector_proxy.h" |
| 34 #include "components/sync/engine_impl/net/sync_server_connection_manager.h" | 35 #include "components/sync/engine_impl/net/sync_server_connection_manager.h" |
| 35 #include "components/sync/engine_impl/sync_scheduler.h" | 36 #include "components/sync/engine_impl/sync_scheduler.h" |
| 36 #include "components/sync/engine_impl/syncer_types.h" | 37 #include "components/sync/engine_impl/syncer_types.h" |
| 37 #include "components/sync/engine_impl/uss_migrator.h" | 38 #include "components/sync/engine_impl/uss_migrator.h" |
| 38 #include "components/sync/protocol/proto_value_conversions.h" | 39 #include "components/sync/protocol/proto_value_conversions.h" |
| 39 #include "components/sync/protocol/sync.pb.h" | 40 #include "components/sync/protocol/sync.pb.h" |
| 40 #include "components/sync/syncable/base_node.h" | 41 #include "components/sync/syncable/base_node.h" |
| 41 #include "components/sync/syncable/directory.h" | 42 #include "components/sync/syncable/directory.h" |
| 42 #include "components/sync/syncable/entry.h" | 43 #include "components/sync/syncable/entry.h" |
| 43 #include "components/sync/syncable/in_memory_directory_backing_store.h" | 44 #include "components/sync/syncable/in_memory_directory_backing_store.h" |
| 44 #include "components/sync/syncable/on_disk_directory_backing_store.h" | 45 #include "components/sync/syncable/on_disk_directory_backing_store.h" |
| 45 #include "components/sync/syncable/read_node.h" | 46 #include "components/sync/syncable/read_node.h" |
| 46 #include "components/sync/syncable/read_transaction.h" | 47 #include "components/sync/syncable/read_transaction.h" |
| 47 #include "components/sync/syncable/write_node.h" | 48 #include "components/sync/syncable/write_node.h" |
| 48 #include "components/sync/syncable/write_transaction.h" | 49 #include "components/sync/syncable/write_transaction.h" |
| 49 | 50 |
| 50 #if defined(OS_WIN) | |
| 51 #include "components/sync/engine_impl/loopback_server/loopback_connection_manage
r.h" | |
| 52 #endif | |
| 53 | 51 |
| 54 using base::TimeDelta; | 52 using base::TimeDelta; |
| 55 using sync_pb::GetUpdatesCallerInfo; | 53 using sync_pb::GetUpdatesCallerInfo; |
| 56 | 54 |
| 57 class GURL; | 55 class GURL; |
| 58 | 56 |
| 59 namespace syncer { | 57 namespace syncer { |
| 60 | 58 |
| 61 using syncable::ImmutableWriteTransactionInfo; | 59 using syncable::ImmutableWriteTransactionInfo; |
| 62 using syncable::SPECIFICS; | 60 using syncable::SPECIFICS; |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 new_routing_info, ready_task, retry_task); | 203 new_routing_info, ready_task, retry_task); |
| 206 | 204 |
| 207 scheduler_->Start(SyncScheduler::CONFIGURATION_MODE, base::Time()); | 205 scheduler_->Start(SyncScheduler::CONFIGURATION_MODE, base::Time()); |
| 208 scheduler_->ScheduleConfiguration(params); | 206 scheduler_->ScheduleConfiguration(params); |
| 209 } | 207 } |
| 210 | 208 |
| 211 void SyncManagerImpl::Init(InitArgs* args) { | 209 void SyncManagerImpl::Init(InitArgs* args) { |
| 212 CHECK(!initialized_); | 210 CHECK(!initialized_); |
| 213 DCHECK(thread_checker_.CalledOnValidThread()); | 211 DCHECK(thread_checker_.CalledOnValidThread()); |
| 214 DCHECK(args->post_factory.get()); | 212 DCHECK(args->post_factory.get()); |
| 215 DCHECK(!args->credentials.account_id.empty()); | 213 if (!args->enable_local_sync_backend) { |
| 216 DCHECK(!args->credentials.sync_token.empty()); | 214 DCHECK(!args->credentials.account_id.empty()); |
| 217 DCHECK(!args->credentials.scope_set.empty()); | 215 DCHECK(!args->credentials.sync_token.empty()); |
| 216 DCHECK(!args->credentials.scope_set.empty()); |
| 217 } |
| 218 DCHECK(args->cancelation_signal); | 218 DCHECK(args->cancelation_signal); |
| 219 DVLOG(1) << "SyncManager starting Init..."; | 219 DVLOG(1) << "SyncManager starting Init..."; |
| 220 | 220 |
| 221 weak_handle_this_ = MakeWeakHandle(weak_ptr_factory_.GetWeakPtr()); | 221 weak_handle_this_ = MakeWeakHandle(weak_ptr_factory_.GetWeakPtr()); |
| 222 | 222 |
| 223 change_delegate_ = args->change_delegate; | 223 change_delegate_ = args->change_delegate; |
| 224 | 224 |
| 225 AddObserver(&js_sync_manager_observer_); | 225 AddObserver(&js_sync_manager_observer_); |
| 226 SetJsEventHandler(args->event_handler); | 226 SetJsEventHandler(args->event_handler); |
| 227 | 227 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 } | 269 } |
| 270 | 270 |
| 271 // Now that we have opened the Directory we can restore any previously saved | 271 // Now that we have opened the Directory we can restore any previously saved |
| 272 // nigori specifics. | 272 // nigori specifics. |
| 273 if (args->saved_nigori_state) { | 273 if (args->saved_nigori_state) { |
| 274 sync_encryption_handler_->RestoreNigori(*args->saved_nigori_state); | 274 sync_encryption_handler_->RestoreNigori(*args->saved_nigori_state); |
| 275 args->saved_nigori_state.reset(); | 275 args->saved_nigori_state.reset(); |
| 276 } | 276 } |
| 277 | 277 |
| 278 if (args->enable_local_sync_backend) { | 278 if (args->enable_local_sync_backend) { |
| 279 #if defined(OS_WIN) | |
| 280 VLOG(1) << "Running against local sync backend."; | 279 VLOG(1) << "Running against local sync backend."; |
| 281 connection_manager_ = base::MakeUnique<LoopbackConnectionManager>( | 280 connection_manager_ = base::MakeUnique<LoopbackConnectionManager>( |
| 282 args->cancelation_signal, args->local_sync_backend_folder); | 281 args->cancelation_signal, args->local_sync_backend_folder); |
| 283 #else | |
| 284 NOTREACHED(); | |
| 285 #endif // defined(OS_WIN) | |
| 286 } else { | 282 } else { |
| 287 connection_manager_ = base::MakeUnique<SyncServerConnectionManager>( | 283 connection_manager_ = base::MakeUnique<SyncServerConnectionManager>( |
| 288 args->service_url.host() + args->service_url.path(), | 284 args->service_url.host() + args->service_url.path(), |
| 289 args->service_url.EffectiveIntPort(), | 285 args->service_url.EffectiveIntPort(), |
| 290 args->service_url.SchemeIsCryptographic(), args->post_factory.release(), | 286 args->service_url.SchemeIsCryptographic(), args->post_factory.release(), |
| 291 args->cancelation_signal); | 287 args->cancelation_signal); |
| 292 } | 288 } |
| 293 connection_manager_->set_client_id(directory()->cache_guid()); | 289 connection_manager_->set_client_id(directory()->cache_guid()); |
| 294 connection_manager_->AddListener(this); | 290 connection_manager_->AddListener(this); |
| 295 | 291 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 309 // Build a SyncCycleContext and store the worker in it. | 305 // Build a SyncCycleContext and store the worker in it. |
| 310 DVLOG(1) << "Sync is bringing up SyncCycleContext."; | 306 DVLOG(1) << "Sync is bringing up SyncCycleContext."; |
| 311 std::vector<SyncEngineEventListener*> listeners; | 307 std::vector<SyncEngineEventListener*> listeners; |
| 312 listeners.push_back(&allstatus_); | 308 listeners.push_back(&allstatus_); |
| 313 listeners.push_back(this); | 309 listeners.push_back(this); |
| 314 cycle_context_ = args->engine_components_factory->BuildContext( | 310 cycle_context_ = args->engine_components_factory->BuildContext( |
| 315 connection_manager_.get(), directory(), args->extensions_activity, | 311 connection_manager_.get(), directory(), args->extensions_activity, |
| 316 listeners, &debug_info_event_listener_, model_type_registry_.get(), | 312 listeners, &debug_info_event_listener_, model_type_registry_.get(), |
| 317 args->invalidator_client_id); | 313 args->invalidator_client_id); |
| 318 scheduler_ = args->engine_components_factory->BuildScheduler( | 314 scheduler_ = args->engine_components_factory->BuildScheduler( |
| 319 name_, cycle_context_.get(), args->cancelation_signal); | 315 name_, cycle_context_.get(), args->cancelation_signal, |
| 316 args->enable_local_sync_backend); |
| 320 | 317 |
| 321 scheduler_->Start(SyncScheduler::CONFIGURATION_MODE, base::Time()); | 318 scheduler_->Start(SyncScheduler::CONFIGURATION_MODE, base::Time()); |
| 322 | 319 |
| 323 initialized_ = true; | 320 initialized_ = true; |
| 324 | 321 |
| 325 net::NetworkChangeNotifier::AddIPAddressObserver(this); | 322 if (!args->enable_local_sync_backend) { |
| 326 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); | 323 net::NetworkChangeNotifier::AddIPAddressObserver(this); |
| 327 observing_network_connectivity_changes_ = true; | 324 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); |
| 325 observing_network_connectivity_changes_ = true; |
| 328 | 326 |
| 329 UpdateCredentials(args->credentials); | 327 UpdateCredentials(args->credentials); |
| 328 } else { |
| 329 scheduler_->OnCredentialsUpdated(); |
| 330 } |
| 330 | 331 |
| 331 NotifyInitializationSuccess(); | 332 NotifyInitializationSuccess(); |
| 332 } | 333 } |
| 333 | 334 |
| 334 void SyncManagerImpl::NotifyInitializationSuccess() { | 335 void SyncManagerImpl::NotifyInitializationSuccess() { |
| 335 for (auto& observer : observers_) { | 336 for (auto& observer : observers_) { |
| 336 observer.OnInitializationComplete( | 337 observer.OnInitializationComplete( |
| 337 MakeWeakHandle(weak_ptr_factory_.GetWeakPtr()), | 338 MakeWeakHandle(weak_ptr_factory_.GetWeakPtr()), |
| 338 MakeWeakHandle(debug_info_event_listener_.GetWeakPtr()), true, | 339 MakeWeakHandle(debug_info_event_listener_.GetWeakPtr()), true, |
| 339 InitialSyncEndedTypes()); | 340 InitialSyncEndedTypes()); |
| (...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1006 DCHECK(thread_checker_.CalledOnValidThread()); | 1007 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1007 cycle_context_->set_cookie_jar_mismatch(account_mismatch); | 1008 cycle_context_->set_cookie_jar_mismatch(account_mismatch); |
| 1008 cycle_context_->set_cookie_jar_empty(empty_jar); | 1009 cycle_context_->set_cookie_jar_empty(empty_jar); |
| 1009 } | 1010 } |
| 1010 | 1011 |
| 1011 void SyncManagerImpl::OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd) { | 1012 void SyncManagerImpl::OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd) { |
| 1012 directory()->OnMemoryDump(pmd); | 1013 directory()->OnMemoryDump(pmd); |
| 1013 } | 1014 } |
| 1014 | 1015 |
| 1015 } // namespace syncer | 1016 } // namespace syncer |
| OLD | NEW |