Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: sync/internal_api/sync_manager_impl.cc

Issue 10824161: [Sync] Avoid unregistering object IDs on shutdown (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Work around brittle unit test Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sync/internal_api/sync_manager_impl.h ('k') | sync/internal_api/sync_manager_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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);
399 400
400 AddObserver(&js_sync_manager_observer_); 401 AddObserver(&js_sync_manager_observer_);
401 SetJsEventHandler(event_handler); 402 SetJsEventHandler(event_handler);
402 403
403 AddObserver(&debug_info_event_listener_); 404 AddObserver(&debug_info_event_listener_);
404 405
405 database_path_ = database_location.Append( 406 database_path_ = database_location.Append(
406 syncable::Directory::kSyncDatabaseFilename); 407 syncable::Directory::kSyncDatabaseFilename);
407 encryptor_ = encryptor; 408 encryptor_ = encryptor;
408 unrecoverable_error_handler_ = unrecoverable_error_handler; 409 unrecoverable_error_handler_ = unrecoverable_error_handler;
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 if (!connection_manager_->set_auth_token(credentials.sync_token)) 727 if (!connection_manager_->set_auth_token(credentials.sync_token))
727 return; // Auth token is known to be invalid, so exit early. 728 return; // Auth token is known to be invalid, so exit early.
728 729
729 sync_notifier_->UpdateCredentials(credentials.email, credentials.sync_token); 730 sync_notifier_->UpdateCredentials(credentials.email, credentials.sync_token);
730 scheduler_->OnCredentialsUpdated(); 731 scheduler_->OnCredentialsUpdated();
731 } 732 }
732 733
733 void SyncManagerImpl::UpdateEnabledTypes( 734 void SyncManagerImpl::UpdateEnabledTypes(
734 const ModelTypeSet& enabled_types) { 735 const ModelTypeSet& enabled_types) {
735 DCHECK(thread_checker_.CalledOnValidThread()); 736 DCHECK(thread_checker_.CalledOnValidThread());
737 DCHECK(initialized_);
736 sync_notifier_->UpdateRegisteredIds( 738 sync_notifier_->UpdateRegisteredIds(
737 this, 739 this,
738 ModelTypeSetToObjectIdSet(enabled_types)); 740 ModelTypeSetToObjectIdSet(enabled_types));
739 } 741 }
740 742
743 void SyncManagerImpl::RegisterInvalidationHandler(
744 SyncNotifierObserver* handler) {
745 DCHECK(thread_checker_.CalledOnValidThread());
746 DCHECK(initialized_);
747 sync_notifier_->RegisterHandler(handler);
748 }
749
741 void SyncManagerImpl::UpdateRegisteredInvalidationIds( 750 void SyncManagerImpl::UpdateRegisteredInvalidationIds(
742 SyncNotifierObserver* handler, 751 SyncNotifierObserver* handler,
743 const ObjectIdSet& ids) { 752 const ObjectIdSet& ids) {
744 DCHECK(thread_checker_.CalledOnValidThread()); 753 DCHECK(thread_checker_.CalledOnValidThread());
754 DCHECK(initialized_);
745 sync_notifier_->UpdateRegisteredIds(handler, ids); 755 sync_notifier_->UpdateRegisteredIds(handler, ids);
746 } 756 }
747 757
758 void SyncManagerImpl::UnregisterInvalidationHandler(
759 SyncNotifierObserver* handler) {
760 DCHECK(thread_checker_.CalledOnValidThread());
761 DCHECK(initialized_);
762 sync_notifier_->UnregisterHandler(handler);
763 }
764
748 void SyncManagerImpl::SetEncryptionPassphrase( 765 void SyncManagerImpl::SetEncryptionPassphrase(
749 const std::string& passphrase, 766 const std::string& passphrase,
750 bool is_explicit) { 767 bool is_explicit) {
751 DCHECK(thread_checker_.CalledOnValidThread()); 768 DCHECK(thread_checker_.CalledOnValidThread());
752 // We do not accept empty passphrases. 769 // We do not accept empty passphrases.
753 if (passphrase.empty()) { 770 if (passphrase.empty()) {
754 NOTREACHED() << "Cannot encrypt with an empty passphrase."; 771 NOTREACHED() << "Cannot encrypt with an empty passphrase.";
755 return; 772 return;
756 } 773 }
757 774
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
1209 js_mutation_event_observer_.InvalidateWeakPtrs(); 1226 js_mutation_event_observer_.InvalidateWeakPtrs();
1210 1227
1211 scheduler_.reset(); 1228 scheduler_.reset();
1212 session_context_.reset(); 1229 session_context_.reset();
1213 1230
1214 SetJsEventHandler(WeakHandle<JsEventHandler>()); 1231 SetJsEventHandler(WeakHandle<JsEventHandler>());
1215 RemoveObserver(&js_sync_manager_observer_); 1232 RemoveObserver(&js_sync_manager_observer_);
1216 1233
1217 RemoveObserver(&debug_info_event_listener_); 1234 RemoveObserver(&debug_info_event_listener_);
1218 1235
1219 if (sync_notifier_.get()) { 1236 // |sync_notifier_| and |connection_manager_| may end up being NULL here in
1220 sync_notifier_->UpdateRegisteredIds(this, ObjectIdSet()); 1237 // tests (in synchronous initialization mode).
1221 } 1238 //
1239 // TODO(akalin): Fix this behavior.
1240
1241 if (sync_notifier_.get())
1242 sync_notifier_->UnregisterHandler(this);
1222 sync_notifier_.reset(); 1243 sync_notifier_.reset();
1223 1244
1224 if (connection_manager_.get()) { 1245 if (connection_manager_.get())
1225 connection_manager_->RemoveListener(this); 1246 connection_manager_->RemoveListener(this);
1226 }
1227 connection_manager_.reset(); 1247 connection_manager_.reset();
1228 1248
1229 net::NetworkChangeNotifier::RemoveIPAddressObserver(this); 1249 net::NetworkChangeNotifier::RemoveIPAddressObserver(this);
1230 observing_ip_address_changes_ = false; 1250 observing_ip_address_changes_ = false;
1231 1251
1232 if (initialized_ && directory()) { 1252 if (initialized_ && directory()) {
1233 { 1253 {
1234 // Cryptographer should only be accessed while holding a 1254 // Cryptographer should only be accessed while holding a
1235 // transaction. 1255 // transaction.
1236 ReadTransaction trans(FROM_HERE, GetUserShare()); 1256 ReadTransaction trans(FROM_HERE, GetUserShare());
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
1897 int SyncManagerImpl::GetDefaultNudgeDelay() { 1917 int SyncManagerImpl::GetDefaultNudgeDelay() {
1898 return kDefaultNudgeDelayMilliseconds; 1918 return kDefaultNudgeDelayMilliseconds;
1899 } 1919 }
1900 1920
1901 // static. 1921 // static.
1902 int SyncManagerImpl::GetPreferencesNudgeDelay() { 1922 int SyncManagerImpl::GetPreferencesNudgeDelay() {
1903 return kPreferencesNudgeDelayMilliseconds; 1923 return kPreferencesNudgeDelayMilliseconds;
1904 } 1924 }
1905 1925
1906 } // namespace syncer 1926 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/internal_api/sync_manager_impl.h ('k') | sync/internal_api/sync_manager_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698