| 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 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 | 381 |
| 382 std::string sync_id = directory()->cache_guid(); | 382 std::string sync_id = directory()->cache_guid(); |
| 383 | 383 |
| 384 DVLOG(1) << "Setting sync client ID: " << sync_id; | 384 DVLOG(1) << "Setting sync client ID: " << sync_id; |
| 385 allstatus_.SetSyncId(sync_id); | 385 allstatus_.SetSyncId(sync_id); |
| 386 DVLOG(1) << "Setting invalidator client ID: " << args->invalidator_client_id; | 386 DVLOG(1) << "Setting invalidator client ID: " << args->invalidator_client_id; |
| 387 allstatus_.SetInvalidatorClientId(args->invalidator_client_id); | 387 allstatus_.SetInvalidatorClientId(args->invalidator_client_id); |
| 388 | 388 |
| 389 model_type_registry_.reset( | 389 model_type_registry_.reset( |
| 390 new ModelTypeRegistry(args->workers, directory(), this)); | 390 new ModelTypeRegistry(args->workers, directory(), this)); |
| 391 sync_encryption_handler_->AddObserver(model_type_registry_.get()); |
| 391 | 392 |
| 392 // Bind the SyncContext WeakPtr to this thread. This helps us crash earlier | 393 // Bind the SyncContext WeakPtr to this thread. This helps us crash earlier |
| 393 // if the pointer is misused in debug mode. | 394 // if the pointer is misused in debug mode. |
| 394 base::WeakPtr<SyncContext> weak_core = model_type_registry_->AsWeakPtr(); | 395 base::WeakPtr<SyncContext> weak_core = model_type_registry_->AsWeakPtr(); |
| 395 weak_core.get(); | 396 weak_core.get(); |
| 396 | 397 |
| 397 sync_context_proxy_.reset( | 398 sync_context_proxy_.reset( |
| 398 new SyncContextProxyImpl(base::ThreadTaskRunnerHandle::Get(), weak_core)); | 399 new SyncContextProxyImpl(base::ThreadTaskRunnerHandle::Get(), weak_core)); |
| 399 | 400 |
| 400 // Build a SyncSessionContext and store the worker in it. | 401 // Build a SyncSessionContext and store the worker in it. |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 void SyncManagerImpl::ShutdownOnSyncThread(ShutdownReason reason) { | 602 void SyncManagerImpl::ShutdownOnSyncThread(ShutdownReason reason) { |
| 602 DCHECK(thread_checker_.CalledOnValidThread()); | 603 DCHECK(thread_checker_.CalledOnValidThread()); |
| 603 | 604 |
| 604 // Prevent any in-flight method calls from running. Also | 605 // Prevent any in-flight method calls from running. Also |
| 605 // invalidates |weak_handle_this_| and |change_observer_|. | 606 // invalidates |weak_handle_this_| and |change_observer_|. |
| 606 weak_ptr_factory_.InvalidateWeakPtrs(); | 607 weak_ptr_factory_.InvalidateWeakPtrs(); |
| 607 js_mutation_event_observer_.InvalidateWeakPtrs(); | 608 js_mutation_event_observer_.InvalidateWeakPtrs(); |
| 608 | 609 |
| 609 scheduler_.reset(); | 610 scheduler_.reset(); |
| 610 session_context_.reset(); | 611 session_context_.reset(); |
| 612 |
| 613 if (model_type_registry_) |
| 614 sync_encryption_handler_->RemoveObserver(model_type_registry_.get()); |
| 615 |
| 611 model_type_registry_.reset(); | 616 model_type_registry_.reset(); |
| 612 | 617 |
| 613 if (sync_encryption_handler_) { | 618 if (sync_encryption_handler_) { |
| 614 sync_encryption_handler_->RemoveObserver(&debug_info_event_listener_); | 619 sync_encryption_handler_->RemoveObserver(&debug_info_event_listener_); |
| 615 sync_encryption_handler_->RemoveObserver(this); | 620 sync_encryption_handler_->RemoveObserver(this); |
| 616 } | 621 } |
| 617 | 622 |
| 618 SetJsEventHandler(WeakHandle<JsEventHandler>()); | 623 SetJsEventHandler(WeakHandle<JsEventHandler>()); |
| 619 RemoveObserver(&js_sync_manager_observer_); | 624 RemoveObserver(&js_sync_manager_observer_); |
| 620 | 625 |
| (...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1140 int SyncManagerImpl::GetDefaultNudgeDelay() { | 1145 int SyncManagerImpl::GetDefaultNudgeDelay() { |
| 1141 return kDefaultNudgeDelayMilliseconds; | 1146 return kDefaultNudgeDelayMilliseconds; |
| 1142 } | 1147 } |
| 1143 | 1148 |
| 1144 // static. | 1149 // static. |
| 1145 int SyncManagerImpl::GetPreferencesNudgeDelay() { | 1150 int SyncManagerImpl::GetPreferencesNudgeDelay() { |
| 1146 return kPreferencesNudgeDelayMilliseconds; | 1151 return kPreferencesNudgeDelayMilliseconds; |
| 1147 } | 1152 } |
| 1148 | 1153 |
| 1149 } // namespace syncer | 1154 } // namespace syncer |
| OLD | NEW |