summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-03 21:20:54 +0000
committerrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-03 21:20:54 +0000
commitba85740ffef8b4622d7fc94c71672cc207b4365c (patch)
treedd7de7ac6903ec690e15dd9090bce3e01bf9f7c8
parentad554bcfe7ea960662f05fbd61c6aadcf71c04bf (diff)
downloadchromium_src-ba85740ffef8b4622d7fc94c71672cc207b4365c.zip
chromium_src-ba85740ffef8b4622d7fc94c71672cc207b4365c.tar.gz
chromium_src-ba85740ffef8b4622d7fc94c71672cc207b4365c.tar.bz2
sync: Remove ModelTypeInvalidationMap
Removes the definition and all uses of ModelTypeInvalidationMap. The ModelTypeInvalidationMap was useful only for sync-related invalidations. Its existence made sense when sync was the only client for invalidations. Now that we have many invalidations clients, it makes sense to replace it with the more generic ObjectIdInvalidationMap. The reason for doing this now is that the ObjectIdInvalidationMap will soon be modified to be incompatible with the current definition of ModelTypeInvalidationMap. In order to support trickles it will be modified to allow it to contain several invalidations per ObjectId. Although it would have been possible to maintain compatibility by making a corresponding modification to ModelTypeInvalidationMap, there's really no point in having two invalidation map types. In the long run, it makes more sense to deprecate ModelTypeInvalidationMap. BUG=233437 Review URL: https://chromiumcodereview.appspot.com/23238005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221025 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/sync/glue/session_change_processor.cc1
-rw-r--r--chrome/browser/sync/glue/session_model_associator.cc1
-rw-r--r--chrome/browser/sync/profile_sync_service_android.cc1
-rw-r--r--sync/engine/DEPS1
-rw-r--r--sync/engine/download.cc1
-rw-r--r--sync/engine/download_unittest.cc10
-rw-r--r--sync/engine/sync_scheduler.h4
-rw-r--r--sync/engine/sync_scheduler_impl.cc9
-rw-r--r--sync/engine/sync_scheduler_impl.h3
-rw-r--r--sync/engine/sync_scheduler_unittest.cc27
-rw-r--r--sync/internal_api/debug_info_event_listener.cc18
-rw-r--r--sync/internal_api/debug_info_event_listener.h3
-rw-r--r--sync/internal_api/public/base/DEPS1
-rw-r--r--sync/internal_api/public/base/model_type_invalidation_map.cc78
-rw-r--r--sync/internal_api/public/base/model_type_invalidation_map.h53
-rw-r--r--sync/internal_api/public/base/model_type_invalidation_map_test_util.cc114
-rw-r--r--sync/internal_api/public/base/model_type_invalidation_map_test_util.h20
-rw-r--r--sync/internal_api/public/base/model_type_invalidation_map_unittest.cc71
-rw-r--r--sync/internal_api/public/base/model_type_test_util.cc19
-rw-r--r--sync/internal_api/public/base/model_type_test_util.h9
-rw-r--r--sync/internal_api/public/engine/model_safe_worker.cc11
-rw-r--r--sync/internal_api/public/engine/model_safe_worker.h8
-rw-r--r--sync/internal_api/public/engine/model_safe_worker_unittest.cc16
-rw-r--r--sync/internal_api/sync_manager_impl.cc44
-rw-r--r--sync/internal_api/sync_manager_impl.h3
-rw-r--r--sync/internal_api/sync_manager_impl_unittest.cc11
-rw-r--r--sync/notifier/invalidation_notifier_unittest.cc1
-rw-r--r--sync/notifier/object_id_invalidation_map.cc31
-rw-r--r--sync/notifier/object_id_invalidation_map.h9
-rw-r--r--sync/notifier/object_id_invalidation_map_test_util.h1
-rw-r--r--sync/notifier/p2p_invalidator_unittest.cc21
-rw-r--r--sync/sessions/DEPS1
-rw-r--r--sync/sessions/nudge_tracker.cc18
-rw-r--r--sync/sessions/nudge_tracker.h4
-rw-r--r--sync/sessions/nudge_tracker_unittest.cc43
-rw-r--r--sync/sessions/sync_session_unittest.cc20
-rw-r--r--sync/sync.gyp5
-rw-r--r--sync/sync_internal_api.gypi2
-rw-r--r--sync/sync_tests.gypi13
-rw-r--r--sync/test/engine/fake_sync_scheduler.cc2
-rw-r--r--sync/test/engine/fake_sync_scheduler.h2
-rw-r--r--sync/test/engine/mock_connection_manager.h1
-rw-r--r--sync/tools/sync_listen_notifications.cc13
43 files changed, 159 insertions, 565 deletions
diff --git a/chrome/browser/sync/glue/session_change_processor.cc b/chrome/browser/sync/glue/session_change_processor.cc
index 92e0cfa..efc51ee 100644
--- a/chrome/browser/sync/glue/session_change_processor.cc
+++ b/chrome/browser/sync/glue/session_change_processor.cc
@@ -23,7 +23,6 @@
#include "content/public/browser/web_contents.h"
#include "sync/api/sync_error.h"
#include "sync/internal_api/public/base/model_type.h"
-#include "sync/internal_api/public/base/model_type_invalidation_map.h"
#include "sync/internal_api/public/change_record.h"
#include "sync/internal_api/public/read_node.h"
#include "sync/protocol/session_specifics.pb.h"
diff --git a/chrome/browser/sync/glue/session_model_associator.cc b/chrome/browser/sync/glue/session_model_associator.cc
index 10e8feb..d419ee8 100644
--- a/chrome/browser/sync/glue/session_model_associator.cc
+++ b/chrome/browser/sync/glue/session_model_associator.cc
@@ -41,7 +41,6 @@
#include "sync/api/sync_error.h"
#include "sync/api/time.h"
#include "sync/internal_api/public/base/model_type.h"
-#include "sync/internal_api/public/base/model_type_invalidation_map.h"
#include "sync/internal_api/public/read_node.h"
#include "sync/internal_api/public/read_transaction.h"
#include "sync/internal_api/public/write_node.h"
diff --git a/chrome/browser/sync/profile_sync_service_android.cc b/chrome/browser/sync/profile_sync_service_android.cc
index b391e89..8894c78 100644
--- a/chrome/browser/sync/profile_sync_service_android.cc
+++ b/chrome/browser/sync/profile_sync_service_android.cc
@@ -35,7 +35,6 @@
#include "google_apis/gaia/oauth2_token_service.h"
#include "grit/generated_resources.h"
#include "jni/ProfileSyncService_jni.h"
-#include "sync/internal_api/public/base/model_type_invalidation_map.h"
#include "sync/internal_api/public/read_transaction.h"
#include "ui/base/l10n/l10n_util.h"
diff --git a/sync/engine/DEPS b/sync/engine/DEPS
index 39c2a68..b43d31c 100644
--- a/sync/engine/DEPS
+++ b/sync/engine/DEPS
@@ -5,6 +5,7 @@ include_rules = [
"+sync/internal_api/public/sessions",
"+sync/internal_api/public/test",
"+sync/internal_api/public/util",
+ "+sync/notifier",
"+sync/protocol",
"+sync/sessions",
"+sync/syncable",
diff --git a/sync/engine/download.cc b/sync/engine/download.cc
index d511fc0..acda834 100644
--- a/sync/engine/download.cc
+++ b/sync/engine/download.cc
@@ -11,7 +11,6 @@
#include "sync/engine/store_timestamps_command.h"
#include "sync/engine/syncer.h"
#include "sync/engine/syncer_proto_util.h"
-#include "sync/internal_api/public/base/model_type_invalidation_map.h"
#include "sync/sessions/nudge_tracker.h"
#include "sync/syncable/directory.h"
#include "sync/syncable/nigori_handler.h"
diff --git a/sync/engine/download_unittest.cc b/sync/engine/download_unittest.cc
index 5ea5c14..6aac31d 100644
--- a/sync/engine/download_unittest.cc
+++ b/sync/engine/download_unittest.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "sync/engine/download.h"
+#include "sync/internal_api/public/base/model_type_test_util.h"
#include "sync/protocol/sync.pb.h"
#include "sync/sessions/nudge_tracker.h"
#include "sync/test/engine/fake_model_worker.h"
@@ -78,14 +79,11 @@ TEST_F(DownloadUpdatesTest, ExecuteNoStates) {
TEST_F(DownloadUpdatesTest, ExecuteWithStates) {
sessions::NudgeTracker nudge_tracker;
nudge_tracker.RecordRemoteInvalidation(
- ModelTypeSetToInvalidationMap(ModelTypeSet(AUTOFILL),
- "autofill_payload"));
+ BuildInvalidationMap(AUTOFILL, 1, "autofill_payload"));
nudge_tracker.RecordRemoteInvalidation(
- ModelTypeSetToInvalidationMap(ModelTypeSet(BOOKMARKS),
- "bookmark_payload"));
+ BuildInvalidationMap(BOOKMARKS, 1, "bookmark_payload"));
nudge_tracker.RecordRemoteInvalidation(
- ModelTypeSetToInvalidationMap(ModelTypeSet(PREFERENCES),
- "preferences_payload"));
+ BuildInvalidationMap(PREFERENCES, 1, "preferences_payload"));
ModelTypeSet notified_types;
notified_types.Put(AUTOFILL);
notified_types.Put(BOOKMARKS);
diff --git a/sync/engine/sync_scheduler.h b/sync/engine/sync_scheduler.h
index 1dd1018..923c7be 100644
--- a/sync/engine/sync_scheduler.h
+++ b/sync/engine/sync_scheduler.h
@@ -13,7 +13,7 @@
#include "base/time/time.h"
#include "sync/base/sync_export.h"
#include "sync/engine/nudge_source.h"
-#include "sync/internal_api/public/base/model_type_invalidation_map.h"
+#include "sync/notifier/object_id_invalidation_map.h"
#include "sync/sessions/sync_session.h"
namespace tracked_objects {
@@ -112,7 +112,7 @@ class SYNC_EXPORT_PRIVATE SyncScheduler
// order to fetch the update.
virtual void ScheduleInvalidationNudge(
const base::TimeDelta& desired_delay,
- const ModelTypeInvalidationMap& invalidation_map,
+ const ObjectIdInvalidationMap& invalidations,
const tracked_objects::Location& nudge_location) = 0;
// Change status of notifications in the SyncSessionContext.
diff --git a/sync/engine/sync_scheduler_impl.cc b/sync/engine/sync_scheduler_impl.cc
index e4509e4..93eb0fb 100644
--- a/sync/engine/sync_scheduler_impl.cc
+++ b/sync/engine/sync_scheduler_impl.cc
@@ -16,6 +16,7 @@
#include "base/message_loop/message_loop.h"
#include "sync/engine/backoff_delay_provider.h"
#include "sync/engine/syncer.h"
+#include "sync/notifier/object_id_invalidation_map.h"
#include "sync/protocol/proto_enum_conversions.h"
#include "sync/protocol/sync.pb.h"
#include "sync/util/data_type_histogram.h"
@@ -389,14 +390,15 @@ void SyncSchedulerImpl::ScheduleLocalRefreshRequest(
void SyncSchedulerImpl::ScheduleInvalidationNudge(
const TimeDelta& desired_delay,
- const ModelTypeInvalidationMap& invalidation_map,
+ const ObjectIdInvalidationMap& invalidation_map,
const tracked_objects::Location& nudge_location) {
DCHECK(CalledOnValidThread());
DCHECK(!invalidation_map.empty());
SDVLOG_LOC(nudge_location, 2)
<< "Scheduling sync because we received invalidation for "
- << ModelTypeInvalidationMapToString(invalidation_map);
+ << ModelTypeSetToString(ObjectIdSetToModelTypeSet(
+ ObjectIdInvalidationMapToSet(invalidation_map)));
nudge_tracker_.RecordRemoteInvalidation(invalidation_map);
ScheduleNudgeImpl(desired_delay, nudge_location);
}
@@ -552,9 +554,6 @@ void SyncSchedulerImpl::HandleFailure(
}
void SyncSchedulerImpl::DoPollSyncSessionJob() {
- ModelSafeRoutingInfo r;
- ModelTypeInvalidationMap invalidation_map =
- ModelSafeRoutingInfoToInvalidationMap(r, std::string());
base::AutoReset<bool> protector(&no_scheduling_allowed_, true);
if (!CanRunJobNow(NORMAL_PRIORITY)) {
diff --git a/sync/engine/sync_scheduler_impl.h b/sync/engine/sync_scheduler_impl.h
index f0245a9..b8dcce9 100644
--- a/sync/engine/sync_scheduler_impl.h
+++ b/sync/engine/sync_scheduler_impl.h
@@ -23,7 +23,6 @@
#include "sync/engine/nudge_source.h"
#include "sync/engine/sync_scheduler.h"
#include "sync/engine/syncer.h"
-#include "sync/internal_api/public/base/model_type_invalidation_map.h"
#include "sync/internal_api/public/engine/polling_constants.h"
#include "sync/internal_api/public/util/weak_handle.h"
#include "sync/sessions/nudge_tracker.h"
@@ -66,7 +65,7 @@ class SYNC_EXPORT_PRIVATE SyncSchedulerImpl
const tracked_objects::Location& nudge_location) OVERRIDE;
virtual void ScheduleInvalidationNudge(
const base::TimeDelta& desired_delay,
- const ModelTypeInvalidationMap& invalidation_map,
+ const ObjectIdInvalidationMap& invalidation_map,
const tracked_objects::Location& nudge_location) OVERRIDE;
virtual void SetNotificationsEnabled(bool notifications_enabled) OVERRIDE;
diff --git a/sync/engine/sync_scheduler_unittest.cc b/sync/engine/sync_scheduler_unittest.cc
index f76e1c5..e0ea9a8 100644
--- a/sync/engine/sync_scheduler_unittest.cc
+++ b/sync/engine/sync_scheduler_unittest.cc
@@ -11,6 +11,9 @@
#include "sync/engine/backoff_delay_provider.h"
#include "sync/engine/sync_scheduler_impl.h"
#include "sync/engine/syncer.h"
+#include "sync/internal_api/public/base/model_type_test_util.h"
+#include "sync/notifier/invalidation_util.h"
+#include "sync/notifier/object_id_invalidation_map.h"
#include "sync/sessions/test_util.h"
#include "sync/test/callback_counter.h"
#include "sync/test/engine/fake_model_worker.h"
@@ -450,28 +453,26 @@ TEST_F(SyncSchedulerTest, NudgeCoalescingWithDifferentTimings) {
TEST_F(SyncSchedulerTest, NudgeWithStates) {
StartSyncScheduler(SyncScheduler::NORMAL_MODE);
- SyncShareTimes times;
- const ModelTypeSet types(BOOKMARKS);
- ModelTypeInvalidationMap invalidation_map =
- ModelTypeSetToInvalidationMap(types, "test");
-
+ SyncShareTimes times1;
+ ObjectIdInvalidationMap invalidations1 =
+ BuildInvalidationMap(BOOKMARKS, 10, "test");
EXPECT_CALL(*syncer(), NormalSyncShare(_,_,_))
.WillOnce(DoAll(Invoke(sessions::test_util::SimulateNormalSuccess),
- RecordSyncShare(&times)))
+ RecordSyncShare(&times1)))
.RetiresOnSaturation();
- scheduler()->ScheduleInvalidationNudge(zero(), invalidation_map, FROM_HERE);
+ scheduler()->ScheduleInvalidationNudge(zero(), invalidations1, FROM_HERE);
RunLoop();
Mock::VerifyAndClearExpectations(syncer());
// Make sure a second, later, nudge is unaffected by first (no coalescing).
SyncShareTimes times2;
- invalidation_map.erase(BOOKMARKS);
- invalidation_map[AUTOFILL].payload = "test2";
+ ObjectIdInvalidationMap invalidations2 =
+ BuildInvalidationMap(AUTOFILL, 10, "test2");
EXPECT_CALL(*syncer(), NormalSyncShare(_,_,_))
.WillOnce(DoAll(Invoke(sessions::test_util::SimulateNormalSuccess),
RecordSyncShare(&times2)));
- scheduler()->ScheduleInvalidationNudge(zero(), invalidation_map, FROM_HERE);
+ scheduler()->ScheduleInvalidationNudge(zero(), invalidations2, FROM_HERE);
RunLoop();
}
@@ -749,9 +750,9 @@ TEST_F(SyncSchedulerTest, TypeThrottlingDoesBlockOtherSources) {
EXPECT_TRUE(GetThrottledTypes().HasAll(throttled_types));
// Ignore invalidations for throttled types.
- ModelTypeInvalidationMap invalidation_map =
- ModelTypeSetToInvalidationMap(throttled_types, "test");
- scheduler()->ScheduleInvalidationNudge(zero(), invalidation_map, FROM_HERE);
+ ObjectIdInvalidationMap invalidations =
+ BuildInvalidationMap(BOOKMARKS, 10, "test");
+ scheduler()->ScheduleInvalidationNudge(zero(), invalidations, FROM_HERE);
PumpLoop();
// Ignore refresh requests for throttled types.
diff --git a/sync/internal_api/debug_info_event_listener.cc b/sync/internal_api/debug_info_event_listener.cc
index 66953d4..64bbab8 100644
--- a/sync/internal_api/debug_info_event_listener.cc
+++ b/sync/internal_api/debug_info_event_listener.cc
@@ -4,6 +4,7 @@
#include "sync/internal_api/debug_info_event_listener.h"
+#include "sync/notifier/object_id_invalidation_map.h"
#include "sync/util/cryptographer.h"
namespace syncer {
@@ -134,14 +135,19 @@ void DebugInfoEventListener::OnNudgeFromDatatype(ModelType datatype) {
}
void DebugInfoEventListener::OnIncomingNotification(
- const ModelTypeInvalidationMap& invalidation_map) {
+ const ObjectIdInvalidationMap& invalidations) {
DCHECK(thread_checker_.CalledOnValidThread());
sync_pb::DebugEventInfo event_info;
- ModelTypeSet types = ModelTypeInvalidationMapToSet(invalidation_map);
-
- for (ModelTypeSet::Iterator it = types.First(); it.Good(); it.Inc()) {
- event_info.add_datatypes_notified_from_server(
- GetSpecificsFieldNumberFromModelType(it.Get()));
+ ModelTypeSet types = ObjectIdSetToModelTypeSet(ObjectIdInvalidationMapToSet(
+ invalidations));
+
+ for (ObjectIdInvalidationMap::const_iterator it = invalidations.begin();
+ it != invalidations.end(); ++it) {
+ ModelType type = UNSPECIFIED;
+ if (ObjectIdToRealModelType(it->first, &type)) {
+ event_info.add_datatypes_notified_from_server(
+ GetSpecificsFieldNumberFromModelType(type));
+ }
}
AddEventToQueue(event_info);
diff --git a/sync/internal_api/debug_info_event_listener.h b/sync/internal_api/debug_info_event_listener.h
index a3c15eb..022fafb 100644
--- a/sync/internal_api/debug_info_event_listener.h
+++ b/sync/internal_api/debug_info_event_listener.h
@@ -71,8 +71,7 @@ class SYNC_EXPORT_PRIVATE DebugInfoEventListener
// Sync manager events.
void OnNudgeFromDatatype(ModelType datatype);
- void OnIncomingNotification(
- const ModelTypeInvalidationMap& invalidation_map);
+ void OnIncomingNotification(const ObjectIdInvalidationMap& invalidations);
// DebugInfoGetter implementation.
virtual void GetAndClearDebugInfo(sync_pb::DebugInfo* debug_info) OVERRIDE;
diff --git a/sync/internal_api/public/base/DEPS b/sync/internal_api/public/base/DEPS
index 29a82b7..6eae52a 100644
--- a/sync/internal_api/public/base/DEPS
+++ b/sync/internal_api/public/base/DEPS
@@ -3,4 +3,5 @@ include_rules = [
"+sync/base",
"+sync/internal_api/public/base",
"+sync/protocol",
+ "+sync/notifier"
]
diff --git a/sync/internal_api/public/base/model_type_invalidation_map.cc b/sync/internal_api/public/base/model_type_invalidation_map.cc
deleted file mode 100644
index 7ced0ff..0000000
--- a/sync/internal_api/public/base/model_type_invalidation_map.cc
+++ /dev/null
@@ -1,78 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "sync/internal_api/public/base/model_type_invalidation_map.h"
-
-#include <vector>
-
-#include "base/json/json_writer.h"
-#include "base/json/string_escape.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/values.h"
-
-namespace syncer {
-
-ModelTypeInvalidationMap ModelTypeSetToInvalidationMap(
- ModelTypeSet types, const std::string& payload) {
- ModelTypeInvalidationMap invalidation_map;
- for (ModelTypeSet::Iterator it = types.First(); it.Good(); it.Inc()) {
- // TODO(dcheng): Do we need to set ack_handle?
- invalidation_map[it.Get()].payload = payload;
- }
- return invalidation_map;
-}
-
-ModelTypeSet ModelTypeInvalidationMapToSet(
- const ModelTypeInvalidationMap& invalidation_map) {
- ModelTypeSet types;
- for (ModelTypeInvalidationMap::const_iterator it = invalidation_map.begin();
- it != invalidation_map.end(); ++it) {
- types.Put(it->first);
- }
- return types;
-}
-
-std::string ModelTypeInvalidationMapToString(
- const ModelTypeInvalidationMap& invalidation_map) {
- scoped_ptr<base::DictionaryValue> value(
- ModelTypeInvalidationMapToValue(invalidation_map));
- std::string json;
- base::JSONWriter::Write(value.get(), &json);
- return json;
-}
-
-base::DictionaryValue* ModelTypeInvalidationMapToValue(
- const ModelTypeInvalidationMap& invalidation_map) {
- base::DictionaryValue* value = new base::DictionaryValue();
- for (ModelTypeInvalidationMap::const_iterator it = invalidation_map.begin();
- it != invalidation_map.end(); ++it) {
- std::string printable_payload;
- base::JsonDoubleQuote(it->second.payload,
- false /* put_in_quotes */,
- &printable_payload);
- value->SetString(ModelTypeToString(it->first), printable_payload);
- }
- return value;
-}
-
-void CoalesceStates(const ModelTypeInvalidationMap& update,
- ModelTypeInvalidationMap* original) {
- // TODO(dcheng): Where is this called? Do we need to add more clever logic for
- // handling ack_handle? We probably want to always use the "latest"
- // ack_handle, which might imply always using the one in update?
- for (ModelTypeInvalidationMap::const_iterator i = update.begin();
- i != update.end(); ++i) {
- if (original->count(i->first) == 0) {
- // If this datatype isn't already in our map, add it with
- // whatever payload it has.
- (*original)[i->first] = i->second;
- } else if (i->second.payload.length() > 0) {
- // If this datatype is already in our map, we only overwrite the
- // payload if the new one is non-empty.
- (*original)[i->first].payload = i->second.payload;
- }
- }
-}
-
-} // namespace syncer
diff --git a/sync/internal_api/public/base/model_type_invalidation_map.h b/sync/internal_api/public/base/model_type_invalidation_map.h
deleted file mode 100644
index 462e17e..0000000
--- a/sync/internal_api/public/base/model_type_invalidation_map.h
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-// Definition of ModelTypeInvalidationMap and various utility functions.
-
-#ifndef SYNC_INTERNAL_PUBLIC_API_BASE_MODEL_TYPE_INVALIDATION_MAP_H_
-#define SYNC_INTERNAL_PUBLIC_API_BASE_MODEL_TYPE_INVALIDATION_MAP_H_
-
-#include <map>
-#include <string>
-
-#include "sync/base/sync_export.h"
-#include "sync/internal_api/public/base/invalidation.h"
-#include "sync/internal_api/public/base/model_type.h"
-
-// TODO(akalin): Move the non-exported functions in this file to a
-// private header.
-
-namespace base {
-class DictionaryValue;
-}
-
-namespace syncer {
-
-// A map between sync data types and their associated invalidation.
-typedef std::map<ModelType, Invalidation> ModelTypeInvalidationMap;
-
-// Helper functions for building ModelTypeInvalidationMaps.
-
-// Make a ModelTypeInvalidationMap from all the types in a ModelTypeSet using a
-// default payload.
-SYNC_EXPORT ModelTypeInvalidationMap ModelTypeSetToInvalidationMap(
- ModelTypeSet model_types, const std::string& payload);
-
-SYNC_EXPORT_PRIVATE ModelTypeSet ModelTypeInvalidationMapToSet(
- const ModelTypeInvalidationMap& invalidation_map);
-
-std::string ModelTypeInvalidationMapToString(
- const ModelTypeInvalidationMap& invalidation_map);
-
-// Caller takes ownership of the returned dictionary.
-SYNC_EXPORT_PRIVATE base::DictionaryValue* ModelTypeInvalidationMapToValue(
- const ModelTypeInvalidationMap& invalidation_map);
-
-// Coalesce |update| into |original|, overwriting only when |update| has
-// a non-empty payload.
-SYNC_EXPORT_PRIVATE void CoalesceStates(
- const ModelTypeInvalidationMap& update, ModelTypeInvalidationMap* original);
-
-} // namespace syncer
-
-#endif // SYNC_INTERNAL_PUBLIC_API_BASE_MODEL_TYPE_INVALIDATION_MAP_H_
diff --git a/sync/internal_api/public/base/model_type_invalidation_map_test_util.cc b/sync/internal_api/public/base/model_type_invalidation_map_test_util.cc
deleted file mode 100644
index 991a6e1..0000000
--- a/sync/internal_api/public/base/model_type_invalidation_map_test_util.cc
+++ /dev/null
@@ -1,114 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "sync/internal_api/public/base/model_type_invalidation_map_test_util.h"
-
-#include <algorithm>
-
-#include "base/basictypes.h"
-#include "sync/internal_api/public/base/model_type_test_util.h"
-
-namespace syncer {
-
-using ::testing::MakeMatcher;
-using ::testing::MatchResultListener;
-using ::testing::Matcher;
-using ::testing::MatcherInterface;
-using ::testing::PrintToString;
-
-namespace {
-
-class ModelTypeInvalidationMapEqMatcher
- : public MatcherInterface<const ModelTypeInvalidationMap&> {
- public:
- explicit ModelTypeInvalidationMapEqMatcher(
- const ModelTypeInvalidationMap& expected);
-
- virtual bool MatchAndExplain(const ModelTypeInvalidationMap& lhs,
- MatchResultListener* listener) const;
- virtual void DescribeTo(::std::ostream* os) const;
- virtual void DescribeNegationTo(::std::ostream* os) const;
-
- private:
- const ModelTypeInvalidationMap expected_;
-
- DISALLOW_COPY_AND_ASSIGN(ModelTypeInvalidationMapEqMatcher);
-};
-
-ModelTypeInvalidationMapEqMatcher::ModelTypeInvalidationMapEqMatcher(
- const ModelTypeInvalidationMap& expected) : expected_(expected) {
-}
-
-bool ModelTypeInvalidationMapEqMatcher::MatchAndExplain(
- const ModelTypeInvalidationMap& actual,
- MatchResultListener* listener) const {
- ModelTypeInvalidationMap expected_only;
- ModelTypeInvalidationMap actual_only;
- typedef std::pair<ModelType, std::pair<Invalidation, Invalidation> >
- ValueDifference;
- std::vector<ValueDifference> value_differences;
-
- std::set_difference(expected_.begin(), expected_.end(),
- actual.begin(), actual.end(),
- std::inserter(expected_only, expected_only.begin()),
- expected_.value_comp());
- std::set_difference(actual.begin(), actual.end(),
- expected_.begin(), expected_.end(),
- std::inserter(actual_only, actual_only.begin()),
- actual.value_comp());
-
- for (ModelTypeInvalidationMap::const_iterator it = expected_.begin();
- it != expected_.end(); ++it) {
- ModelTypeInvalidationMap::const_iterator find_it =
- actual.find(it->first);
- if (find_it != actual.end() &&
- !Matches(Eq(it->second))(find_it->second)) {
- value_differences.push_back(std::make_pair(
- it->first, std::make_pair(it->second, find_it->second)));
- }
- }
-
- if (expected_only.empty() && actual_only.empty() && value_differences.empty())
- return true;
-
- bool printed_header = false;
- if (!actual_only.empty()) {
- *listener << " which has these unexpected elements: "
- << PrintToString(actual_only);
- printed_header = true;
- }
-
- if (!expected_only.empty()) {
- *listener << (printed_header ? ",\nand" : "which")
- << " doesn't have these expected elements: "
- << PrintToString(expected_only);
- printed_header = true;
- }
-
- if (!value_differences.empty()) {
- *listener << (printed_header ? ",\nand" : "which")
- << " differ in the following values: "
- << PrintToString(value_differences);
- }
-
- return false;
-}
-
-void ModelTypeInvalidationMapEqMatcher::DescribeTo(::std::ostream* os) const {
- *os << " is equal to " << PrintToString(expected_);
-}
-
-void ModelTypeInvalidationMapEqMatcher::DescribeNegationTo(
- ::std::ostream* os) const {
- *os << " isn't equal to " << PrintToString(expected_);
-}
-
-} // namespace
-
-Matcher<const ModelTypeInvalidationMap&> Eq(
- const ModelTypeInvalidationMap& expected) {
- return MakeMatcher(new ModelTypeInvalidationMapEqMatcher(expected));
-}
-
-} // namespace syncer
diff --git a/sync/internal_api/public/base/model_type_invalidation_map_test_util.h b/sync/internal_api/public/base/model_type_invalidation_map_test_util.h
deleted file mode 100644
index 20a2819..0000000
--- a/sync/internal_api/public/base/model_type_invalidation_map_test_util.h
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef SYNC_INTERNAL_API_PUBLIC_BASE_MODEL_TYPE_STATE_MAP_TEST_UTIL_H_
-#define SYNC_INTERNAL_API_PUBLIC_BASE_MODEL_TYPE_STATE_MAP_TEST_UTIL_H_
-
-// Convince googletest to use the correct overload for PrintTo().
-#include "sync/internal_api/public/base/invalidation_test_util.h"
-#include "sync/internal_api/public/base/model_type_invalidation_map.h"
-#include "testing/gmock/include/gmock/gmock.h"
-
-namespace syncer {
-
-::testing::Matcher<const ModelTypeInvalidationMap&> Eq(
- const ModelTypeInvalidationMap& expected);
-
-} // namespace syncer
-
-#endif // SYNC_INTERNAL_API_PUBLIC_BASE_MODEL_TYPE_STATE_MAP_TEST_UTIL_H_
diff --git a/sync/internal_api/public/base/model_type_invalidation_map_unittest.cc b/sync/internal_api/public/base/model_type_invalidation_map_unittest.cc
deleted file mode 100644
index 016e167..0000000
--- a/sync/internal_api/public/base/model_type_invalidation_map_unittest.cc
+++ /dev/null
@@ -1,71 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "sync/internal_api/public/base/model_type_invalidation_map.h"
-
-#include <string>
-
-#include "base/memory/scoped_ptr.h"
-#include "base/test/values_test_util.h"
-#include "base/values.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace syncer {
-namespace {
-
-using base::ExpectDictStringValue;
-
-class ModelTypeInvalidationMapTest : public testing::Test {};
-
-TEST_F(ModelTypeInvalidationMapTest, TypeInvalidationMapToSet) {
- ModelTypeInvalidationMap states;
- states[BOOKMARKS].payload = "bookmarkpayload";
- states[APPS].payload = "";
-
- const ModelTypeSet types(BOOKMARKS, APPS);
- EXPECT_TRUE(ModelTypeInvalidationMapToSet(states).Equals(types));
-}
-
-TEST_F(ModelTypeInvalidationMapTest, TypeInvalidationMapToValue) {
- ModelTypeInvalidationMap states;
- states[BOOKMARKS].payload = "bookmarkpayload";
- states[APPS].payload = "";
-
- scoped_ptr<base::DictionaryValue> value(
- ModelTypeInvalidationMapToValue(states));
- EXPECT_EQ(2u, value->size());
- ExpectDictStringValue(states[BOOKMARKS].payload, *value, "Bookmarks");
- ExpectDictStringValue(std::string(), *value, "Apps");
- EXPECT_FALSE(value->HasKey("Preferences"));
-}
-
-TEST_F(ModelTypeInvalidationMapTest, CoalesceStates) {
- ModelTypeInvalidationMap original;
- std::string empty_payload;
- std::string payload1 = "payload1";
- std::string payload2 = "payload2";
- std::string payload3 = "payload3";
- original[BOOKMARKS].payload = empty_payload;
- original[PASSWORDS].payload = payload1;
- original[AUTOFILL].payload = payload2;
- original[THEMES].payload = payload3;
-
- ModelTypeInvalidationMap update;
- update[BOOKMARKS].payload = empty_payload; // Same.
- update[PASSWORDS].payload = empty_payload; // Overwrite with empty.
- update[AUTOFILL].payload = payload1; // Overwrite with non-empty.
- update[SESSIONS].payload = payload2; // New.
- // Themes untouched.
-
- CoalesceStates(update, &original);
- ASSERT_EQ(5U, original.size());
- EXPECT_EQ(empty_payload, original[BOOKMARKS].payload);
- EXPECT_EQ(payload1, original[PASSWORDS].payload);
- EXPECT_EQ(payload1, original[AUTOFILL].payload);
- EXPECT_EQ(payload2, original[SESSIONS].payload);
- EXPECT_EQ(payload3, original[THEMES].payload);
-}
-
-} // namespace
-} // namespace syncer
diff --git a/sync/internal_api/public/base/model_type_test_util.cc b/sync/internal_api/public/base/model_type_test_util.cc
index 8c1164b..242b398 100644
--- a/sync/internal_api/public/base/model_type_test_util.cc
+++ b/sync/internal_api/public/base/model_type_test_util.cc
@@ -6,6 +6,25 @@
namespace syncer {
+ObjectIdInvalidationMap BuildInvalidationMap(
+ ModelType type,
+ int version,
+ const std::string& payload) {
+ ObjectIdInvalidationMap map;
+ invalidation::ObjectId id;
+ Invalidation invalidation;
+
+ bool result = RealModelTypeToObjectId(type, &id);
+ DCHECK(result)
+ << "Conversion of model type to object id failed: "
+ << ModelTypeToString(type);
+ invalidation.version = version;
+ invalidation.payload = payload;
+
+ map.insert(std::make_pair(id, invalidation));
+ return map;
+}
+
void PrintTo(ModelTypeSet model_types, ::std::ostream* os) {
*os << ModelTypeSetToString(model_types);
}
diff --git a/sync/internal_api/public/base/model_type_test_util.h b/sync/internal_api/public/base/model_type_test_util.h
index cd347cb..c724bf5 100644
--- a/sync/internal_api/public/base/model_type_test_util.h
+++ b/sync/internal_api/public/base/model_type_test_util.h
@@ -8,10 +8,19 @@
#include <ostream>
#include "sync/internal_api/public/base/model_type.h"
+#include "sync/notifier/object_id_invalidation_map.h"
#include "testing/gmock/include/gmock/gmock.h"
namespace syncer {
+// Builds an invaliation map that contains a single invalidation with specified
+// type, version, and payload. The type will be converted from a ModelType to
+// and ObjectId.
+ObjectIdInvalidationMap BuildInvalidationMap(
+ ModelType type,
+ int version,
+ const std::string& payload);
+
// Defined for googletest. Forwards to ModelTypeSetToString().
void PrintTo(ModelTypeSet model_types, ::std::ostream* os);
diff --git a/sync/internal_api/public/engine/model_safe_worker.cc b/sync/internal_api/public/engine/model_safe_worker.cc
index 5c91715..eb3fc1f 100644
--- a/sync/internal_api/public/engine/model_safe_worker.cc
+++ b/sync/internal_api/public/engine/model_safe_worker.cc
@@ -31,17 +31,6 @@ std::string ModelSafeRoutingInfoToString(
return json;
}
-ModelTypeInvalidationMap ModelSafeRoutingInfoToInvalidationMap(
- const ModelSafeRoutingInfo& routes,
- const std::string& payload) {
- ModelTypeInvalidationMap invalidation_map;
- for (ModelSafeRoutingInfo::const_iterator i = routes.begin();
- i != routes.end(); ++i) {
- invalidation_map[i->first].payload = payload;
- }
- return invalidation_map;
-}
-
ModelTypeSet GetRoutingInfoTypes(const ModelSafeRoutingInfo& routing_info) {
ModelTypeSet types;
for (ModelSafeRoutingInfo::const_iterator it = routing_info.begin();
diff --git a/sync/internal_api/public/engine/model_safe_worker.h b/sync/internal_api/public/engine/model_safe_worker.h
index 0f41594..75f0345 100644
--- a/sync/internal_api/public/engine/model_safe_worker.h
+++ b/sync/internal_api/public/engine/model_safe_worker.h
@@ -16,7 +16,6 @@
#include "base/synchronization/waitable_event.h"
#include "sync/base/sync_export.h"
#include "sync/internal_api/public/base/model_type.h"
-#include "sync/internal_api/public/base/model_type_invalidation_map.h"
#include "sync/internal_api/public/util/syncer_error.h"
namespace base {
@@ -149,13 +148,6 @@ SYNC_EXPORT_PRIVATE base::DictionaryValue* ModelSafeRoutingInfoToValue(
SYNC_EXPORT std::string ModelSafeRoutingInfoToString(
const ModelSafeRoutingInfo& routing_info);
-// Make a ModelTypeInvalidationMap for all the enabled types in a
-// ModelSafeRoutingInfo using a default payload.
-SYNC_EXPORT_PRIVATE ModelTypeInvalidationMap
- ModelSafeRoutingInfoToInvalidationMap(
- const ModelSafeRoutingInfo& routes,
- const std::string& payload);
-
SYNC_EXPORT ModelTypeSet GetRoutingInfoTypes(
const ModelSafeRoutingInfo& routing_info);
diff --git a/sync/internal_api/public/engine/model_safe_worker_unittest.cc b/sync/internal_api/public/engine/model_safe_worker_unittest.cc
index acddb7a7..f2e8c0e 100644
--- a/sync/internal_api/public/engine/model_safe_worker_unittest.cc
+++ b/sync/internal_api/public/engine/model_safe_worker_unittest.cc
@@ -48,21 +48,5 @@ TEST_F(ModelSafeWorkerTest, GetRoutingInfoTypes) {
EXPECT_TRUE(GetRoutingInfoTypes(routing_info).Equals(expected_types));
}
-TEST_F(ModelSafeWorkerTest, ModelSafeRoutingInfoToInvalidationMap) {
- std::string payload = "test";
- ModelSafeRoutingInfo routing_info;
- routing_info[BOOKMARKS] = GROUP_PASSIVE;
- routing_info[NIGORI] = GROUP_UI;
- routing_info[PREFERENCES] = GROUP_DB;
- ModelTypeInvalidationMap invalidation_map =
- ModelSafeRoutingInfoToInvalidationMap(routing_info, payload);
- ASSERT_EQ(routing_info.size(), invalidation_map.size());
- for (ModelSafeRoutingInfo::iterator iter = routing_info.begin();
- iter != routing_info.end();
- ++iter) {
- EXPECT_EQ(payload, invalidation_map[iter->first].payload);
- }
-}
-
} // namespace
} // namespace syncer
diff --git a/sync/internal_api/sync_manager_impl.cc b/sync/internal_api/sync_manager_impl.cc
index a541032..091ed28 100644
--- a/sync/internal_api/sync_manager_impl.cc
+++ b/sync/internal_api/sync_manager_impl.cc
@@ -20,7 +20,6 @@
#include "sync/engine/syncer_types.h"
#include "sync/internal_api/change_reorder_buffer.h"
#include "sync/internal_api/public/base/model_type.h"
-#include "sync/internal_api/public/base/model_type_invalidation_map.h"
#include "sync/internal_api/public/base_node.h"
#include "sync/internal_api/public/configure_reason.h"
#include "sync/internal_api/public/engine/polling_constants.h"
@@ -1152,12 +1151,15 @@ JsArgList SyncManagerImpl::GetChildNodeIds(const JsArgList& args) {
}
void SyncManagerImpl::UpdateNotificationInfo(
- const ModelTypeInvalidationMap& invalidation_map) {
- for (ModelTypeInvalidationMap::const_iterator it = invalidation_map.begin();
+ const ObjectIdInvalidationMap& invalidation_map) {
+ for (ObjectIdInvalidationMap::const_iterator it = invalidation_map.begin();
it != invalidation_map.end(); ++it) {
- NotificationInfo* info = &notification_info_map_[it->first];
- info->total_count++;
- info->payload = it->second.payload;
+ ModelType type = UNSPECIFIED;
+ if (ObjectIdToRealModelType(it->first, &type)) {
+ NotificationInfo* info = &notification_info_map_[type];
+ info->total_count++;
+ info->payload = it->second.payload;
+ }
}
}
@@ -1186,29 +1188,37 @@ void SyncManagerImpl::OnIncomingInvalidation(
const ObjectIdInvalidationMap& invalidation_map) {
DCHECK(thread_checker_.CalledOnValidThread());
- const ModelTypeInvalidationMap& type_invalidation_map =
- ObjectIdInvalidationMapToModelTypeInvalidationMap(invalidation_map);
- if (type_invalidation_map.empty()) {
+ // We should never receive IDs from non-sync objects.
+ ObjectIdSet ids = ObjectIdInvalidationMapToSet(invalidation_map);
+ for (ObjectIdSet::const_iterator it = ids.begin(); it != ids.end(); ++it) {
+ ModelType type;
+ if (!ObjectIdToRealModelType(*it, &type)) {
+ DLOG(WARNING) << "Notification has invalid id: " << ObjectIdToString(*it);
+ }
+ }
+
+ if (invalidation_map.empty()) {
LOG(WARNING) << "Sync received invalidation without any type information.";
} else {
allstatus_.IncrementNudgeCounter(NUDGE_SOURCE_NOTIFICATION);
scheduler_->ScheduleInvalidationNudge(
TimeDelta::FromMilliseconds(kSyncSchedulerDelayMsec),
- type_invalidation_map, FROM_HERE);
+ invalidation_map, FROM_HERE);
allstatus_.IncrementNotificationsReceived();
- UpdateNotificationInfo(type_invalidation_map);
- debug_info_event_listener_.OnIncomingNotification(type_invalidation_map);
+ UpdateNotificationInfo(invalidation_map);
+ debug_info_event_listener_.OnIncomingNotification(invalidation_map);
}
if (js_event_handler_.IsInitialized()) {
base::DictionaryValue details;
base::ListValue* changed_types = new base::ListValue();
details.Set("changedTypes", changed_types);
- for (ModelTypeInvalidationMap::const_iterator it =
- type_invalidation_map.begin(); it != type_invalidation_map.end();
- ++it) {
- const std::string& model_type_str =
- ModelTypeToString(it->first);
+ ObjectIdSet id_set = ObjectIdInvalidationMapToSet(invalidation_map);
+ ModelTypeSet nudged_types = ObjectIdSetToModelTypeSet(id_set);
+ DCHECK(!nudged_types.Empty());
+ for (ModelTypeSet::Iterator it = nudged_types.First();
+ it.Good(); it.Inc()) {
+ const std::string model_type_str = ModelTypeToString(it.Get());
changed_types->Append(new base::StringValue(model_type_str));
}
details.SetString("source", "REMOTE_INVALIDATION");
diff --git a/sync/internal_api/sync_manager_impl.h b/sync/internal_api/sync_manager_impl.h
index 712c268..03d6636 100644
--- a/sync/internal_api/sync_manager_impl.h
+++ b/sync/internal_api/sync_manager_impl.h
@@ -251,8 +251,7 @@ class SYNC_EXPORT_PRIVATE SyncManagerImpl :
// Called for every notification. This updates the notification statistics
// to be displayed in about:sync.
- void UpdateNotificationInfo(
- const ModelTypeInvalidationMap& invalidation_map);
+ void UpdateNotificationInfo(const ObjectIdInvalidationMap& invalidation_map);
// Checks for server reachabilty and requests a nudge.
void OnNetworkConnectivityChangedImpl();
diff --git a/sync/internal_api/sync_manager_impl_unittest.cc b/sync/internal_api/sync_manager_impl_unittest.cc
index 06bc783..06e65e2 100644
--- a/sync/internal_api/sync_manager_impl_unittest.cc
+++ b/sync/internal_api/sync_manager_impl_unittest.cc
@@ -982,11 +982,12 @@ class SyncManagerTest : public testing::Test,
void TriggerOnIncomingNotificationForTest(ModelTypeSet model_types) {
DCHECK(sync_manager_.thread_checker_.CalledOnValidThread());
- ModelTypeInvalidationMap invalidation_map =
- ModelTypeSetToInvalidationMap(model_types, std::string());
- sync_manager_.OnIncomingInvalidation(
- ModelTypeInvalidationMapToObjectIdInvalidationMap(
- invalidation_map));
+ ObjectIdSet id_set = ModelTypeSetToObjectIdSet(model_types);
+ ObjectIdInvalidationMap invalidation_map =
+ ObjectIdSetToInvalidationMap(id_set,
+ Invalidation::kUnknownVersion,
+ std::string());
+ sync_manager_.OnIncomingInvalidation(invalidation_map);
}
void SetProgressMarkerForType(ModelType type, bool set) {
diff --git a/sync/notifier/invalidation_notifier_unittest.cc b/sync/notifier/invalidation_notifier_unittest.cc
index 9604929..623bfa9 100644
--- a/sync/notifier/invalidation_notifier_unittest.cc
+++ b/sync/notifier/invalidation_notifier_unittest.cc
@@ -11,7 +11,6 @@
#include "jingle/notifier/listener/fake_push_client.h"
#include "net/url_request/url_request_test_util.h"
#include "sync/internal_api/public/base/model_type.h"
-#include "sync/internal_api/public/base/model_type_invalidation_map.h"
#include "sync/internal_api/public/util/weak_handle.h"
#include "sync/notifier/fake_invalidation_handler.h"
#include "sync/notifier/fake_invalidation_state_tracker.h"
diff --git a/sync/notifier/object_id_invalidation_map.cc b/sync/notifier/object_id_invalidation_map.cc
index 3dc7514..bde2e4c 100644
--- a/sync/notifier/object_id_invalidation_map.cc
+++ b/sync/notifier/object_id_invalidation_map.cc
@@ -90,35 +90,4 @@ bool ObjectIdInvalidationMapFromValue(const base::ListValue& value,
return true;
}
-ModelTypeInvalidationMap ObjectIdInvalidationMapToModelTypeInvalidationMap(
- const ObjectIdInvalidationMap& invalidation_map) {
- ModelTypeInvalidationMap type_invalidation_map;
- for (ObjectIdInvalidationMap::const_iterator it = invalidation_map.begin();
- it != invalidation_map.end(); ++it) {
- ModelType model_type;
- if (!ObjectIdToRealModelType(it->first, &model_type)) {
- DLOG(WARNING) << "Invalid object ID: "
- << ObjectIdToString(it->first);
- continue;
- }
- type_invalidation_map[model_type] = it->second;
- }
- return type_invalidation_map;
-}
-
-ObjectIdInvalidationMap ModelTypeInvalidationMapToObjectIdInvalidationMap(
- const ModelTypeInvalidationMap& invalidation_map) {
- ObjectIdInvalidationMap id_invalidation_map;
- for (ModelTypeInvalidationMap::const_iterator it = invalidation_map.begin();
- it != invalidation_map.end(); ++it) {
- invalidation::ObjectId id;
- if (!RealModelTypeToObjectId(it->first, &id)) {
- DLOG(WARNING) << "Invalid model type " << it->first;
- continue;
- }
- id_invalidation_map[id] = it->second;
- }
- return id_invalidation_map;
-}
-
} // namespace syncer
diff --git a/sync/notifier/object_id_invalidation_map.h b/sync/notifier/object_id_invalidation_map.h
index 0a6a95e..bb97fb3 100644
--- a/sync/notifier/object_id_invalidation_map.h
+++ b/sync/notifier/object_id_invalidation_map.h
@@ -13,7 +13,6 @@
#include "google/cacheinvalidation/include/types.h"
#include "sync/base/sync_export.h"
#include "sync/internal_api/public/base/invalidation.h"
-#include "sync/internal_api/public/base/model_type_invalidation_map.h"
#include "sync/notifier/invalidation_util.h"
namespace base {
@@ -42,14 +41,6 @@ scoped_ptr<base::ListValue> ObjectIdInvalidationMapToValue(
bool ObjectIdInvalidationMapFromValue(const base::ListValue& value,
ObjectIdInvalidationMap* out);
-// Converts between ObjectIdInvalidationMaps and ModelTypeInvalidationMaps.
-SYNC_EXPORT_PRIVATE ModelTypeInvalidationMap
- ObjectIdInvalidationMapToModelTypeInvalidationMap(
- const ObjectIdInvalidationMap& invalidation_map);
-SYNC_EXPORT ObjectIdInvalidationMap
- ModelTypeInvalidationMapToObjectIdInvalidationMap(
- const ModelTypeInvalidationMap& invalidation_map);
-
} // namespace syncer
#endif // SYNC_NOTIFIER_OBJECT_ID_INVALIDATION_MAP_H_
diff --git a/sync/notifier/object_id_invalidation_map_test_util.h b/sync/notifier/object_id_invalidation_map_test_util.h
index 47d03e9..0217da8 100644
--- a/sync/notifier/object_id_invalidation_map_test_util.h
+++ b/sync/notifier/object_id_invalidation_map_test_util.h
@@ -7,6 +7,7 @@
// Convince googletest to use the correct overload for PrintTo().
#include "sync/internal_api/public/base/invalidation_test_util.h"
+#include "sync/internal_api/public/base/model_type.h"
#include "sync/notifier/object_id_invalidation_map.h"
#include "testing/gmock/include/gmock/gmock.h"
diff --git a/sync/notifier/p2p_invalidator_unittest.cc b/sync/notifier/p2p_invalidator_unittest.cc
index be9ee3f..24cfe02 100644
--- a/sync/notifier/p2p_invalidator_unittest.cc
+++ b/sync/notifier/p2p_invalidator_unittest.cc
@@ -8,7 +8,6 @@
#include "jingle/notifier/listener/fake_push_client.h"
#include "sync/internal_api/public/base/model_type.h"
-#include "sync/internal_api/public/base/model_type_invalidation_map.h"
#include "sync/notifier/fake_invalidation_handler.h"
#include "sync/notifier/invalidator_test_template.h"
#include "sync/notifier/object_id_invalidation_map_test_util.h"
@@ -96,8 +95,12 @@ class P2PInvalidatorTest : public testing::Test {
delegate_.GetInvalidator()->UnregisterHandler(&fake_handler_);
}
- ModelTypeInvalidationMap MakeInvalidationMap(ModelTypeSet types) {
- return ModelTypeSetToInvalidationMap(types, std::string());
+ ObjectIdInvalidationMap MakeInvalidationMap(ModelTypeSet types) {
+ ObjectIdInvalidationMap invalidations;
+ ObjectIdSet ids = ModelTypeSetToObjectIdSet(types);
+ return ObjectIdSetToInvalidationMap(ids,
+ Invalidation::kUnknownVersion,
+ std::string());
}
// Simulate receiving all the notifications we sent out since last
@@ -240,8 +243,7 @@ TEST_F(P2PInvalidatorTest, NotificationsBasic) {
ReflectSentNotifications();
EXPECT_EQ(1, fake_handler_.GetInvalidationCount());
EXPECT_THAT(
- ModelTypeInvalidationMapToObjectIdInvalidationMap(
- MakeInvalidationMap(enabled_types)),
+ MakeInvalidationMap(enabled_types),
Eq(fake_handler_.GetLastInvalidationMap()));
// Sent with target NOTIFY_OTHERS so should not be propagated to
@@ -286,10 +288,8 @@ TEST_F(P2PInvalidatorTest, SendNotificationData) {
ReflectSentNotifications();
EXPECT_EQ(1, fake_handler_.GetInvalidationCount());
- EXPECT_THAT(
- ModelTypeInvalidationMapToObjectIdInvalidationMap(
- MakeInvalidationMap(enabled_types)),
- Eq(fake_handler_.GetLastInvalidationMap()));
+ EXPECT_THAT(MakeInvalidationMap(enabled_types),
+ Eq(fake_handler_.GetLastInvalidationMap()));
// Should be dropped.
invalidator->SendNotificationDataForTest(P2PNotificationData());
@@ -297,8 +297,7 @@ TEST_F(P2PInvalidatorTest, SendNotificationData) {
EXPECT_EQ(1, fake_handler_.GetInvalidationCount());
const ObjectIdInvalidationMap& expected_ids =
- ModelTypeInvalidationMapToObjectIdInvalidationMap(
- MakeInvalidationMap(expected_types));
+ MakeInvalidationMap(expected_types);
// Should be propagated.
invalidator->SendNotificationDataForTest(
diff --git a/sync/sessions/DEPS b/sync/sessions/DEPS
index 57778b0..b4042e3 100644
--- a/sync/sessions/DEPS
+++ b/sync/sessions/DEPS
@@ -4,6 +4,7 @@ include_rules = [
"+sync/internal_api/public/base",
"+sync/internal_api/public/engine",
"+sync/internal_api/public/sessions",
+ "+sync/notifier",
"+sync/protocol",
"+sync/syncable",
"+sync/test",
diff --git a/sync/sessions/nudge_tracker.cc b/sync/sessions/nudge_tracker.cc
index 9587f39..8ec8970 100644
--- a/sync/sessions/nudge_tracker.cc
+++ b/sync/sessions/nudge_tracker.cc
@@ -6,6 +6,8 @@
#include "base/basictypes.h"
#include "sync/internal_api/public/base/invalidation.h"
+#include "sync/notifier/invalidation_util.h"
+#include "sync/notifier/object_id_invalidation_map.h"
#include "sync/protocol/sync.pb.h"
namespace syncer {
@@ -91,15 +93,19 @@ void NudgeTracker::RecordLocalRefreshRequest(ModelTypeSet types) {
}
void NudgeTracker::RecordRemoteInvalidation(
- const ModelTypeInvalidationMap& invalidation_map) {
+ const ObjectIdInvalidationMap& invalidation_map) {
updates_source_ = sync_pb::GetUpdatesCallerInfo::NOTIFICATION;
- for (ModelTypeInvalidationMap::const_iterator i = invalidation_map.begin();
- i != invalidation_map.end(); ++i) {
- const ModelType type = i->first;
- const std::string& payload = i->second.payload;
+ for (ObjectIdInvalidationMap::const_iterator it = invalidation_map.begin();
+ it != invalidation_map.end(); ++it) {
+ ModelType type;
+ if (!ObjectIdToRealModelType(it->first, &type)) {
+ NOTREACHED()
+ << "Object ID " << ObjectIdToString(it->first)
+ << " does not map to valid model type";
+ }
DCHECK(type_trackers_.find(type) != type_trackers_.end());
- type_trackers_[type].RecordRemoteInvalidation(payload);
+ type_trackers_[type].RecordRemoteInvalidation(it->second.payload);
}
}
diff --git a/sync/sessions/nudge_tracker.h b/sync/sessions/nudge_tracker.h
index 8d8839e..aa4414c 100644
--- a/sync/sessions/nudge_tracker.h
+++ b/sync/sessions/nudge_tracker.h
@@ -13,7 +13,7 @@
#include "base/compiler_specific.h"
#include "sync/base/sync_export.h"
#include "sync/internal_api/public/base/model_type.h"
-#include "sync/internal_api/public/base/model_type_invalidation_map.h"
+#include "sync/notifier/object_id_invalidation_map.h"
#include "sync/protocol/sync.pb.h"
#include "sync/sessions/data_type_tracker.h"
@@ -48,7 +48,7 @@ class SYNC_EXPORT_PRIVATE NudgeTracker {
// Takes note of the receipt of an invalidation notice from the server.
void RecordRemoteInvalidation(
- const ModelTypeInvalidationMap& invalidation_map);
+ const ObjectIdInvalidationMap& invalidation_map);
// These functions should be called to keep this class informed of the status
// of the connection to the invalidations server.
diff --git a/sync/sessions/nudge_tracker_unittest.cc b/sync/sessions/nudge_tracker_unittest.cc
index d3efc02..ea7f4c7 100644
--- a/sync/sessions/nudge_tracker_unittest.cc
+++ b/sync/sessions/nudge_tracker_unittest.cc
@@ -2,9 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "sync/internal_api/public/base/model_type_test_util.h"
#include "sync/sessions/nudge_tracker.h"
-
-#include "sync/internal_api/public/base/model_type_invalidation_map.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace syncer {
@@ -92,9 +91,8 @@ TEST_F(NudgeTrackerTest, SourcePriorities) {
nudge_tracker.updates_source());
// An invalidation will override the refresh request source.
- ModelTypeInvalidationMap invalidation_map =
- ModelTypeSetToInvalidationMap(ModelTypeSet(PREFERENCES),
- std::string("hint"));
+ ObjectIdInvalidationMap invalidation_map =
+ BuildInvalidationMap(PREFERENCES, 1, "hint");
nudge_tracker.RecordRemoteInvalidation(invalidation_map);
EXPECT_EQ(sync_pb::GetUpdatesCallerInfo::NOTIFICATION,
nudge_tracker.updates_source());
@@ -113,9 +111,8 @@ TEST_F(NudgeTrackerTest, HintCoalescing) {
// Easy case: record one hint.
{
- ModelTypeInvalidationMap invalidation_map =
- ModelTypeSetToInvalidationMap(ModelTypeSet(BOOKMARKS),
- std::string("bm_hint_1"));
+ ObjectIdInvalidationMap invalidation_map =
+ BuildInvalidationMap(BOOKMARKS, 1, "bm_hint_1");
nudge_tracker.RecordRemoteInvalidation(invalidation_map);
sync_pb::GetUpdateTriggers gu_trigger;
@@ -127,9 +124,8 @@ TEST_F(NudgeTrackerTest, HintCoalescing) {
// Record a second hint for the same type.
{
- ModelTypeInvalidationMap invalidation_map =
- ModelTypeSetToInvalidationMap(ModelTypeSet(BOOKMARKS),
- std::string("bm_hint_2"));
+ ObjectIdInvalidationMap invalidation_map =
+ BuildInvalidationMap(BOOKMARKS, 2, "bm_hint_2");
nudge_tracker.RecordRemoteInvalidation(invalidation_map);
sync_pb::GetUpdateTriggers gu_trigger;
@@ -144,9 +140,8 @@ TEST_F(NudgeTrackerTest, HintCoalescing) {
// Record a hint for a different type.
{
- ModelTypeInvalidationMap invalidation_map =
- ModelTypeSetToInvalidationMap(ModelTypeSet(PASSWORDS),
- std::string("pw_hint_1"));
+ ObjectIdInvalidationMap invalidation_map =
+ BuildInvalidationMap(PASSWORDS, 1, "pw_hint_1");
nudge_tracker.RecordRemoteInvalidation(invalidation_map);
// Re-verify the bookmarks to make sure they're unaffected.
@@ -169,9 +164,8 @@ TEST_F(NudgeTrackerTest, HintCoalescing) {
TEST_F(NudgeTrackerTest, DropHintsLocally) {
NudgeTracker nudge_tracker;
- ModelTypeInvalidationMap invalidation_map =
- ModelTypeSetToInvalidationMap(ModelTypeSet(BOOKMARKS),
- std::string("hint"));
+ ObjectIdInvalidationMap invalidation_map =
+ BuildInvalidationMap(BOOKMARKS, 1, "hint");
for (size_t i = 0; i < GetHintBufferSize(); ++i) {
nudge_tracker.RecordRemoteInvalidation(invalidation_map);
@@ -185,9 +179,8 @@ TEST_F(NudgeTrackerTest, DropHintsLocally) {
}
// Force an overflow.
- ModelTypeInvalidationMap invalidation_map2 =
- ModelTypeSetToInvalidationMap(ModelTypeSet(BOOKMARKS),
- std::string("new_hint"));
+ ObjectIdInvalidationMap invalidation_map2 =
+ BuildInvalidationMap(BOOKMARKS, 1000, "new_hint");
nudge_tracker.RecordRemoteInvalidation(invalidation_map2);
{
@@ -290,9 +283,8 @@ TEST_F(NudgeTrackerTest, IsSyncRequired) {
EXPECT_FALSE(nudge_tracker.IsSyncRequired());
// Invalidations.
- ModelTypeInvalidationMap invalidation_map =
- ModelTypeSetToInvalidationMap(ModelTypeSet(PREFERENCES),
- std::string("hint"));
+ ObjectIdInvalidationMap invalidation_map =
+ BuildInvalidationMap(PREFERENCES, 1, "hint");
nudge_tracker.RecordRemoteInvalidation(invalidation_map);
EXPECT_TRUE(nudge_tracker.IsSyncRequired());
nudge_tracker.RecordSuccessfulSyncCycle();
@@ -317,9 +309,8 @@ TEST_F(NudgeTrackerTest, IsGetUpdatesRequired) {
EXPECT_FALSE(nudge_tracker.IsGetUpdatesRequired());
// Invalidations.
- ModelTypeInvalidationMap invalidation_map =
- ModelTypeSetToInvalidationMap(ModelTypeSet(PREFERENCES),
- std::string("hint"));
+ ObjectIdInvalidationMap invalidation_map =
+ BuildInvalidationMap(PREFERENCES, 1, "hint");
nudge_tracker.RecordRemoteInvalidation(invalidation_map);
EXPECT_TRUE(nudge_tracker.IsGetUpdatesRequired());
nudge_tracker.RecordSuccessfulSyncCycle();
diff --git a/sync/sessions/sync_session_unittest.cc b/sync/sessions/sync_session_unittest.cc
index ea64afc..f751e25 100644
--- a/sync/sessions/sync_session_unittest.cc
+++ b/sync/sessions/sync_session_unittest.cc
@@ -10,7 +10,6 @@
#include "base/message_loop/message_loop.h"
#include "sync/engine/syncer_types.h"
#include "sync/internal_api/public/base/model_type.h"
-#include "sync/internal_api/public/base/model_type_invalidation_map_test_util.h"
#include "sync/sessions/status_controller.h"
#include "sync/syncable/syncable_id.h"
#include "sync/syncable/syncable_write_transaction.h"
@@ -181,25 +180,6 @@ TEST_F(SyncSessionTest, MoreToDownloadIfGotNoChangesRemaining) {
EXPECT_TRUE(status()->download_updates_succeeded());
}
-TEST_F(SyncSessionTest, MakeTypeInvalidationMapFromBitSet) {
- ModelTypeSet types;
- std::string payload = "test";
- ModelTypeInvalidationMap invalidation_map =
- ModelTypeSetToInvalidationMap(types, payload);
- EXPECT_TRUE(invalidation_map.empty());
-
- types.Put(BOOKMARKS);
- types.Put(PASSWORDS);
- types.Put(AUTOFILL);
- payload = "test2";
- invalidation_map = ModelTypeSetToInvalidationMap(types, payload);
-
- ASSERT_EQ(3U, invalidation_map.size());
- EXPECT_EQ(invalidation_map[BOOKMARKS].payload, payload);
- EXPECT_EQ(invalidation_map[PASSWORDS].payload, payload);
- EXPECT_EQ(invalidation_map[AUTOFILL].payload, payload);
-}
-
} // namespace
} // namespace sessions
} // namespace syncer
diff --git a/sync/sync.gyp b/sync/sync.gyp
index fb6476f..f71a872 100644
--- a/sync/sync.gyp
+++ b/sync/sync.gyp
@@ -64,9 +64,11 @@
'sync_core.gypi',
],
'dependencies': [
+ 'sync_notifier',
'sync_proto',
],
'export_dependent_settings': [
+ 'sync_notifier',
'sync_proto',
],
},
@@ -98,9 +100,6 @@
'includes': [
'sync_notifier.gypi',
],
- 'dependencies': [
- 'sync_core',
- ],
},
# The sync protocol buffer library.
diff --git a/sync/sync_internal_api.gypi b/sync/sync_internal_api.gypi
index 704e960..a22195a 100644
--- a/sync/sync_internal_api.gypi
+++ b/sync/sync_internal_api.gypi
@@ -36,8 +36,6 @@
'internal_api/public/base/invalidation.cc',
'internal_api/public/base/invalidation.h',
'internal_api/public/base/model_type.h',
- 'internal_api/public/base/model_type_invalidation_map.cc',
- 'internal_api/public/base/model_type_invalidation_map.h',
'internal_api/public/base/node_ordinal.cc',
'internal_api/public/base/node_ordinal.h',
'internal_api/public/base/ordinal.h',
diff --git a/sync/sync_tests.gypi b/sync/sync_tests.gypi
index 933ad7b..07165af 100644
--- a/sync/sync_tests.gypi
+++ b/sync/sync_tests.gypi
@@ -27,6 +27,8 @@
'sync',
],
'sources': [
+ 'internal_api/public/base/model_type_test_util.cc',
+ 'internal_api/public/base/model_type_test_util.h',
'js/js_test_util.cc',
'js/js_test_util.h',
'sessions/test_util.cc',
@@ -47,10 +49,8 @@
'test/engine/test_syncable_utils.h',
'test/fake_encryptor.cc',
'test/fake_encryptor.h',
- 'test/fake_sync_encryption_handler.h',
'test/fake_sync_encryption_handler.cc',
- 'test/test_transaction_observer.cc',
- 'test/test_transaction_observer.h',
+ 'test/fake_sync_encryption_handler.h',
'test/null_directory_change_delegate.cc',
'test/null_directory_change_delegate.h',
'test/null_transaction_observer.cc',
@@ -58,6 +58,8 @@
'test/sessions/test_scoped_session_event_listener.h',
'test/test_directory_backing_store.cc',
'test/test_directory_backing_store.h',
+ 'test/test_transaction_observer.cc',
+ 'test/test_transaction_observer.h',
'util/test_unrecoverable_error_handler.cc',
'util/test_unrecoverable_error_handler.h',
],
@@ -147,10 +149,6 @@
'sources': [
'internal_api/public/base/invalidation_test_util.cc',
'internal_api/public/base/invalidation_test_util.h',
- 'internal_api/public/base/model_type_invalidation_map_test_util.cc',
- 'internal_api/public/base/model_type_invalidation_map_test_util.h',
- 'internal_api/public/base/model_type_test_util.cc',
- 'internal_api/public/base/model_type_test_util.h',
'internal_api/public/test/fake_sync_manager.h',
'internal_api/public/test/test_entry_factory.h',
'internal_api/public/test/test_internal_components_factory.h',
@@ -229,7 +227,6 @@
],
'sources': [
'internal_api/public/base/enum_set_unittest.cc',
- 'internal_api/public/base/model_type_invalidation_map_unittest.cc',
'internal_api/public/base/node_ordinal_unittest.cc',
'internal_api/public/base/ordinal_unittest.cc',
'internal_api/public/base/unique_position_unittest.cc',
diff --git a/sync/test/engine/fake_sync_scheduler.cc b/sync/test/engine/fake_sync_scheduler.cc
index 585248e..1e0c7e8 100644
--- a/sync/test/engine/fake_sync_scheduler.cc
+++ b/sync/test/engine/fake_sync_scheduler.cc
@@ -30,7 +30,7 @@ void FakeSyncScheduler::ScheduleLocalRefreshRequest(
void FakeSyncScheduler::ScheduleInvalidationNudge(
const base::TimeDelta& desired_delay,
- const ModelTypeInvalidationMap& invalidation_map,
+ const ObjectIdInvalidationMap& invalidation_map,
const tracked_objects::Location& nudge_location) {
}
diff --git a/sync/test/engine/fake_sync_scheduler.h b/sync/test/engine/fake_sync_scheduler.h
index 29757e2..11a63cc 100644
--- a/sync/test/engine/fake_sync_scheduler.h
+++ b/sync/test/engine/fake_sync_scheduler.h
@@ -31,7 +31,7 @@ class FakeSyncScheduler : public SyncScheduler {
const tracked_objects::Location& nudge_location) OVERRIDE;
virtual void ScheduleInvalidationNudge(
const base::TimeDelta& desired_delay,
- const ModelTypeInvalidationMap& invalidation_map,
+ const ObjectIdInvalidationMap& invalidation_map,
const tracked_objects::Location& nudge_location) OVERRIDE;
virtual bool ScheduleConfiguration(
const ConfigurationParams& params) OVERRIDE;
diff --git a/sync/test/engine/mock_connection_manager.h b/sync/test/engine/mock_connection_manager.h
index bab81ae..83de59a 100644
--- a/sync/test/engine/mock_connection_manager.h
+++ b/sync/test/engine/mock_connection_manager.h
@@ -17,7 +17,6 @@
#include "base/memory/scoped_vector.h"
#include "sync/engine/net/server_connection_manager.h"
#include "sync/internal_api/public/base/model_type.h"
-#include "sync/internal_api/public/base/model_type_invalidation_map.h"
#include "sync/internal_api/public/base/unique_position.h"
#include "sync/protocol/sync.pb.h"
diff --git a/sync/tools/sync_listen_notifications.cc b/sync/tools/sync_listen_notifications.cc
index 329b5f0..9cebcee 100644
--- a/sync/tools/sync_listen_notifications.cc
+++ b/sync/tools/sync_listen_notifications.cc
@@ -23,7 +23,6 @@
#include "net/http/transport_security_state.h"
#include "net/url_request/url_request_test_util.h"
#include "sync/internal_api/public/base/model_type.h"
-#include "sync/internal_api/public/base/model_type_invalidation_map.h"
#include "sync/notifier/invalidation_handler.h"
#include "sync/notifier/invalidation_state_tracker.h"
#include "sync/notifier/invalidation_util.h"
@@ -61,13 +60,11 @@ class NotificationPrinter : public InvalidationHandler {
virtual void OnIncomingInvalidation(
const ObjectIdInvalidationMap& invalidation_map) OVERRIDE {
- const ModelTypeInvalidationMap& type_invalidation_map =
- ObjectIdInvalidationMapToModelTypeInvalidationMap(invalidation_map);
- for (ModelTypeInvalidationMap::const_iterator it =
- type_invalidation_map.begin(); it != type_invalidation_map.end();
- ++it) {
- LOG(INFO) << "Remote invalidation: type = "
- << ModelTypeToString(it->first)
+ for (ObjectIdInvalidationMap::const_iterator it = invalidation_map.begin();
+ it != invalidation_map.end(); ++it) {
+ LOG(INFO) << "Remote invalidation: id = "
+ << ObjectIdToString(it->first)
+ << ", version = " << it->second.version
<< ", payload = " << it->second.payload;
}
}