summaryrefslogtreecommitdiffstats
path: root/sync/internal_api
diff options
context:
space:
mode:
Diffstat (limited to 'sync/internal_api')
-rw-r--r--sync/internal_api/debug_info_event_listener.cc4
-rw-r--r--sync/internal_api/debug_info_event_listener.h2
-rw-r--r--sync/internal_api/js_sync_manager_observer_unittest.cc2
-rw-r--r--sync/internal_api/public/base/invalidation_state.h25
-rw-r--r--sync/internal_api/public/base/invalidation_state_test_util.cc63
-rw-r--r--sync/internal_api/public/base/invalidation_state_test_util.h23
-rw-r--r--sync/internal_api/public/base/model_type_payload_map.cc75
-rw-r--r--sync/internal_api/public/base/model_type_payload_map.h53
-rw-r--r--sync/internal_api/public/base/model_type_payload_map_unittest.cc73
-rw-r--r--sync/internal_api/public/base/model_type_state_map.cc76
-rw-r--r--sync/internal_api/public/base/model_type_state_map.h54
-rw-r--r--sync/internal_api/public/base/model_type_state_map_test_util.cc111
-rw-r--r--sync/internal_api/public/base/model_type_state_map_test_util.h20
-rw-r--r--sync/internal_api/public/base/model_type_state_map_unittest.cc70
-rw-r--r--sync/internal_api/public/engine/model_safe_worker.cc8
-rw-r--r--sync/internal_api/public/engine/model_safe_worker.h6
-rw-r--r--sync/internal_api/public/engine/model_safe_worker_unittest.cc10
-rw-r--r--sync/internal_api/public/sessions/sync_session_snapshot.cc6
-rw-r--r--sync/internal_api/public/sessions/sync_session_snapshot.h8
-rw-r--r--sync/internal_api/public/sessions/sync_source_info.cc6
-rw-r--r--sync/internal_api/public/sessions/sync_source_info.h8
-rw-r--r--sync/internal_api/public/test/fake_sync_manager.h4
-rw-r--r--sync/internal_api/sync_manager_impl.cc36
-rw-r--r--sync/internal_api/sync_manager_impl.h4
-rw-r--r--sync/internal_api/sync_manager_impl_unittest.cc6
-rw-r--r--sync/internal_api/test/fake_sync_manager.cc10
26 files changed, 502 insertions, 261 deletions
diff --git a/sync/internal_api/debug_info_event_listener.cc b/sync/internal_api/debug_info_event_listener.cc
index d88981a..c48b7c9 100644
--- a/sync/internal_api/debug_info_event_listener.cc
+++ b/sync/internal_api/debug_info_event_listener.cc
@@ -109,9 +109,9 @@ void DebugInfoEventListener::OnNudgeFromDatatype(ModelType datatype) {
}
void DebugInfoEventListener::OnIncomingNotification(
- const ModelTypePayloadMap& type_payloads) {
+ const ModelTypeStateMap& type_state_map) {
sync_pb::DebugEventInfo event_info;
- ModelTypeSet types = ModelTypePayloadMapToEnumSet(type_payloads);
+ ModelTypeSet types = ModelTypeStateMapToSet(type_state_map);
for (ModelTypeSet::Iterator it = types.First(); it.Good(); it.Inc()) {
event_info.add_datatypes_notified_from_server(
diff --git a/sync/internal_api/debug_info_event_listener.h b/sync/internal_api/debug_info_event_listener.h
index 158801d..252f64b 100644
--- a/sync/internal_api/debug_info_event_listener.h
+++ b/sync/internal_api/debug_info_event_listener.h
@@ -60,7 +60,7 @@ class DebugInfoEventListener : public SyncManager::Observer,
// Sync manager events.
void OnNudgeFromDatatype(ModelType datatype);
- void OnIncomingNotification(const ModelTypePayloadMap& type_payloads);
+ void OnIncomingNotification(const ModelTypeStateMap& type_state_map);
// DebugInfoGetter Implementation.
virtual void GetAndClearDebugInfo(sync_pb::DebugInfo* debug_info) OVERRIDE;
diff --git a/sync/internal_api/js_sync_manager_observer_unittest.cc b/sync/internal_api/js_sync_manager_observer_unittest.cc
index 4cde1f6..6d8c9be8 100644
--- a/sync/internal_api/js_sync_manager_observer_unittest.cc
+++ b/sync/internal_api/js_sync_manager_observer_unittest.cc
@@ -72,7 +72,7 @@ TEST_F(JsSyncManagerObserverTest, OnInitializationComplete) {
}
TEST_F(JsSyncManagerObserverTest, OnSyncCycleCompleted) {
- ModelTypePayloadMap download_progress_markers;
+ ModelTypeStateMap download_progress_markers;
sessions::SyncSessionSnapshot snapshot(sessions::ModelNeutralState(),
false,
ModelTypeSet(),
diff --git a/sync/internal_api/public/base/invalidation_state.h b/sync/internal_api/public/base/invalidation_state.h
new file mode 100644
index 0000000..8b79019
--- /dev/null
+++ b/sync/internal_api/public/base/invalidation_state.h
@@ -0,0 +1,25 @@
+// 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_INVALIDATION_STATE_H_
+#define SYNC_INTERNAL_API_PUBLIC_BASE_INVALIDATION_STATE_H_
+
+#include <string>
+
+namespace syncer {
+
+// Opaque class that represents an ack handle.
+// TODO(dcheng): This is just a refactoring change, so the class is empty for
+// the moment. It will be filled once we start implementing 'reminders'.
+class AckHandle {
+};
+
+struct InvalidationState {
+ std::string payload;
+ AckHandle ack_handle;
+};
+
+} // namespace syncer
+
+#endif // SYNC_INTERNAL_API_PUBLIC_BASE_INVALIDATION_STATE_H_
diff --git a/sync/internal_api/public/base/invalidation_state_test_util.cc b/sync/internal_api/public/base/invalidation_state_test_util.cc
new file mode 100644
index 0000000..a27d045
--- /dev/null
+++ b/sync/internal_api/public/base/invalidation_state_test_util.cc
@@ -0,0 +1,63 @@
+// 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/invalidation_state_test_util.h"
+
+#include "base/basictypes.h"
+#include "sync/internal_api/public/base/invalidation_state.h"
+
+namespace syncer {
+
+using ::testing::MakeMatcher;
+using ::testing::MatchResultListener;
+using ::testing::Matcher;
+using ::testing::MatcherInterface;
+using ::testing::PrintToString;
+
+namespace {
+
+class InvalidationStateEqMatcher
+ : public MatcherInterface<const InvalidationState&> {
+ public:
+ explicit InvalidationStateEqMatcher(const InvalidationState& expected);
+
+ virtual bool MatchAndExplain(const InvalidationState& actual,
+ MatchResultListener* listener) const;
+ virtual void DescribeTo(::std::ostream* os) const;
+ virtual void DescribeNegationTo(::std::ostream* os) const;
+
+ private:
+ const InvalidationState expected_;
+
+ DISALLOW_COPY_AND_ASSIGN(InvalidationStateEqMatcher);
+};
+
+InvalidationStateEqMatcher::InvalidationStateEqMatcher(
+ const InvalidationState& expected) : expected_(expected) {
+}
+
+bool InvalidationStateEqMatcher::MatchAndExplain(
+ const InvalidationState& actual, MatchResultListener* listener) const {
+ return expected_.payload == actual.payload;
+}
+
+void InvalidationStateEqMatcher::DescribeTo(::std::ostream* os) const {
+ *os << " is equal to " << PrintToString(expected_);
+}
+
+void InvalidationStateEqMatcher::DescribeNegationTo(::std::ostream* os) const {
+ *os << " isn't equal to " << PrintToString(expected_);
+}
+
+} // namespace
+
+void PrintTo(const InvalidationState& state, ::std::ostream* os) {
+ *os << "{ payload: " << state.payload << " }";
+}
+
+Matcher<const InvalidationState&> Eq(const InvalidationState& expected) {
+ return MakeMatcher(new InvalidationStateEqMatcher(expected));
+}
+
+} // namespace syncer
diff --git a/sync/internal_api/public/base/invalidation_state_test_util.h b/sync/internal_api/public/base/invalidation_state_test_util.h
new file mode 100644
index 0000000..77baccb
--- /dev/null
+++ b/sync/internal_api/public/base/invalidation_state_test_util.h
@@ -0,0 +1,23 @@
+// 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_INVALIDATION_STATE_TEST_UTIL_H_
+#define SYNC_INTERNAL_API_PUBLIC_BASE_INVALIDATION_STATE_TEST_UTIL_H_
+
+#include <iosfwd>
+
+#include "testing/gmock/include/gmock/gmock.h"
+
+namespace syncer {
+
+struct InvalidationState;
+
+void PrintTo(const InvalidationState& state, ::std::ostream* os);
+
+::testing::Matcher<const InvalidationState&> Eq(
+ const InvalidationState& expected);
+
+} // namespace syncer
+
+#endif // SYNC_INTERNAL_API_PUBLIC_BASE_INVALIDATION_STATE_TEST_UTIL_H_
diff --git a/sync/internal_api/public/base/model_type_payload_map.cc b/sync/internal_api/public/base/model_type_payload_map.cc
deleted file mode 100644
index 1728130..0000000
--- a/sync/internal_api/public/base/model_type_payload_map.cc
+++ /dev/null
@@ -1,75 +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_payload_map.h"
-
-#include <vector>
-
-#include "base/base64.h"
-#include "base/json/json_writer.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/values.h"
-
-namespace syncer {
-
-ModelTypePayloadMap ModelTypePayloadMapFromEnumSet(
- ModelTypeSet types,
- const std::string& payload) {
- ModelTypePayloadMap types_with_payloads;
- for (ModelTypeSet::Iterator it = types.First(); it.Good(); it.Inc()) {
- types_with_payloads[it.Get()] = payload;
- }
- return types_with_payloads;
-}
-
-ModelTypeSet ModelTypePayloadMapToEnumSet(
- const ModelTypePayloadMap& payload_map) {
- ModelTypeSet types;
- for (ModelTypePayloadMap::const_iterator it = payload_map.begin();
- it != payload_map.end(); ++it) {
- types.Put(it->first);
- }
- return types;
-}
-
-std::string ModelTypePayloadMapToString(
- const ModelTypePayloadMap& type_payloads) {
- scoped_ptr<DictionaryValue> value(
- ModelTypePayloadMapToValue(type_payloads));
- std::string json;
- base::JSONWriter::Write(value.get(), &json);
- return json;
-}
-
-DictionaryValue* ModelTypePayloadMapToValue(
- const ModelTypePayloadMap& type_payloads) {
- DictionaryValue* value = new DictionaryValue();
- for (ModelTypePayloadMap::const_iterator it = type_payloads.begin();
- it != type_payloads.end(); ++it) {
- // TODO(akalin): Unpack the value into a protobuf.
- std::string base64_marker;
- bool encoded = base::Base64Encode(it->second, &base64_marker);
- DCHECK(encoded);
- value->SetString(ModelTypeToString(it->first), base64_marker);
- }
- return value;
-}
-
-void CoalescePayloads(ModelTypePayloadMap* original,
- const ModelTypePayloadMap& update) {
- for (ModelTypePayloadMap::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.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] = i->second;
- }
- }
-}
-
-} // namespace syncer
diff --git a/sync/internal_api/public/base/model_type_payload_map.h b/sync/internal_api/public/base/model_type_payload_map.h
deleted file mode 100644
index 66eb7f7..0000000
--- a/sync/internal_api/public/base/model_type_payload_map.h
+++ /dev/null
@@ -1,53 +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.
-//
-// Definition of ModelTypePayloadMap and various utility functions.
-
-#ifndef SYNC_INTERNAL_PUBLIC_API_BASE_MODEL_TYPE_PAYLOAD_MAP_H_
-#define SYNC_INTERNAL_PUBLIC_API_BASE_MODEL_TYPE_PAYLOAD_MAP_H_
-
-#include <map>
-#include <string>
-
-#include "sync/base/sync_export.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 container that contains a set of datatypes with possible string
-// payloads.
-typedef std::map<ModelType, std::string> ModelTypePayloadMap;
-
-// Helper functions for building ModelTypePayloadMaps.
-
-// Make a TypePayloadMap from all the types in a ModelTypeSet using a
-// default payload.
-SYNC_EXPORT ModelTypePayloadMap ModelTypePayloadMapFromEnumSet(
- ModelTypeSet model_types, const std::string& payload);
-
-ModelTypeSet ModelTypePayloadMapToEnumSet(
- const ModelTypePayloadMap& payload_map);
-
-std::string ModelTypePayloadMapToString(
- const ModelTypePayloadMap& model_type_payloads);
-
-// Caller takes ownership of the returned dictionary.
-base::DictionaryValue* ModelTypePayloadMapToValue(
- const ModelTypePayloadMap& model_type_payloads);
-
-// Coalesce |update| into |original|, overwriting only when |update| has
-// a non-empty payload.
-void CoalescePayloads(ModelTypePayloadMap* original,
- const ModelTypePayloadMap& update);
-
-} // namespace syncer
-
-#endif // SYNC_INTERNAL_PUBLIC_API_BASE_MODEL_TYPE_PAYLOAD_MAP_H_
diff --git a/sync/internal_api/public/base/model_type_payload_map_unittest.cc b/sync/internal_api/public/base/model_type_payload_map_unittest.cc
deleted file mode 100644
index 19762eeb..0000000
--- a/sync/internal_api/public/base/model_type_payload_map_unittest.cc
+++ /dev/null
@@ -1,73 +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_payload_map.h"
-
-#include <string>
-
-#include "base/base64.h"
-#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 ModelTypePayloadMapTest : public testing::Test {};
-
-TEST_F(ModelTypePayloadMapTest, TypePayloadMapToSet) {
- ModelTypePayloadMap payloads;
- payloads[BOOKMARKS] = "bookmarkpayload";
- payloads[APPS] = "";
-
- const ModelTypeSet types(BOOKMARKS, APPS);
- EXPECT_TRUE(ModelTypePayloadMapToEnumSet(payloads).Equals(types));
-}
-
-TEST_F(ModelTypePayloadMapTest, TypePayloadMapToValue) {
- ModelTypePayloadMap payloads;
- std::string encoded;
- payloads[BOOKMARKS] = "bookmarkpayload";
- base::Base64Encode(payloads[BOOKMARKS], &encoded);
- payloads[APPS] = "";
-
- scoped_ptr<DictionaryValue> value(ModelTypePayloadMapToValue(payloads));
- EXPECT_EQ(2u, value->size());
- ExpectDictStringValue(encoded, *value, "Bookmarks");
- ExpectDictStringValue("", *value, "Apps");
- EXPECT_FALSE(value->HasKey("Preferences"));
-}
-
-TEST_F(ModelTypePayloadMapTest, CoalescePayloads) {
- ModelTypePayloadMap original;
- std::string empty_payload;
- std::string payload1 = "payload1";
- std::string payload2 = "payload2";
- std::string payload3 = "payload3";
- original[BOOKMARKS] = empty_payload;
- original[PASSWORDS] = payload1;
- original[AUTOFILL] = payload2;
- original[THEMES] = payload3;
-
- ModelTypePayloadMap update;
- update[BOOKMARKS] = empty_payload; // Same.
- update[PASSWORDS] = empty_payload; // Overwrite with empty.
- update[AUTOFILL] = payload1; // Overwrite with non-empty.
- update[SESSIONS] = payload2; // New.
- // Themes untouched.
-
- CoalescePayloads(&original, update);
- ASSERT_EQ(5U, original.size());
- EXPECT_EQ(empty_payload, original[BOOKMARKS]);
- EXPECT_EQ(payload1, original[PASSWORDS]);
- EXPECT_EQ(payload1, original[AUTOFILL]);
- EXPECT_EQ(payload2, original[SESSIONS]);
- EXPECT_EQ(payload3, original[THEMES]);
-}
-
-} // namespace
-} // namespace syncer
diff --git a/sync/internal_api/public/base/model_type_state_map.cc b/sync/internal_api/public/base/model_type_state_map.cc
new file mode 100644
index 0000000..fbdff7d
--- /dev/null
+++ b/sync/internal_api/public/base/model_type_state_map.cc
@@ -0,0 +1,76 @@
+// 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_state_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 {
+
+ModelTypeStateMap ModelTypeSetToStateMap(ModelTypeSet types,
+ const std::string& payload) {
+ ModelTypeStateMap type_state_map;
+ for (ModelTypeSet::Iterator it = types.First(); it.Good(); it.Inc()) {
+ // TODO(dcheng): Do we need to set ack_handle?
+ type_state_map[it.Get()].payload = payload;
+ }
+ return type_state_map;
+}
+
+ModelTypeSet ModelTypeStateMapToSet(
+ const ModelTypeStateMap& type_state_map) {
+ ModelTypeSet types;
+ for (ModelTypeStateMap::const_iterator it = type_state_map.begin();
+ it != type_state_map.end(); ++it) {
+ types.Put(it->first);
+ }
+ return types;
+}
+
+std::string ModelTypeStateMapToString(const ModelTypeStateMap& type_state_map) {
+ scoped_ptr<DictionaryValue> value(ModelTypeStateMapToValue(type_state_map));
+ std::string json;
+ base::JSONWriter::Write(value.get(), &json);
+ return json;
+}
+
+DictionaryValue* ModelTypeStateMapToValue(
+ const ModelTypeStateMap& type_state_map) {
+ DictionaryValue* value = new DictionaryValue();
+ for (ModelTypeStateMap::const_iterator it = type_state_map.begin();
+ it != type_state_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(ModelTypeStateMap* original,
+ const ModelTypeStateMap& update) {
+ // 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 (ModelTypeStateMap::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_state_map.h b/sync/internal_api/public/base/model_type_state_map.h
new file mode 100644
index 0000000..71b0e65
--- /dev/null
+++ b/sync/internal_api/public/base/model_type_state_map.h
@@ -0,0 +1,54 @@
+// 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.
+//
+// Definition of ModelTypeStateMap and various utility functions.
+
+#ifndef SYNC_INTERNAL_PUBLIC_API_BASE_MODEL_TYPE_STATE_MAP_H_
+#define SYNC_INTERNAL_PUBLIC_API_BASE_MODEL_TYPE_STATE_MAP_H_
+
+#include <map>
+#include <string>
+
+#include "sync/base/sync_export.h"
+#include "sync/internal_api/public/base/invalidation_state.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 container that contains a set of datatypes with possible string
+// payloads.
+typedef std::map<ModelType, InvalidationState> ModelTypeStateMap;
+
+// Helper functions for building ModelTypeStateMaps.
+
+// Make a TypeStateMap from all the types in a ModelTypeSet using a
+// default payload.
+SYNC_EXPORT ModelTypeStateMap ModelTypeSetToStateMap(
+ ModelTypeSet model_types, const std::string& payload);
+
+ModelTypeSet ModelTypeStateMapToSet(
+ const ModelTypeStateMap& payload_map);
+
+std::string ModelTypeStateMapToString(
+ const ModelTypeStateMap& model_type_payloads);
+
+// Caller takes ownership of the returned dictionary.
+base::DictionaryValue* ModelTypeStateMapToValue(
+ const ModelTypeStateMap& model_type_payloads);
+
+// Coalesce |update| into |original|, overwriting only when |update| has
+// a non-empty payload.
+void CoalesceStates(ModelTypeStateMap* original,
+ const ModelTypeStateMap& update);
+
+} // namespace syncer
+
+#endif // SYNC_INTERNAL_PUBLIC_API_BASE_MODEL_TYPE_STATE_MAP_H_
diff --git a/sync/internal_api/public/base/model_type_state_map_test_util.cc b/sync/internal_api/public/base/model_type_state_map_test_util.cc
new file mode 100644
index 0000000..3b975f8
--- /dev/null
+++ b/sync/internal_api/public/base/model_type_state_map_test_util.cc
@@ -0,0 +1,111 @@
+// 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_state_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 ModelTypeStateMapEqMatcher
+ : public MatcherInterface<const ModelTypeStateMap&> {
+ public:
+ explicit ModelTypeStateMapEqMatcher(const ModelTypeStateMap& expected);
+
+ virtual bool MatchAndExplain(const ModelTypeStateMap& lhs,
+ MatchResultListener* listener) const;
+ virtual void DescribeTo(::std::ostream* os) const;
+ virtual void DescribeNegationTo(::std::ostream* os) const;
+
+ private:
+ const ModelTypeStateMap expected_;
+
+ DISALLOW_COPY_AND_ASSIGN(ModelTypeStateMapEqMatcher);
+};
+
+ModelTypeStateMapEqMatcher::ModelTypeStateMapEqMatcher(
+ const ModelTypeStateMap& expected) : expected_(expected) {
+}
+
+bool ModelTypeStateMapEqMatcher::MatchAndExplain(
+ const ModelTypeStateMap& actual, MatchResultListener* listener) const {
+ ModelTypeStateMap expected_only;
+ ModelTypeStateMap actual_only;
+ typedef std::pair<ModelType,
+ std::pair<InvalidationState, InvalidationState> >
+ 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 (ModelTypeStateMap::const_iterator it = expected_.begin();
+ it != expected_.end(); ++it) {
+ ModelTypeStateMap::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 ModelTypeStateMapEqMatcher::DescribeTo(::std::ostream* os) const {
+ *os << " is equal to " << PrintToString(expected_);
+}
+
+void ModelTypeStateMapEqMatcher::DescribeNegationTo(::std::ostream* os) const {
+ *os << " isn't equal to " << PrintToString(expected_);
+}
+
+} // namespace
+
+Matcher<const ModelTypeStateMap&> Eq(const ModelTypeStateMap& expected) {
+ return MakeMatcher(new ModelTypeStateMapEqMatcher(expected));
+}
+
+} // namespace syncer
diff --git a/sync/internal_api/public/base/model_type_state_map_test_util.h b/sync/internal_api/public/base/model_type_state_map_test_util.h
new file mode 100644
index 0000000..3538816
--- /dev/null
+++ b/sync/internal_api/public/base/model_type_state_map_test_util.h
@@ -0,0 +1,20 @@
+// 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_state_test_util.h"
+#include "sync/internal_api/public/base/model_type_state_map.h"
+#include "testing/gmock/include/gmock/gmock.h"
+
+namespace syncer {
+
+::testing::Matcher<const ModelTypeStateMap&> Eq(
+ const ModelTypeStateMap& 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_state_map_unittest.cc b/sync/internal_api/public/base/model_type_state_map_unittest.cc
new file mode 100644
index 0000000..1981f3d
--- /dev/null
+++ b/sync/internal_api/public/base/model_type_state_map_unittest.cc
@@ -0,0 +1,70 @@
+// 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_state_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 ModelTypeStateMapTest : public testing::Test {};
+
+TEST_F(ModelTypeStateMapTest, TypeStateMapToSet) {
+ ModelTypeStateMap states;
+ states[BOOKMARKS].payload = "bookmarkpayload";
+ states[APPS].payload = "";
+
+ const ModelTypeSet types(BOOKMARKS, APPS);
+ EXPECT_TRUE(ModelTypeStateMapToSet(states).Equals(types));
+}
+
+TEST_F(ModelTypeStateMapTest, TypeStateMapToValue) {
+ ModelTypeStateMap states;
+ states[BOOKMARKS].payload = "bookmarkpayload";
+ states[APPS].payload = "";
+
+ scoped_ptr<DictionaryValue> value(ModelTypeStateMapToValue(states));
+ EXPECT_EQ(2u, value->size());
+ ExpectDictStringValue(states[BOOKMARKS].payload, *value, "Bookmarks");
+ ExpectDictStringValue("", *value, "Apps");
+ EXPECT_FALSE(value->HasKey("Preferences"));
+}
+
+TEST_F(ModelTypeStateMapTest, CoalesceStates) {
+ ModelTypeStateMap 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;
+
+ ModelTypeStateMap 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(&original, update);
+ 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/engine/model_safe_worker.cc b/sync/internal_api/public/engine/model_safe_worker.cc
index cd7eaea..2212a41 100644
--- a/sync/internal_api/public/engine/model_safe_worker.cc
+++ b/sync/internal_api/public/engine/model_safe_worker.cc
@@ -29,15 +29,15 @@ std::string ModelSafeRoutingInfoToString(
return json;
}
-ModelTypePayloadMap ModelSafeRoutingInfoToPayloadMap(
+ModelTypeStateMap ModelSafeRoutingInfoToStateMap(
const ModelSafeRoutingInfo& routes,
const std::string& payload) {
- ModelTypePayloadMap types_with_payloads;
+ ModelTypeStateMap type_state_map;
for (ModelSafeRoutingInfo::const_iterator i = routes.begin();
i != routes.end(); ++i) {
- types_with_payloads[i->first] = payload;
+ type_state_map[i->first].payload = payload;
}
- return types_with_payloads;
+ return type_state_map;
}
ModelTypeSet GetRoutingInfoTypes(const ModelSafeRoutingInfo& routing_info) {
diff --git a/sync/internal_api/public/engine/model_safe_worker.h b/sync/internal_api/public/engine/model_safe_worker.h
index d67f4b6..d76ddb9 100644
--- a/sync/internal_api/public/engine/model_safe_worker.h
+++ b/sync/internal_api/public/engine/model_safe_worker.h
@@ -13,7 +13,7 @@
#include "base/memory/ref_counted.h"
#include "sync/base/sync_export.h"
#include "sync/internal_api/public/base/model_type.h"
-#include "sync/internal_api/public/base/model_type_payload_map.h"
+#include "sync/internal_api/public/base/model_type_state_map.h"
#include "sync/internal_api/public/util/syncer_error.h"
namespace base {
@@ -80,9 +80,9 @@ base::DictionaryValue* ModelSafeRoutingInfoToValue(
SYNC_EXPORT std::string ModelSafeRoutingInfoToString(
const ModelSafeRoutingInfo& routing_info);
-// Make a ModelTypePayloadMap for all the enabled types in a
+// Make a ModelTypeStateMap for all the enabled types in a
// ModelSafeRoutingInfo using a default payload.
-ModelTypePayloadMap ModelSafeRoutingInfoToPayloadMap(
+ModelTypeStateMap ModelSafeRoutingInfoToStateMap(
const ModelSafeRoutingInfo& routes,
const std::string& payload);
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 5acf460..9c65894 100644
--- a/sync/internal_api/public/engine/model_safe_worker_unittest.cc
+++ b/sync/internal_api/public/engine/model_safe_worker_unittest.cc
@@ -48,19 +48,19 @@ TEST_F(ModelSafeWorkerTest, GetRoutingInfoTypes) {
EXPECT_TRUE(GetRoutingInfoTypes(routing_info).Equals(expected_types));
}
-TEST_F(ModelSafeWorkerTest, ModelSafeRoutingInfoToPayloadMap) {
+TEST_F(ModelSafeWorkerTest, ModelSafeRoutingInfoToStateMap) {
std::string payload = "test";
ModelSafeRoutingInfo routing_info;
routing_info[BOOKMARKS] = GROUP_PASSIVE;
routing_info[NIGORI] = GROUP_UI;
routing_info[PREFERENCES] = GROUP_DB;
- ModelTypePayloadMap types_with_payloads =
- ModelSafeRoutingInfoToPayloadMap(routing_info, payload);
- ASSERT_EQ(routing_info.size(), types_with_payloads.size());
+ ModelTypeStateMap type_state_map =
+ ModelSafeRoutingInfoToStateMap(routing_info, payload);
+ ASSERT_EQ(routing_info.size(), type_state_map.size());
for (ModelSafeRoutingInfo::iterator iter = routing_info.begin();
iter != routing_info.end();
++iter) {
- EXPECT_EQ(payload, types_with_payloads[iter->first]);
+ EXPECT_EQ(payload, type_state_map[iter->first].payload);
}
}
diff --git a/sync/internal_api/public/sessions/sync_session_snapshot.cc b/sync/internal_api/public/sessions/sync_session_snapshot.cc
index 5e1e4e7..9e7a3b1 100644
--- a/sync/internal_api/public/sessions/sync_session_snapshot.cc
+++ b/sync/internal_api/public/sessions/sync_session_snapshot.cc
@@ -29,7 +29,7 @@ SyncSessionSnapshot::SyncSessionSnapshot(
const ModelNeutralState& model_neutral_state,
bool is_share_usable,
ModelTypeSet initial_sync_ended,
- const ModelTypePayloadMap& download_progress_markers,
+ const ModelTypeStateMap& download_progress_markers,
bool more_to_sync,
bool is_silenced,
int num_encryption_conflicts,
@@ -84,7 +84,7 @@ DictionaryValue* SyncSessionSnapshot::ToValue() const {
value->Set("initialSyncEnded",
ModelTypeSetToValue(initial_sync_ended_));
value->Set("downloadProgressMarkers",
- ModelTypePayloadMapToValue(download_progress_markers_));
+ ModelTypeStateMapToValue(download_progress_markers_));
value->SetBoolean("hasMoreToSync", has_more_to_sync_);
value->SetBoolean("isSilenced", is_silenced_);
// We don't care too much if we lose precision here, also.
@@ -123,7 +123,7 @@ ModelTypeSet SyncSessionSnapshot::initial_sync_ended() const {
return initial_sync_ended_;
}
-ModelTypePayloadMap SyncSessionSnapshot::download_progress_markers() const {
+ModelTypeStateMap SyncSessionSnapshot::download_progress_markers() const {
return download_progress_markers_;
}
diff --git a/sync/internal_api/public/sessions/sync_session_snapshot.h b/sync/internal_api/public/sessions/sync_session_snapshot.h
index d6fb025..74e972b 100644
--- a/sync/internal_api/public/sessions/sync_session_snapshot.h
+++ b/sync/internal_api/public/sessions/sync_session_snapshot.h
@@ -10,7 +10,7 @@
#include "base/basictypes.h"
#include "base/time.h"
#include "sync/internal_api/public/base/model_type.h"
-#include "sync/internal_api/public/base/model_type_payload_map.h"
+#include "sync/internal_api/public/base/model_type_state_map.h"
#include "sync/internal_api/public/sessions/model_neutral_state.h"
#include "sync/internal_api/public/sessions/sync_source_info.h"
@@ -33,7 +33,7 @@ class SyncSessionSnapshot {
const ModelNeutralState& model_neutral_state,
bool is_share_usable,
ModelTypeSet initial_sync_ended,
- const ModelTypePayloadMap& download_progress_markers,
+ const ModelTypeStateMap& download_progress_markers,
bool more_to_sync,
bool is_silenced,
int num_encryption_conflicts,
@@ -58,7 +58,7 @@ class SyncSessionSnapshot {
int64 num_server_changes_remaining() const;
bool is_share_usable() const;
ModelTypeSet initial_sync_ended() const;
- ModelTypePayloadMap download_progress_markers() const;
+ ModelTypeStateMap download_progress_markers() const;
bool has_more_to_sync() const;
bool is_silenced() const;
int num_encryption_conflicts() const;
@@ -78,7 +78,7 @@ class SyncSessionSnapshot {
ModelNeutralState model_neutral_state_;
bool is_share_usable_;
ModelTypeSet initial_sync_ended_;
- ModelTypePayloadMap download_progress_markers_;
+ ModelTypeStateMap download_progress_markers_;
bool has_more_to_sync_;
bool is_silenced_;
int num_encryption_conflicts_;
diff --git a/sync/internal_api/public/sessions/sync_source_info.cc b/sync/internal_api/public/sessions/sync_source_info.cc
index 9e15289..8a64c8a 100644
--- a/sync/internal_api/public/sessions/sync_source_info.cc
+++ b/sync/internal_api/public/sessions/sync_source_info.cc
@@ -13,12 +13,12 @@ namespace sessions {
SyncSourceInfo::SyncSourceInfo()
: updates_source(sync_pb::GetUpdatesCallerInfo::UNKNOWN) {}
-SyncSourceInfo::SyncSourceInfo(const ModelTypePayloadMap& t)
+SyncSourceInfo::SyncSourceInfo(const ModelTypeStateMap& t)
: updates_source(sync_pb::GetUpdatesCallerInfo::UNKNOWN), types(t) {}
SyncSourceInfo::SyncSourceInfo(
const sync_pb::GetUpdatesCallerInfo::GetUpdatesSource& u,
- const ModelTypePayloadMap& t)
+ const ModelTypeStateMap& t)
: updates_source(u), types(t) {}
SyncSourceInfo::~SyncSourceInfo() {}
@@ -27,7 +27,7 @@ DictionaryValue* SyncSourceInfo::ToValue() const {
DictionaryValue* value = new DictionaryValue();
value->SetString("updatesSource",
GetUpdatesSourceString(updates_source));
- value->Set("types", ModelTypePayloadMapToValue(types));
+ value->Set("types", ModelTypeStateMapToValue(types));
return value;
}
diff --git a/sync/internal_api/public/sessions/sync_source_info.h b/sync/internal_api/public/sessions/sync_source_info.h
index 390bdb5..619fc57 100644
--- a/sync/internal_api/public/sessions/sync_source_info.h
+++ b/sync/internal_api/public/sessions/sync_source_info.h
@@ -7,7 +7,7 @@
#include "base/basictypes.h"
#include "sync/internal_api/public/base/model_type.h"
-#include "sync/internal_api/public/base/model_type_payload_map.h"
+#include "sync/internal_api/public/base/model_type_state_map.h"
#include "sync/protocol/sync.pb.h"
namespace base {
@@ -22,17 +22,17 @@ namespace sessions {
// specific payloads which should be sent to the server.
struct SyncSourceInfo {
SyncSourceInfo();
- explicit SyncSourceInfo(const ModelTypePayloadMap& t);
+ explicit SyncSourceInfo(const ModelTypeStateMap& t);
SyncSourceInfo(
const sync_pb::GetUpdatesCallerInfo::GetUpdatesSource& u,
- const ModelTypePayloadMap& t);
+ const ModelTypeStateMap& t);
~SyncSourceInfo();
// Caller takes ownership of the returned dictionary.
base::DictionaryValue* ToValue() const;
sync_pb::GetUpdatesCallerInfo::GetUpdatesSource updates_source;
- ModelTypePayloadMap types;
+ ModelTypeStateMap types;
};
} // namespace sessions
diff --git a/sync/internal_api/public/test/fake_sync_manager.h b/sync/internal_api/public/test/fake_sync_manager.h
index 91a25d1..604429f 100644
--- a/sync/internal_api/public/test/fake_sync_manager.h
+++ b/sync/internal_api/public/test/fake_sync_manager.h
@@ -54,7 +54,7 @@ class FakeSyncManager : public SyncManager {
ModelTypeSet GetAndResetEnabledTypes();
// Posts a method to invalidate the given IDs on the sync thread.
- void Invalidate(const ObjectIdPayloadMap& id_payloads,
+ void Invalidate(const ObjectIdStateMap& id_state_map,
IncomingNotificationSource source);
// Posts a method to enable notifications on the sync thread.
@@ -125,7 +125,7 @@ class FakeSyncManager : public SyncManager {
private:
void InvalidateOnSyncThread(
- const ObjectIdPayloadMap& id_payloads,
+ const ObjectIdStateMap& id_state_map,
IncomingNotificationSource source);
void EnableNotificationsOnSyncThread();
void DisableNotificationsOnSyncThread(NotificationsDisabledReason reason);
diff --git a/sync/internal_api/sync_manager_impl.cc b/sync/internal_api/sync_manager_impl.cc
index 4335fe1..ccf5cea 100644
--- a/sync/internal_api/sync_manager_impl.cc
+++ b/sync/internal_api/sync_manager_impl.cc
@@ -21,7 +21,7 @@
#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_payload_map.h"
+#include "sync/internal_api/public/base/model_type_state_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"
@@ -1017,7 +1017,7 @@ void SyncManagerImpl::OnSyncEngineEvent(const SyncEngineEvent& event) {
if (is_notifiable_commit) {
if (sync_notifier_.get()) {
const ModelTypeSet changed_types =
- ModelTypePayloadMapToEnumSet(event.snapshot.source().types);
+ ModelTypeStateMapToSet(event.snapshot.source().types);
sync_notifier_->SendNotification(changed_types);
} else {
DVLOG(1) << "Not sending notification: sync_notifier_ is NULL";
@@ -1259,12 +1259,12 @@ JsArgList SyncManagerImpl::GetChildNodeIds(const JsArgList& args) {
}
void SyncManagerImpl::UpdateNotificationInfo(
- const ModelTypePayloadMap& type_payloads) {
- for (ModelTypePayloadMap::const_iterator it = type_payloads.begin();
- it != type_payloads.end(); ++it) {
+ const ModelTypeStateMap& type_state_map) {
+ for (ModelTypeStateMap::const_iterator it = type_state_map.begin();
+ it != type_state_map.end(); ++it) {
NotificationInfo* info = &notification_info_map_[it->first];
info->total_count++;
- info->payload = it->second;
+ info->payload = it->second.payload;
}
}
@@ -1278,24 +1278,24 @@ void SyncManagerImpl::OnNotificationsDisabled(
}
void SyncManagerImpl::OnIncomingNotification(
- const ObjectIdPayloadMap& id_payloads,
+ const ObjectIdStateMap& id_state_map,
IncomingNotificationSource source) {
DCHECK(thread_checker_.CalledOnValidThread());
- const ModelTypePayloadMap& type_payloads =
- ObjectIdPayloadMapToModelTypePayloadMap(id_payloads);
+ const ModelTypeStateMap& type_state_map =
+ ObjectIdStateMapToModelTypeStateMap(id_state_map);
if (source == LOCAL_NOTIFICATION) {
- scheduler_->ScheduleNudgeWithPayloadsAsync(
+ scheduler_->ScheduleNudgeWithStatesAsync(
TimeDelta::FromMilliseconds(kSyncRefreshDelayMsec),
NUDGE_SOURCE_LOCAL_REFRESH,
- type_payloads, FROM_HERE);
- } else if (!type_payloads.empty()) {
- scheduler_->ScheduleNudgeWithPayloadsAsync(
+ type_state_map, FROM_HERE);
+ } else if (!type_state_map.empty()) {
+ scheduler_->ScheduleNudgeWithStatesAsync(
TimeDelta::FromMilliseconds(kSyncSchedulerDelayMsec),
NUDGE_SOURCE_NOTIFICATION,
- type_payloads, FROM_HERE);
+ type_state_map, FROM_HERE);
allstatus_.IncrementNotificationsReceived();
- UpdateNotificationInfo(type_payloads);
- debug_info_event_listener_.OnIncomingNotification(type_payloads);
+ UpdateNotificationInfo(type_state_map);
+ debug_info_event_listener_.OnIncomingNotification(type_state_map);
} else {
LOG(WARNING) << "Sync received notification without any type information.";
}
@@ -1304,8 +1304,8 @@ void SyncManagerImpl::OnIncomingNotification(
DictionaryValue details;
ListValue* changed_types = new ListValue();
details.Set("changedTypes", changed_types);
- for (ModelTypePayloadMap::const_iterator it = type_payloads.begin();
- it != type_payloads.end(); ++it) {
+ for (ModelTypeStateMap::const_iterator it = type_state_map.begin();
+ it != type_state_map.end(); ++it) {
const std::string& model_type_str =
ModelTypeToString(it->first);
changed_types->Append(Value::CreateStringValue(model_type_str));
diff --git a/sync/internal_api/sync_manager_impl.h b/sync/internal_api/sync_manager_impl.h
index 7b2a6c4..b0ed231 100644
--- a/sync/internal_api/sync_manager_impl.h
+++ b/sync/internal_api/sync_manager_impl.h
@@ -171,7 +171,7 @@ class SyncManagerImpl : public SyncManager,
virtual void OnNotificationsDisabled(
NotificationsDisabledReason reason) OVERRIDE;
virtual void OnIncomingNotification(
- const ObjectIdPayloadMap& id_payloads,
+ const ObjectIdStateMap& id_state_map,
IncomingNotificationSource source) OVERRIDE;
// Called only by our NetworkChangeNotifier.
@@ -255,7 +255,7 @@ class SyncManagerImpl : public SyncManager,
// Called for every notification. This updates the notification statistics
// to be displayed in about:sync.
void UpdateNotificationInfo(
- const ModelTypePayloadMap& type_payloads);
+ const ModelTypeStateMap& type_state_map);
// Checks for server reachabilty and requests a nudge.
void OnIPAddressChangedImpl();
diff --git a/sync/internal_api/sync_manager_impl_unittest.cc b/sync/internal_api/sync_manager_impl_unittest.cc
index 48b81c1..dc3ea15 100644
--- a/sync/internal_api/sync_manager_impl_unittest.cc
+++ b/sync/internal_api/sync_manager_impl_unittest.cc
@@ -942,10 +942,10 @@ class SyncManagerTest : public testing::Test,
void TriggerOnIncomingNotificationForTest(ModelTypeSet model_types) {
DCHECK(sync_manager_.thread_checker_.CalledOnValidThread());
- ModelTypePayloadMap model_types_with_payloads =
- ModelTypePayloadMapFromEnumSet(model_types, std::string());
+ ModelTypeStateMap type_state_map =
+ ModelTypeSetToStateMap(model_types, std::string());
sync_manager_.OnIncomingNotification(
- ModelTypePayloadMapToObjectIdPayloadMap(model_types_with_payloads),
+ ModelTypeStateMapToObjectIdStateMap(type_state_map),
REMOTE_NOTIFICATION);
}
diff --git a/sync/internal_api/test/fake_sync_manager.cc b/sync/internal_api/test/fake_sync_manager.cc
index 97e729e..6bf55fc 100644
--- a/sync/internal_api/test/fake_sync_manager.cc
+++ b/sync/internal_api/test/fake_sync_manager.cc
@@ -17,7 +17,7 @@
#include "sync/internal_api/public/internal_components_factory.h"
#include "sync/internal_api/public/util/weak_handle.h"
#include "sync/notifier/notifications_disabled_reason.h"
-#include "sync/notifier/object_id_payload_map.h"
+#include "sync/notifier/object_id_state_map.h"
#include "sync/notifier/sync_notifier.h"
#include "sync/test/fake_sync_encryption_handler.h"
@@ -52,12 +52,12 @@ ModelTypeSet FakeSyncManager::GetAndResetEnabledTypes() {
return enabled_types;
}
-void FakeSyncManager::Invalidate(const ObjectIdPayloadMap& id_payloads,
+void FakeSyncManager::Invalidate(const ObjectIdStateMap& id_state_map,
IncomingNotificationSource source) {
if (!sync_task_runner_->PostTask(
FROM_HERE,
base::Bind(&FakeSyncManager::InvalidateOnSyncThread,
- base::Unretained(this), id_payloads, source))) {
+ base::Unretained(this), id_state_map, source))) {
NOTREACHED();
}
}
@@ -265,10 +265,10 @@ SyncEncryptionHandler* FakeSyncManager::GetEncryptionHandler() {
}
void FakeSyncManager::InvalidateOnSyncThread(
- const ObjectIdPayloadMap& id_payloads,
+ const ObjectIdStateMap& id_state_map,
IncomingNotificationSource source) {
DCHECK(sync_task_runner_->RunsTasksOnCurrentThread());
- registrar_.DispatchInvalidationsToHandlers(id_payloads, source);
+ registrar_.DispatchInvalidationsToHandlers(id_state_map, source);
}
void FakeSyncManager::EnableNotificationsOnSyncThread() {