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