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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 using browser_sync::DataTypeController; | 72 using browser_sync::DataTypeController; |
| 73 using browser_sync::DataTypeManager; | 73 using browser_sync::DataTypeManager; |
| 74 using browser_sync::SyncBackendHost; | 74 using browser_sync::SyncBackendHost; |
| 75 using syncer::ModelType; | 75 using syncer::ModelType; |
| 76 using syncer::ModelTypeSet; | 76 using syncer::ModelTypeSet; |
| 77 using syncer::JsBackend; | 77 using syncer::JsBackend; |
| 78 using syncer::JsController; | 78 using syncer::JsController; |
| 79 using syncer::JsEventDetails; | 79 using syncer::JsEventDetails; |
| 80 using syncer::JsEventHandler; | 80 using syncer::JsEventHandler; |
| 81 using syncer::ModelSafeRoutingInfo; | 81 using syncer::ModelSafeRoutingInfo; |
| 82 using syncer::ObjectIdSet; | |
|
dcheng
2012/09/13 21:00:48
If you want to add using lines for this, you shoul
Pete Williamson
2012/09/14 19:14:48
Done.
| |
| 83 using syncer::ObjectIdStateMap; | |
| 82 using syncer::SyncCredentials; | 84 using syncer::SyncCredentials; |
| 83 using syncer::SyncProtocolError; | 85 using syncer::SyncProtocolError; |
| 84 using syncer::WeakHandle; | 86 using syncer::WeakHandle; |
| 85 | 87 |
| 86 typedef GoogleServiceAuthError AuthError; | 88 typedef GoogleServiceAuthError AuthError; |
| 87 | 89 |
| 88 const char* ProfileSyncService::kSyncServerUrl = | 90 const char* ProfileSyncService::kSyncServerUrl = |
| 89 "https://clients4.google.com/chrome-sync"; | 91 "https://clients4.google.com/chrome-sync"; |
| 90 | 92 |
| 91 const char* ProfileSyncService::kDevServerUrl = | 93 const char* ProfileSyncService::kDevServerUrl = |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 465 | 467 |
| 466 void ProfileSyncService::UnregisterInvalidationHandler( | 468 void ProfileSyncService::UnregisterInvalidationHandler( |
| 467 syncer::InvalidationHandler* handler) { | 469 syncer::InvalidationHandler* handler) { |
| 468 invalidator_registrar_.UnregisterHandler(handler); | 470 invalidator_registrar_.UnregisterHandler(handler); |
| 469 } | 471 } |
| 470 | 472 |
| 471 syncer::InvalidatorState ProfileSyncService::GetInvalidatorState() const { | 473 syncer::InvalidatorState ProfileSyncService::GetInvalidatorState() const { |
| 472 return invalidator_registrar_.GetInvalidatorState(); | 474 return invalidator_registrar_.GetInvalidatorState(); |
| 473 } | 475 } |
| 474 | 476 |
| 477 // test method for system test to allow a test to send in an invalidation | |
| 478 void ProfileSyncService::SendNotificationForTest( | |
| 479 const std::string& id_name, | |
|
dcheng
2012/09/13 21:00:48
Why not have this take an ObjectId or an ObjectIdS
Pete Williamson
2012/09/14 19:14:48
Since we have to look up the name in the invalidat
dcheng
2012/09/17 18:39:15
I don't quite understand what you mean. You don't
| |
| 480 const std::string& payload) { | |
| 481 // the list of ids to notify | |
| 482 ObjectIdSet notify_ids; | |
| 483 | |
| 484 // find a registered id (if any) with the same name | |
| 485 ObjectIdSet registered_ids = invalidator_registrar_.GetAllRegisteredIds(); | |
| 486 ObjectIdSet::const_iterator it = registered_ids.begin(); | |
| 487 for (; it != registered_ids.end(); ++it) { | |
| 488 if (0 == id_name.compare(it->name())) { | |
| 489 // if we find a registered id with the same name, insert a copy of it | |
| 490 // into the list of ids we will notify | |
| 491 notify_ids.insert(invalidation::ObjectId(it->source(), it->name())); | |
| 492 } | |
| 493 } | |
| 494 | |
| 495 // build an object state map, and use it to forward the call to | |
| 496 // registered clients such as PushMessagingHandler::OnIncomingNotification | |
| 497 // as if this came from the server | |
| 498 const ObjectIdStateMap& id_state_map = | |
| 499 ObjectIdSetToStateMap(notify_ids, payload); | |
| 500 OnIncomingInvalidation(id_state_map, syncer::REMOTE_INVALIDATION); | |
| 501 } | |
| 502 | |
| 475 void ProfileSyncService::Shutdown() { | 503 void ProfileSyncService::Shutdown() { |
| 476 ShutdownImpl(false); | 504 ShutdownImpl(false); |
| 477 } | 505 } |
| 478 | 506 |
| 479 void ProfileSyncService::ShutdownImpl(bool sync_disabled) { | 507 void ProfileSyncService::ShutdownImpl(bool sync_disabled) { |
| 480 // First, we spin down the backend and wait for it to stop syncing completely | 508 // 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 | 509 // 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 | 510 // applying changes to the sync db that wouldn't get applied via |
| 483 // ChangeProcessors, leading to back-from-the-dead bugs. | 511 // ChangeProcessors, leading to back-from-the-dead bugs. |
| 484 base::Time shutdown_start_time = base::Time::Now(); | 512 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. | 1842 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru. |
| 1815 ProfileSyncService* old_this = this; | 1843 ProfileSyncService* old_this = this; |
| 1816 this->~ProfileSyncService(); | 1844 this->~ProfileSyncService(); |
| 1817 new(old_this) ProfileSyncService( | 1845 new(old_this) ProfileSyncService( |
| 1818 new ProfileSyncComponentsFactoryImpl(profile, | 1846 new ProfileSyncComponentsFactoryImpl(profile, |
| 1819 CommandLine::ForCurrentProcess()), | 1847 CommandLine::ForCurrentProcess()), |
| 1820 profile, | 1848 profile, |
| 1821 signin, | 1849 signin, |
| 1822 behavior); | 1850 behavior); |
| 1823 } | 1851 } |
| OLD | NEW |