diff options
author | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-03 21:20:54 +0000 |
---|---|---|
committer | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-03 21:20:54 +0000 |
commit | ba85740ffef8b4622d7fc94c71672cc207b4365c (patch) | |
tree | dd7de7ac6903ec690e15dd9090bce3e01bf9f7c8 /sync/sessions | |
parent | ad554bcfe7ea960662f05fbd61c6aadcf71c04bf (diff) | |
download | chromium_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
Diffstat (limited to 'sync/sessions')
-rw-r--r-- | sync/sessions/DEPS | 1 | ||||
-rw-r--r-- | sync/sessions/nudge_tracker.cc | 18 | ||||
-rw-r--r-- | sync/sessions/nudge_tracker.h | 4 | ||||
-rw-r--r-- | sync/sessions/nudge_tracker_unittest.cc | 43 | ||||
-rw-r--r-- | sync/sessions/sync_session_unittest.cc | 20 |
5 files changed, 32 insertions, 54 deletions
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 |