Chromium Code Reviews| 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 if (sync_notifier_.get()) | |
|
msw
2012/08/09 05:20:26
Can this legitimately be NULL? It's not NULL check
akalin
2012/08/10 01:28:08
good catch. this shouldn't be null.
| |
| 400 sync_notifier_->RegisterHandler(this); | |
| 399 | 401 |
| 400 AddObserver(&js_sync_manager_observer_); | 402 AddObserver(&js_sync_manager_observer_); |
| 401 SetJsEventHandler(event_handler); | 403 SetJsEventHandler(event_handler); |
| 402 | 404 |
| 403 AddObserver(&debug_info_event_listener_); | 405 AddObserver(&debug_info_event_listener_); |
| 404 | 406 |
| 405 database_path_ = database_location.Append( | 407 database_path_ = database_location.Append( |
| 406 syncable::Directory::kSyncDatabaseFilename); | 408 syncable::Directory::kSyncDatabaseFilename); |
| 407 encryptor_ = encryptor; | 409 encryptor_ = encryptor; |
| 408 unrecoverable_error_handler_ = unrecoverable_error_handler; | 410 unrecoverable_error_handler_ = unrecoverable_error_handler; |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 726 if (!connection_manager_->set_auth_token(credentials.sync_token)) | 728 if (!connection_manager_->set_auth_token(credentials.sync_token)) |
| 727 return; // Auth token is known to be invalid, so exit early. | 729 return; // Auth token is known to be invalid, so exit early. |
| 728 | 730 |
| 729 sync_notifier_->UpdateCredentials(credentials.email, credentials.sync_token); | 731 sync_notifier_->UpdateCredentials(credentials.email, credentials.sync_token); |
| 730 scheduler_->OnCredentialsUpdated(); | 732 scheduler_->OnCredentialsUpdated(); |
| 731 } | 733 } |
| 732 | 734 |
| 733 void SyncManagerImpl::UpdateEnabledTypes( | 735 void SyncManagerImpl::UpdateEnabledTypes( |
| 734 const ModelTypeSet& enabled_types) { | 736 const ModelTypeSet& enabled_types) { |
| 735 DCHECK(thread_checker_.CalledOnValidThread()); | 737 DCHECK(thread_checker_.CalledOnValidThread()); |
| 738 DCHECK(initialized_); | |
| 736 sync_notifier_->UpdateRegisteredIds( | 739 sync_notifier_->UpdateRegisteredIds( |
| 737 this, | 740 this, |
| 738 ModelTypeSetToObjectIdSet(enabled_types)); | 741 ModelTypeSetToObjectIdSet(enabled_types)); |
| 739 } | 742 } |
| 740 | 743 |
| 744 void SyncManagerImpl::RegisterInvalidationHandler( | |
| 745 SyncNotifierObserver* handler) { | |
| 746 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 747 DCHECK(initialized_); | |
| 748 sync_notifier_->RegisterHandler(handler); | |
| 749 } | |
| 750 | |
| 741 void SyncManagerImpl::UpdateRegisteredInvalidationIds( | 751 void SyncManagerImpl::UpdateRegisteredInvalidationIds( |
| 742 SyncNotifierObserver* handler, | 752 SyncNotifierObserver* handler, |
| 743 const ObjectIdSet& ids) { | 753 const ObjectIdSet& ids) { |
| 744 DCHECK(thread_checker_.CalledOnValidThread()); | 754 DCHECK(thread_checker_.CalledOnValidThread()); |
| 755 DCHECK(initialized_); | |
| 745 sync_notifier_->UpdateRegisteredIds(handler, ids); | 756 sync_notifier_->UpdateRegisteredIds(handler, ids); |
| 746 } | 757 } |
| 747 | 758 |
| 759 void SyncManagerImpl::UnregisterInvalidationHandler( | |
| 760 SyncNotifierObserver* handler) { | |
| 761 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 762 DCHECK(initialized_); | |
| 763 sync_notifier_->UnregisterHandler(handler); | |
| 764 } | |
| 765 | |
| 748 void SyncManagerImpl::SetEncryptionPassphrase( | 766 void SyncManagerImpl::SetEncryptionPassphrase( |
| 749 const std::string& passphrase, | 767 const std::string& passphrase, |
| 750 bool is_explicit) { | 768 bool is_explicit) { |
| 751 DCHECK(thread_checker_.CalledOnValidThread()); | 769 DCHECK(thread_checker_.CalledOnValidThread()); |
| 752 // We do not accept empty passphrases. | 770 // We do not accept empty passphrases. |
| 753 if (passphrase.empty()) { | 771 if (passphrase.empty()) { |
| 754 NOTREACHED() << "Cannot encrypt with an empty passphrase."; | 772 NOTREACHED() << "Cannot encrypt with an empty passphrase."; |
| 755 return; | 773 return; |
| 756 } | 774 } |
| 757 | 775 |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1209 js_mutation_event_observer_.InvalidateWeakPtrs(); | 1227 js_mutation_event_observer_.InvalidateWeakPtrs(); |
| 1210 | 1228 |
| 1211 scheduler_.reset(); | 1229 scheduler_.reset(); |
| 1212 session_context_.reset(); | 1230 session_context_.reset(); |
| 1213 | 1231 |
| 1214 SetJsEventHandler(WeakHandle<JsEventHandler>()); | 1232 SetJsEventHandler(WeakHandle<JsEventHandler>()); |
| 1215 RemoveObserver(&js_sync_manager_observer_); | 1233 RemoveObserver(&js_sync_manager_observer_); |
| 1216 | 1234 |
| 1217 RemoveObserver(&debug_info_event_listener_); | 1235 RemoveObserver(&debug_info_event_listener_); |
| 1218 | 1236 |
| 1219 if (sync_notifier_.get()) { | 1237 if (sync_notifier_.get()) { |
|
msw
2012/08/09 05:20:26
ditto on NULL question; and nit: remove {}
akalin
2012/08/10 01:28:08
needed for tests. added comment.
| |
| 1220 sync_notifier_->UpdateRegisteredIds(this, ObjectIdSet()); | 1238 sync_notifier_->UnregisterHandler(this); |
| 1221 } | 1239 } |
| 1222 sync_notifier_.reset(); | 1240 sync_notifier_.reset(); |
| 1223 | 1241 |
| 1224 if (connection_manager_.get()) { | 1242 if (connection_manager_.get()) { |
| 1225 connection_manager_->RemoveListener(this); | 1243 connection_manager_->RemoveListener(this); |
| 1226 } | 1244 } |
| 1227 connection_manager_.reset(); | 1245 connection_manager_.reset(); |
| 1228 | 1246 |
| 1229 net::NetworkChangeNotifier::RemoveIPAddressObserver(this); | 1247 net::NetworkChangeNotifier::RemoveIPAddressObserver(this); |
| 1230 observing_ip_address_changes_ = false; | 1248 observing_ip_address_changes_ = false; |
| (...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1897 int SyncManagerImpl::GetDefaultNudgeDelay() { | 1915 int SyncManagerImpl::GetDefaultNudgeDelay() { |
| 1898 return kDefaultNudgeDelayMilliseconds; | 1916 return kDefaultNudgeDelayMilliseconds; |
| 1899 } | 1917 } |
| 1900 | 1918 |
| 1901 // static. | 1919 // static. |
| 1902 int SyncManagerImpl::GetPreferencesNudgeDelay() { | 1920 int SyncManagerImpl::GetPreferencesNudgeDelay() { |
| 1903 return kPreferencesNudgeDelayMilliseconds; | 1921 return kPreferencesNudgeDelayMilliseconds; |
| 1904 } | 1922 } |
| 1905 | 1923 |
| 1906 } // namespace syncer | 1924 } // namespace syncer |
| OLD | NEW |