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

Unified Diff: chrome/browser/sync/profile_sync_service.cc

Issue 10915216: Browser test for the push messaging feature (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: refactor to reduce duplication Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sync/profile_sync_service.cc
diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc
index 366026f19d0ee7d468d93903afe21b9b920ee832..860ce7bf31dd888e43f3b58bcdc765f614c4513f 100644
--- a/chrome/browser/sync/profile_sync_service.cc
+++ b/chrome/browser/sync/profile_sync_service.cc
@@ -79,6 +79,8 @@ using syncer::JsController;
using syncer::JsEventDetails;
using syncer::JsEventHandler;
using syncer::ModelSafeRoutingInfo;
+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.
+using syncer::ObjectIdStateMap;
using syncer::SyncCredentials;
using syncer::SyncProtocolError;
using syncer::WeakHandle;
@@ -472,6 +474,32 @@ syncer::InvalidatorState ProfileSyncService::GetInvalidatorState() const {
return invalidator_registrar_.GetInvalidatorState();
}
+// test method for system test to allow a test to send in an invalidation
+void ProfileSyncService::SendNotificationForTest(
+ 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
+ const std::string& payload) {
+ // the list of ids to notify
+ ObjectIdSet notify_ids;
+
+ // find a registered id (if any) with the same name
+ ObjectIdSet registered_ids = invalidator_registrar_.GetAllRegisteredIds();
+ ObjectIdSet::const_iterator it = registered_ids.begin();
+ for (; it != registered_ids.end(); ++it) {
+ if (0 == id_name.compare(it->name())) {
+ // if we find a registered id with the same name, insert a copy of it
+ // into the list of ids we will notify
+ notify_ids.insert(invalidation::ObjectId(it->source(), it->name()));
+ }
+ }
+
+ // build an object state map, and use it to forward the call to
+ // registered clients such as PushMessagingHandler::OnIncomingNotification
+ // as if this came from the server
+ const ObjectIdStateMap& id_state_map =
+ ObjectIdSetToStateMap(notify_ids, payload);
+ OnIncomingInvalidation(id_state_map, syncer::REMOTE_INVALIDATION);
+}
+
void ProfileSyncService::Shutdown() {
ShutdownImpl(false);
}

Powered by Google App Engine
This is Rietveld 408576698