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 "chrome/browser/sync/profile_sync_service.h" | 5 #include "chrome/browser/sync/profile_sync_service.h" |
| 6 | 6 |
| 7 #include <cstddef> | 7 #include <cstddef> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 465 | 465 |
| 466 void ProfileSyncService::UnregisterInvalidationHandler( | 466 void ProfileSyncService::UnregisterInvalidationHandler( |
| 467 syncer::InvalidationHandler* handler) { | 467 syncer::InvalidationHandler* handler) { |
| 468 invalidator_registrar_.UnregisterHandler(handler); | 468 invalidator_registrar_.UnregisterHandler(handler); |
| 469 } | 469 } |
| 470 | 470 |
| 471 syncer::InvalidatorState ProfileSyncService::GetInvalidatorState() const { | 471 syncer::InvalidatorState ProfileSyncService::GetInvalidatorState() const { |
| 472 return invalidator_registrar_.GetInvalidatorState(); | 472 return invalidator_registrar_.GetInvalidatorState(); |
| 473 } | 473 } |
| 474 | 474 |
| 475 // test method for system test to allow a test to send in an invalidation | |
|
Mihai Parparita -not on Chrome
2012/09/14 20:02:49
More comments that need to be capitalized and end
| |
| 476 void ProfileSyncService::SendInvalidationForTest( | |
| 477 const std::string& id_name, | |
| 478 const std::string& payload) { | |
| 479 // the list of ids to notify | |
| 480 syncer::ObjectIdSet notify_ids; | |
| 481 | |
| 482 // find a registered id (if any) with the same name | |
| 483 syncer::ObjectIdSet registered_ids = | |
| 484 invalidator_registrar_.GetAllRegisteredIds(); | |
| 485 syncer::ObjectIdSet::const_iterator it = registered_ids.begin(); | |
| 486 for (; it != registered_ids.end(); ++it) { | |
| 487 if (0 == id_name.compare(it->name())) { | |
| 488 // if we find a registered id with the same name, insert a copy of it | |
| 489 // into the list of ids we will notify | |
| 490 notify_ids.insert(invalidation::ObjectId(it->source(), it->name())); | |
| 491 } | |
| 492 } | |
| 493 | |
| 494 // build an object state map, and use it to forward the call to | |
| 495 // registered clients such as PushMessagingHandler::OnIncomingNotification | |
| 496 // as if this came from the server | |
| 497 const syncer::ObjectIdStateMap& id_state_map = | |
| 498 ObjectIdSetToStateMap(notify_ids, payload); | |
| 499 OnIncomingInvalidation(id_state_map, syncer::REMOTE_INVALIDATION); | |
| 500 } | |
| 501 | |
| 475 void ProfileSyncService::Shutdown() { | 502 void ProfileSyncService::Shutdown() { |
| 476 ShutdownImpl(false); | 503 ShutdownImpl(false); |
| 477 } | 504 } |
| 478 | 505 |
| 479 void ProfileSyncService::ShutdownImpl(bool sync_disabled) { | 506 void ProfileSyncService::ShutdownImpl(bool sync_disabled) { |
| 480 // First, we spin down the backend and wait for it to stop syncing completely | 507 // First, we spin down the backend and wait for it to stop syncing completely |
| 481 // before we Stop the data type manager. This is to avoid a late sync cycle | 508 // before we Stop the data type manager. This is to avoid a late sync cycle |
| 482 // applying changes to the sync db that wouldn't get applied via | 509 // applying changes to the sync db that wouldn't get applied via |
| 483 // ChangeProcessors, leading to back-from-the-dead bugs. | 510 // ChangeProcessors, leading to back-from-the-dead bugs. |
| 484 base::Time shutdown_start_time = base::Time::Now(); | 511 base::Time shutdown_start_time = base::Time::Now(); |
| (...skipping 1329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1814 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru. | 1841 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru. |
| 1815 ProfileSyncService* old_this = this; | 1842 ProfileSyncService* old_this = this; |
| 1816 this->~ProfileSyncService(); | 1843 this->~ProfileSyncService(); |
| 1817 new(old_this) ProfileSyncService( | 1844 new(old_this) ProfileSyncService( |
| 1818 new ProfileSyncComponentsFactoryImpl(profile, | 1845 new ProfileSyncComponentsFactoryImpl(profile, |
| 1819 CommandLine::ForCurrentProcess()), | 1846 CommandLine::ForCurrentProcess()), |
| 1820 profile, | 1847 profile, |
| 1821 signin, | 1848 signin, |
| 1822 behavior); | 1849 behavior); |
| 1823 } | 1850 } |
| OLD | NEW |