| 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 "sync/internal_api/sync_manager_impl.h" | 5 #include "sync/internal_api/sync_manager_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 } | 416 } |
| 417 | 417 |
| 418 connection_manager_.reset(new SyncAPIServerConnectionManager( | 418 connection_manager_.reset(new SyncAPIServerConnectionManager( |
| 419 sync_server_and_path, port, use_ssl, | 419 sync_server_and_path, port, use_ssl, |
| 420 post_factory.release(), cancelation_signal)); | 420 post_factory.release(), cancelation_signal)); |
| 421 connection_manager_->set_client_id(directory()->cache_guid()); | 421 connection_manager_->set_client_id(directory()->cache_guid()); |
| 422 connection_manager_->AddListener(this); | 422 connection_manager_->AddListener(this); |
| 423 | 423 |
| 424 std::string sync_id = directory()->cache_guid(); | 424 std::string sync_id = directory()->cache_guid(); |
| 425 | 425 |
| 426 DVLOG(1) << "Setting sync client ID: " << sync_id; |
| 426 allstatus_.SetSyncId(sync_id); | 427 allstatus_.SetSyncId(sync_id); |
| 428 DVLOG(1) << "Setting invalidator client ID: " << invalidator_client_id; |
| 427 allstatus_.SetInvalidatorClientId(invalidator_client_id); | 429 allstatus_.SetInvalidatorClientId(invalidator_client_id); |
| 428 | 430 |
| 429 DVLOG(1) << "Setting sync client ID: " << sync_id; | 431 model_type_registry_.reset(new ModelTypeRegistry(workers, directory())); |
| 430 DVLOG(1) << "Setting invalidator client ID: " << invalidator_client_id; | |
| 431 | 432 |
| 432 // Build a SyncSessionContext and store the worker in it. | 433 // Build a SyncSessionContext and store the worker in it. |
| 433 DVLOG(1) << "Sync is bringing up SyncSessionContext."; | 434 DVLOG(1) << "Sync is bringing up SyncSessionContext."; |
| 434 std::vector<SyncEngineEventListener*> listeners; | 435 std::vector<SyncEngineEventListener*> listeners; |
| 435 listeners.push_back(&allstatus_); | 436 listeners.push_back(&allstatus_); |
| 436 listeners.push_back(this); | 437 listeners.push_back(this); |
| 437 session_context_ = internal_components_factory->BuildContext( | 438 session_context_ = internal_components_factory->BuildContext( |
| 438 connection_manager_.get(), | 439 connection_manager_.get(), |
| 439 directory(), | 440 directory(), |
| 440 workers, | |
| 441 extensions_activity, | 441 extensions_activity, |
| 442 listeners, | 442 listeners, |
| 443 &debug_info_event_listener_, | 443 &debug_info_event_listener_, |
| 444 &traffic_recorder_, | 444 &traffic_recorder_, |
| 445 model_type_registry_.get(), |
| 445 invalidator_client_id).Pass(); | 446 invalidator_client_id).Pass(); |
| 446 session_context_->set_account_name(credentials.email); | 447 session_context_->set_account_name(credentials.email); |
| 447 scheduler_ = internal_components_factory->BuildScheduler( | 448 scheduler_ = internal_components_factory->BuildScheduler( |
| 448 name_, session_context_.get(), cancelation_signal).Pass(); | 449 name_, session_context_.get(), cancelation_signal).Pass(); |
| 449 | 450 |
| 450 scheduler_->Start(SyncScheduler::CONFIGURATION_MODE); | 451 scheduler_->Start(SyncScheduler::CONFIGURATION_MODE); |
| 451 | 452 |
| 452 initialized_ = true; | 453 initialized_ = true; |
| 453 | 454 |
| 454 net::NetworkChangeNotifier::AddIPAddressObserver(this); | 455 net::NetworkChangeNotifier::AddIPAddressObserver(this); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 } | 520 } |
| 520 | 521 |
| 521 void SyncManagerImpl::StartSyncingNormally( | 522 void SyncManagerImpl::StartSyncingNormally( |
| 522 const ModelSafeRoutingInfo& routing_info) { | 523 const ModelSafeRoutingInfo& routing_info) { |
| 523 // Start the sync scheduler. | 524 // Start the sync scheduler. |
| 524 // TODO(sync): We always want the newest set of routes when we switch back | 525 // TODO(sync): We always want the newest set of routes when we switch back |
| 525 // to normal mode. Figure out how to enforce set_routing_info is always | 526 // to normal mode. Figure out how to enforce set_routing_info is always |
| 526 // appropriately set and that it's only modified when switching to normal | 527 // appropriately set and that it's only modified when switching to normal |
| 527 // mode. | 528 // mode. |
| 528 DCHECK(thread_checker_.CalledOnValidThread()); | 529 DCHECK(thread_checker_.CalledOnValidThread()); |
| 529 session_context_->set_routing_info(routing_info); | 530 session_context_->SetRoutingInfo(routing_info); |
| 530 scheduler_->Start(SyncScheduler::NORMAL_MODE); | 531 scheduler_->Start(SyncScheduler::NORMAL_MODE); |
| 531 } | 532 } |
| 532 | 533 |
| 533 syncable::Directory* SyncManagerImpl::directory() { | 534 syncable::Directory* SyncManagerImpl::directory() { |
| 534 return share_.directory.get(); | 535 return share_.directory.get(); |
| 535 } | 536 } |
| 536 | 537 |
| 537 const SyncScheduler* SyncManagerImpl::scheduler() const { | 538 const SyncScheduler* SyncManagerImpl::scheduler() const { |
| 538 return scheduler_.get(); | 539 return scheduler_.get(); |
| 539 } | 540 } |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 void SyncManagerImpl::ShutdownOnSyncThread() { | 632 void SyncManagerImpl::ShutdownOnSyncThread() { |
| 632 DCHECK(thread_checker_.CalledOnValidThread()); | 633 DCHECK(thread_checker_.CalledOnValidThread()); |
| 633 | 634 |
| 634 // Prevent any in-flight method calls from running. Also | 635 // Prevent any in-flight method calls from running. Also |
| 635 // invalidates |weak_handle_this_| and |change_observer_|. | 636 // invalidates |weak_handle_this_| and |change_observer_|. |
| 636 weak_ptr_factory_.InvalidateWeakPtrs(); | 637 weak_ptr_factory_.InvalidateWeakPtrs(); |
| 637 js_mutation_event_observer_.InvalidateWeakPtrs(); | 638 js_mutation_event_observer_.InvalidateWeakPtrs(); |
| 638 | 639 |
| 639 scheduler_.reset(); | 640 scheduler_.reset(); |
| 640 session_context_.reset(); | 641 session_context_.reset(); |
| 642 model_type_registry_.reset(); |
| 641 | 643 |
| 642 if (sync_encryption_handler_) { | 644 if (sync_encryption_handler_) { |
| 643 sync_encryption_handler_->RemoveObserver(&debug_info_event_listener_); | 645 sync_encryption_handler_->RemoveObserver(&debug_info_event_listener_); |
| 644 sync_encryption_handler_->RemoveObserver(this); | 646 sync_encryption_handler_->RemoveObserver(this); |
| 645 } | 647 } |
| 646 | 648 |
| 647 SetJsEventHandler(WeakHandle<JsEventHandler>()); | 649 SetJsEventHandler(WeakHandle<JsEventHandler>()); |
| 648 RemoveObserver(&js_sync_manager_observer_); | 650 RemoveObserver(&js_sync_manager_observer_); |
| 649 | 651 |
| 650 RemoveObserver(&debug_info_event_listener_); | 652 RemoveObserver(&debug_info_event_listener_); |
| (...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1338 int SyncManagerImpl::GetDefaultNudgeDelay() { | 1340 int SyncManagerImpl::GetDefaultNudgeDelay() { |
| 1339 return kDefaultNudgeDelayMilliseconds; | 1341 return kDefaultNudgeDelayMilliseconds; |
| 1340 } | 1342 } |
| 1341 | 1343 |
| 1342 // static. | 1344 // static. |
| 1343 int SyncManagerImpl::GetPreferencesNudgeDelay() { | 1345 int SyncManagerImpl::GetPreferencesNudgeDelay() { |
| 1344 return kPreferencesNudgeDelayMilliseconds; | 1346 return kPreferencesNudgeDelayMilliseconds; |
| 1345 } | 1347 } |
| 1346 | 1348 |
| 1347 } // namespace syncer | 1349 } // namespace syncer |
| OLD | NEW |