summaryrefslogtreecommitdiffstats
path: root/sync/notifier
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-02 23:49:55 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-02 23:49:55 +0000
commit23b4c45ac76ceb2db660b45d6c9887f467d24d20 (patch)
treeb8014e7c850e87dfe255e55884bac54c27189026 /sync/notifier
parent4e6f6cb768dbf838cec3ad5cc1dee89be18e9d33 (diff)
downloadchromium_src-23b4c45ac76ceb2db660b45d6c9887f467d24d20.zip
chromium_src-23b4c45ac76ceb2db660b45d6c9887f467d24d20.tar.gz
chromium_src-23b4c45ac76ceb2db660b45d6c9887f467d24d20.tar.bz2
[Sync] Enable adding notifier observers from ProfileSyncService
Plumb the registrations from the UI thread to the sync thread, and plumb the invalidations back. Add ObjectIdSet <-> ObjectIdPayloadMap conversions. Rename syncapi_unittest.cc to sync_manager_impl_unittest.cc. BUG=137087 TEST= Review URL: https://chromiumcodereview.appspot.com/10805002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149747 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/notifier')
-rw-r--r--sync/notifier/object_id_payload_map.cc19
-rw-r--r--sync/notifier/object_id_payload_map.h5
-rw-r--r--sync/notifier/sync_notifier.h7
3 files changed, 28 insertions, 3 deletions
diff --git a/sync/notifier/object_id_payload_map.cc b/sync/notifier/object_id_payload_map.cc
index 179f8be..19eed0c 100644
--- a/sync/notifier/object_id_payload_map.cc
+++ b/sync/notifier/object_id_payload_map.cc
@@ -6,6 +6,25 @@
namespace syncer {
+ObjectIdSet ObjectIdPayloadMapToSet(
+ const ObjectIdPayloadMap& id_payloads) {
+ ObjectIdSet ids;
+ for (ObjectIdPayloadMap::const_iterator it = id_payloads.begin();
+ it != id_payloads.end(); ++it) {
+ ids.insert(it->first);
+ }
+ return ids;
+}
+
+ObjectIdPayloadMap ObjectIdSetToPayloadMap(
+ ObjectIdSet ids, const std::string& payload) {
+ ObjectIdPayloadMap id_payloads;
+ for (ObjectIdSet::const_iterator it = ids.begin(); it != ids.end(); ++it) {
+ id_payloads[*it] = payload;
+ }
+ return id_payloads;
+}
+
ModelTypePayloadMap ObjectIdPayloadMapToModelTypePayloadMap(
const ObjectIdPayloadMap& id_payloads) {
ModelTypePayloadMap types_with_payloads;
diff --git a/sync/notifier/object_id_payload_map.h b/sync/notifier/object_id_payload_map.h
index 9205326..91a1f15 100644
--- a/sync/notifier/object_id_payload_map.h
+++ b/sync/notifier/object_id_payload_map.h
@@ -18,6 +18,11 @@ typedef std::map<invalidation::ObjectId,
std::string,
ObjectIdLessThan> ObjectIdPayloadMap;
+// Converts between ObjectIdPayloadMaps and ObjectIdSets.
+ObjectIdSet ObjectIdPayloadMapToSet(const ObjectIdPayloadMap& id_payloads);
+ObjectIdPayloadMap ObjectIdSetToPayloadMap(
+ ObjectIdSet ids, const std::string& payload);
+
// Converts between ObjectIdPayloadMaps and ModelTypePayloadMaps.
ModelTypePayloadMap ObjectIdPayloadMapToModelTypePayloadMap(
const ObjectIdPayloadMap& id_payloads);
diff --git a/sync/notifier/sync_notifier.h b/sync/notifier/sync_notifier.h
index 369ced1..48bc1f1 100644
--- a/sync/notifier/sync_notifier.h
+++ b/sync/notifier/sync_notifier.h
@@ -22,9 +22,10 @@ class SyncNotifier {
SyncNotifier() {}
virtual ~SyncNotifier() {}
- // Updates the set of ObjectIds associated with a given |handler|. Passing an
- // empty ObjectIdSet will unregister |handler|. If two different handlers
- // attempt to register for the same object ID, the first registration wins.
+ // Updates the set of ObjectIds associated with a given
+ // |handler|. Passing an empty ObjectIdSet will unregister
+ // |handler|. There should be at most one handler registered per
+ // object id.
virtual void UpdateRegisteredIds(SyncNotifierObserver* handler,
const ObjectIdSet& ids) = 0;