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 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 DCHECK(!credentials.sync_token.empty()); | 389 DCHECK(!credentials.sync_token.empty()); |
390 DVLOG(1) << "SyncManager starting Init..."; | 390 DVLOG(1) << "SyncManager starting Init..."; |
391 | 391 |
392 weak_handle_this_ = MakeWeakHandle(weak_ptr_factory_.GetWeakPtr()); | 392 weak_handle_this_ = MakeWeakHandle(weak_ptr_factory_.GetWeakPtr()); |
393 | 393 |
394 blocking_task_runner_ = blocking_task_runner; | 394 blocking_task_runner_ = blocking_task_runner; |
395 | 395 |
396 change_delegate_ = change_delegate; | 396 change_delegate_ = change_delegate; |
397 | 397 |
398 sync_notifier_ = sync_notifier.Pass(); | 398 sync_notifier_ = sync_notifier.Pass(); |
399 sync_notifier_->RegisterHandler(this); | |
400 | 399 |
401 AddObserver(&js_sync_manager_observer_); | 400 AddObserver(&js_sync_manager_observer_); |
402 SetJsEventHandler(event_handler); | 401 SetJsEventHandler(event_handler); |
403 | 402 |
404 AddObserver(&debug_info_event_listener_); | 403 AddObserver(&debug_info_event_listener_); |
405 | 404 |
406 database_path_ = database_location.Append( | 405 database_path_ = database_location.Append( |
407 syncable::Directory::kSyncDatabaseFilename); | 406 syncable::Directory::kSyncDatabaseFilename); |
408 encryptor_ = encryptor; | 407 encryptor_ = encryptor; |
409 unrecoverable_error_handler_ = unrecoverable_error_handler; | 408 unrecoverable_error_handler_ = unrecoverable_error_handler; |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
727 if (!connection_manager_->set_auth_token(credentials.sync_token)) | 726 if (!connection_manager_->set_auth_token(credentials.sync_token)) |
728 return; // Auth token is known to be invalid, so exit early. | 727 return; // Auth token is known to be invalid, so exit early. |
729 | 728 |
730 sync_notifier_->UpdateCredentials(credentials.email, credentials.sync_token); | 729 sync_notifier_->UpdateCredentials(credentials.email, credentials.sync_token); |
731 scheduler_->OnCredentialsUpdated(); | 730 scheduler_->OnCredentialsUpdated(); |
732 } | 731 } |
733 | 732 |
734 void SyncManagerImpl::UpdateEnabledTypes( | 733 void SyncManagerImpl::UpdateEnabledTypes( |
735 const ModelTypeSet& enabled_types) { | 734 const ModelTypeSet& enabled_types) { |
736 DCHECK(thread_checker_.CalledOnValidThread()); | 735 DCHECK(thread_checker_.CalledOnValidThread()); |
737 DCHECK(initialized_); | |
738 sync_notifier_->UpdateRegisteredIds( | 736 sync_notifier_->UpdateRegisteredIds( |
739 this, | 737 this, |
740 ModelTypeSetToObjectIdSet(enabled_types)); | 738 ModelTypeSetToObjectIdSet(enabled_types)); |
741 } | 739 } |
742 | 740 |
743 void SyncManagerImpl::RegisterInvalidationHandler( | |
744 SyncNotifierObserver* handler) { | |
745 DCHECK(thread_checker_.CalledOnValidThread()); | |
746 DCHECK(initialized_); | |
747 sync_notifier_->RegisterHandler(handler); | |
748 } | |
749 | |
750 void SyncManagerImpl::UpdateRegisteredInvalidationIds( | 741 void SyncManagerImpl::UpdateRegisteredInvalidationIds( |
751 SyncNotifierObserver* handler, | 742 SyncNotifierObserver* handler, |
752 const ObjectIdSet& ids) { | 743 const ObjectIdSet& ids) { |
753 DCHECK(thread_checker_.CalledOnValidThread()); | 744 DCHECK(thread_checker_.CalledOnValidThread()); |
754 DCHECK(initialized_); | |
755 sync_notifier_->UpdateRegisteredIds(handler, ids); | 745 sync_notifier_->UpdateRegisteredIds(handler, ids); |
756 } | 746 } |
757 | 747 |
758 void SyncManagerImpl::UnregisterInvalidationHandler( | |
759 SyncNotifierObserver* handler) { | |
760 DCHECK(thread_checker_.CalledOnValidThread()); | |
761 DCHECK(initialized_); | |
762 sync_notifier_->UnregisterHandler(handler); | |
763 } | |
764 | |
765 void SyncManagerImpl::SetEncryptionPassphrase( | 748 void SyncManagerImpl::SetEncryptionPassphrase( |
766 const std::string& passphrase, | 749 const std::string& passphrase, |
767 bool is_explicit) { | 750 bool is_explicit) { |
768 DCHECK(thread_checker_.CalledOnValidThread()); | 751 DCHECK(thread_checker_.CalledOnValidThread()); |
769 // We do not accept empty passphrases. | 752 // We do not accept empty passphrases. |
770 if (passphrase.empty()) { | 753 if (passphrase.empty()) { |
771 NOTREACHED() << "Cannot encrypt with an empty passphrase."; | 754 NOTREACHED() << "Cannot encrypt with an empty passphrase."; |
772 return; | 755 return; |
773 } | 756 } |
774 | 757 |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1226 js_mutation_event_observer_.InvalidateWeakPtrs(); | 1209 js_mutation_event_observer_.InvalidateWeakPtrs(); |
1227 | 1210 |
1228 scheduler_.reset(); | 1211 scheduler_.reset(); |
1229 session_context_.reset(); | 1212 session_context_.reset(); |
1230 | 1213 |
1231 SetJsEventHandler(WeakHandle<JsEventHandler>()); | 1214 SetJsEventHandler(WeakHandle<JsEventHandler>()); |
1232 RemoveObserver(&js_sync_manager_observer_); | 1215 RemoveObserver(&js_sync_manager_observer_); |
1233 | 1216 |
1234 RemoveObserver(&debug_info_event_listener_); | 1217 RemoveObserver(&debug_info_event_listener_); |
1235 | 1218 |
1236 // |sync_notifier_| and |connection_manager_| may end up being NULL here in | 1219 if (sync_notifier_.get()) { |
1237 // tests (in synchronous initialization mode). | 1220 sync_notifier_->UpdateRegisteredIds(this, ObjectIdSet()); |
1238 // | 1221 } |
1239 // TODO(akalin): Fix this behavior. | |
1240 | |
1241 if (sync_notifier_.get()) | |
1242 sync_notifier_->UnregisterHandler(this); | |
1243 sync_notifier_.reset(); | 1222 sync_notifier_.reset(); |
1244 | 1223 |
1245 if (connection_manager_.get()) | 1224 if (connection_manager_.get()) { |
1246 connection_manager_->RemoveListener(this); | 1225 connection_manager_->RemoveListener(this); |
| 1226 } |
1247 connection_manager_.reset(); | 1227 connection_manager_.reset(); |
1248 | 1228 |
1249 net::NetworkChangeNotifier::RemoveIPAddressObserver(this); | 1229 net::NetworkChangeNotifier::RemoveIPAddressObserver(this); |
1250 observing_ip_address_changes_ = false; | 1230 observing_ip_address_changes_ = false; |
1251 | 1231 |
1252 if (initialized_ && directory()) { | 1232 if (initialized_ && directory()) { |
1253 { | 1233 { |
1254 // Cryptographer should only be accessed while holding a | 1234 // Cryptographer should only be accessed while holding a |
1255 // transaction. | 1235 // transaction. |
1256 ReadTransaction trans(FROM_HERE, GetUserShare()); | 1236 ReadTransaction trans(FROM_HERE, GetUserShare()); |
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1917 int SyncManagerImpl::GetDefaultNudgeDelay() { | 1897 int SyncManagerImpl::GetDefaultNudgeDelay() { |
1918 return kDefaultNudgeDelayMilliseconds; | 1898 return kDefaultNudgeDelayMilliseconds; |
1919 } | 1899 } |
1920 | 1900 |
1921 // static. | 1901 // static. |
1922 int SyncManagerImpl::GetPreferencesNudgeDelay() { | 1902 int SyncManagerImpl::GetPreferencesNudgeDelay() { |
1923 return kPreferencesNudgeDelayMilliseconds; | 1903 return kPreferencesNudgeDelayMilliseconds; |
1924 } | 1904 } |
1925 | 1905 |
1926 } // namespace syncer | 1906 } // namespace syncer |
OLD | NEW |