summaryrefslogtreecommitdiff
path: root/chromium/sync/sessions
diff options
context:
space:
mode:
authorAndras Becsi <andras.becsi@digia.com>2014-03-18 13:16:26 +0100
committerFrederik Gladhorn <frederik.gladhorn@digia.com>2014-03-20 15:55:39 +0100
commit3f0f86b0caed75241fa71c95a5d73bc0164348c5 (patch)
tree92b9fb00f2e9e90b0be2262093876d4f43b6cd13 /chromium/sync/sessions
parente90d7c4b152c56919d963987e2503f9909a666d2 (diff)
downloadqtwebengine-chromium-3f0f86b0caed75241fa71c95a5d73bc0164348c5.tar.gz
Update to new stable branch 1750
This also includes an updated ninja and chromium dependencies needed on Windows. Change-Id: Icd597d80ed3fa4425933c9f1334c3c2e31291c42 Reviewed-by: Zoltan Arvai <zarvai@inf.u-szeged.hu> Reviewed-by: Zeno Albisser <zeno.albisser@digia.com>
Diffstat (limited to 'chromium/sync/sessions')
-rw-r--r--chromium/sync/sessions/data_type_tracker.cc23
-rw-r--r--chromium/sync/sessions/data_type_tracker.h9
-rw-r--r--chromium/sync/sessions/debug_info_getter.h11
-rw-r--r--chromium/sync/sessions/nudge_tracker.cc13
-rw-r--r--chromium/sync/sessions/nudge_tracker.h4
-rw-r--r--chromium/sync/sessions/nudge_tracker_unittest.cc305
-rw-r--r--chromium/sync/sessions/ordered_commit_set.cc131
-rw-r--r--chromium/sync/sessions/ordered_commit_set.h128
-rw-r--r--chromium/sync/sessions/ordered_commit_set_unittest.cc134
-rw-r--r--chromium/sync/sessions/status_controller.cc42
-rw-r--r--chromium/sync/sessions/status_controller.h99
-rw-r--r--chromium/sync/sessions/status_controller_unittest.cc19
-rw-r--r--chromium/sync/sessions/sync_session.h20
-rw-r--r--chromium/sync/sessions/sync_session_context.cc38
-rw-r--r--chromium/sync/sessions/sync_session_context.h56
-rw-r--r--chromium/sync/sessions/sync_session_unittest.cc35
16 files changed, 274 insertions, 793 deletions
diff --git a/chromium/sync/sessions/data_type_tracker.cc b/chromium/sync/sessions/data_type_tracker.cc
index a061679839f..b0b464923ce 100644
--- a/chromium/sync/sessions/data_type_tracker.cc
+++ b/chromium/sync/sessions/data_type_tracker.cc
@@ -5,6 +5,8 @@
#include "sync/sessions/data_type_tracker.h"
#include "base/logging.h"
+#include "sync/internal_api/public/base/invalidation.h"
+#include "sync/notifier/single_object_invalidation_set.h"
#include "sync/sessions/nudge_tracker.h"
namespace syncer {
@@ -27,13 +29,20 @@ void DataTypeTracker::RecordLocalRefreshRequest() {
local_refresh_request_count_++;
}
-void DataTypeTracker::RecordRemoteInvalidation(
- const std::string& payload) {
- pending_payloads_.push_back(payload);
- if (pending_payloads_.size() > payload_buffer_size_) {
- // Drop the oldest payload if we've overflowed.
- pending_payloads_.pop_front();
- local_payload_overflow_ = true;
+void DataTypeTracker::RecordRemoteInvalidations(
+ const SingleObjectInvalidationSet& invalidations) {
+ for (SingleObjectInvalidationSet::const_iterator it =
+ invalidations.begin(); it != invalidations.end(); ++it) {
+ if (it->is_unknown_version()) {
+ server_payload_overflow_ = true;
+ } else {
+ pending_payloads_.push_back(it->payload());
+ if (pending_payloads_.size() > payload_buffer_size_) {
+ // Drop the oldest payload if we've overflowed.
+ pending_payloads_.pop_front();
+ local_payload_overflow_ = true;
+ }
+ }
}
}
diff --git a/chromium/sync/sessions/data_type_tracker.h b/chromium/sync/sessions/data_type_tracker.h
index 30bc3b6dbbc..6ecaa0eb7c8 100644
--- a/chromium/sync/sessions/data_type_tracker.h
+++ b/chromium/sync/sessions/data_type_tracker.h
@@ -14,6 +14,10 @@
#include "sync/protocol/sync.pb.h"
namespace syncer {
+
+class Invalidation;
+class SingleObjectInvalidationSet;
+
namespace sessions {
typedef std::deque<std::string> PayloadList;
@@ -32,8 +36,9 @@ class DataTypeTracker {
// Tracks that a local refresh request has been made for this type.
void RecordLocalRefreshRequest();
- // Tracks that we received an invalidation notification for this type.
- void RecordRemoteInvalidation(const std::string& payload);
+ // Tracks that we received invalidation notifications for this type.
+ void RecordRemoteInvalidations(
+ const SingleObjectInvalidationSet& invalidations);
// Records that a sync cycle has been performed successfully.
// Generally, this means that all local changes have been committed and all
diff --git a/chromium/sync/sessions/debug_info_getter.h b/chromium/sync/sessions/debug_info_getter.h
index c1536ba50c8..7efe0cb649f 100644
--- a/chromium/sync/sessions/debug_info_getter.h
+++ b/chromium/sync/sessions/debug_info_getter.h
@@ -15,9 +15,13 @@ namespace sessions {
// to communicate the debug info data to the syncer.
class SYNC_EXPORT_PRIVATE DebugInfoGetter {
public:
- // Gets the client debug info and clears the state so the same data is not
- // sent again.
- virtual void GetAndClearDebugInfo(sync_pb::DebugInfo* debug_info) = 0;
+ // Gets the client debug info. Be sure to clear the info to ensure the data
+ // isn't sent multiple times.
+ virtual void GetDebugInfo(sync_pb::DebugInfo* debug_info) = 0;
+
+ // Clears the debug info.
+ virtual void ClearDebugInfo() = 0;
+
virtual ~DebugInfoGetter() {}
};
@@ -25,4 +29,3 @@ class SYNC_EXPORT_PRIVATE DebugInfoGetter {
} // namespace syncer
#endif // SYNC_SESSIONS_DEBUG_INFO_GETTER_H_
-
diff --git a/chromium/sync/sessions/nudge_tracker.cc b/chromium/sync/sessions/nudge_tracker.cc
index 8ec8970ef36..94bef81a350 100644
--- a/chromium/sync/sessions/nudge_tracker.cc
+++ b/chromium/sync/sessions/nudge_tracker.cc
@@ -40,6 +40,8 @@ bool NudgeTracker::IsSyncRequired() const {
}
bool NudgeTracker::IsGetUpdatesRequired() const {
+ if (invalidations_out_of_sync_)
+ return true;
for (TypeTrackerMap::const_iterator it = type_trackers_.begin();
it != type_trackers_.end(); ++it) {
if (it->second.IsGetUpdatesRequired()) {
@@ -96,16 +98,17 @@ void NudgeTracker::RecordRemoteInvalidation(
const ObjectIdInvalidationMap& invalidation_map) {
updates_source_ = sync_pb::GetUpdatesCallerInfo::NOTIFICATION;
- for (ObjectIdInvalidationMap::const_iterator it = invalidation_map.begin();
- it != invalidation_map.end(); ++it) {
+ ObjectIdSet ids = invalidation_map.GetObjectIds();
+ for (ObjectIdSet::const_iterator it = ids.begin(); it != ids.end(); ++it) {
ModelType type;
- if (!ObjectIdToRealModelType(it->first, &type)) {
+ if (!ObjectIdToRealModelType(*it, &type)) {
NOTREACHED()
- << "Object ID " << ObjectIdToString(it->first)
+ << "Object ID " << ObjectIdToString(*it)
<< " does not map to valid model type";
}
DCHECK(type_trackers_.find(type) != type_trackers_.end());
- type_trackers_[type].RecordRemoteInvalidation(it->second.payload);
+ type_trackers_[type].RecordRemoteInvalidations(
+ invalidation_map.ForObject(*it));
}
}
diff --git a/chromium/sync/sessions/nudge_tracker.h b/chromium/sync/sessions/nudge_tracker.h
index aa4414cb7ae..fcd01503410 100644
--- a/chromium/sync/sessions/nudge_tracker.h
+++ b/chromium/sync/sessions/nudge_tracker.h
@@ -13,11 +13,13 @@
#include "base/compiler_specific.h"
#include "sync/base/sync_export.h"
#include "sync/internal_api/public/base/model_type.h"
-#include "sync/notifier/object_id_invalidation_map.h"
#include "sync/protocol/sync.pb.h"
#include "sync/sessions/data_type_tracker.h"
namespace syncer {
+
+class ObjectIdInvalidationMap;
+
namespace sessions {
class SYNC_EXPORT_PRIVATE NudgeTracker {
diff --git a/chromium/sync/sessions/nudge_tracker_unittest.cc b/chromium/sync/sessions/nudge_tracker_unittest.cc
index ea7f4c74765..450d17fe3da 100644
--- a/chromium/sync/sessions/nudge_tracker_unittest.cc
+++ b/chromium/sync/sessions/nudge_tracker_unittest.cc
@@ -3,6 +3,8 @@
// found in the LICENSE file.
#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/nudge_tracker.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -26,97 +28,102 @@ namespace sessions {
class NudgeTrackerTest : public ::testing::Test {
public:
+ NudgeTrackerTest() {
+ SetInvalidationsInSync();
+ }
+
static size_t GetHintBufferSize() {
// Assumes that no test has adjusted this size.
return NudgeTracker::kDefaultMaxPayloadsPerType;
}
- bool InvalidationsOutOfSync(const NudgeTracker& nudge_tracker) {
+ bool InvalidationsOutOfSync() const {
// We don't currently track invalidations out of sync on a per-type basis.
sync_pb::GetUpdateTriggers gu_trigger;
- nudge_tracker.FillProtoMessage(BOOKMARKS, &gu_trigger);
+ nudge_tracker_.FillProtoMessage(BOOKMARKS, &gu_trigger);
return gu_trigger.invalidations_out_of_sync();
}
- int ProtoLocallyModifiedCount(const NudgeTracker& nudge_tracker,
- ModelType type) {
+ int ProtoLocallyModifiedCount(ModelType type) const {
sync_pb::GetUpdateTriggers gu_trigger;
- nudge_tracker.FillProtoMessage(type, &gu_trigger);
+ nudge_tracker_.FillProtoMessage(type, &gu_trigger);
return gu_trigger.local_modification_nudges();
}
- int ProtoRefreshRequestedCount(const NudgeTracker& nudge_tracker,
- ModelType type) {
+ int ProtoRefreshRequestedCount(ModelType type) const {
sync_pb::GetUpdateTriggers gu_trigger;
- nudge_tracker.FillProtoMessage(type, &gu_trigger);
+ nudge_tracker_.FillProtoMessage(type, &gu_trigger);
return gu_trigger.datatype_refresh_nudges();
}
+
+ void SetInvalidationsInSync() {
+ nudge_tracker_.OnInvalidationsEnabled();
+ nudge_tracker_.RecordSuccessfulSyncCycle();
+ }
+
+ protected:
+ NudgeTracker nudge_tracker_;
};
// Exercise an empty NudgeTracker.
// Use with valgrind to detect uninitialized members.
TEST_F(NudgeTrackerTest, EmptyNudgeTracker) {
- NudgeTracker nudge_tracker;
-
- EXPECT_FALSE(nudge_tracker.IsSyncRequired());
- EXPECT_FALSE(nudge_tracker.IsGetUpdatesRequired());
+ // Now we're at the normal, "idle" state.
+ EXPECT_FALSE(nudge_tracker_.IsSyncRequired());
+ EXPECT_FALSE(nudge_tracker_.IsGetUpdatesRequired());
EXPECT_EQ(sync_pb::GetUpdatesCallerInfo::UNKNOWN,
- nudge_tracker.updates_source());
+ nudge_tracker_.updates_source());
sync_pb::GetUpdateTriggers gu_trigger;
- nudge_tracker.FillProtoMessage(BOOKMARKS, &gu_trigger);
+ nudge_tracker_.FillProtoMessage(BOOKMARKS, &gu_trigger);
EXPECT_EQ(sync_pb::GetUpdatesCallerInfo::UNKNOWN,
- nudge_tracker.updates_source());
+ nudge_tracker_.updates_source());
}
// Verify that nudges override each other based on a priority order.
// LOCAL < DATATYPE_REFRESH < NOTIFICATION
TEST_F(NudgeTrackerTest, SourcePriorities) {
- NudgeTracker nudge_tracker;
-
// Track a local nudge.
- nudge_tracker.RecordLocalChange(ModelTypeSet(BOOKMARKS));
+ nudge_tracker_.RecordLocalChange(ModelTypeSet(BOOKMARKS));
EXPECT_EQ(sync_pb::GetUpdatesCallerInfo::LOCAL,
- nudge_tracker.updates_source());
+ nudge_tracker_.updates_source());
// A refresh request will override it.
- nudge_tracker.RecordLocalRefreshRequest(ModelTypeSet(TYPED_URLS));
+ nudge_tracker_.RecordLocalRefreshRequest(ModelTypeSet(TYPED_URLS));
EXPECT_EQ(sync_pb::GetUpdatesCallerInfo::DATATYPE_REFRESH,
- nudge_tracker.updates_source());
+ nudge_tracker_.updates_source());
// Another local nudge will not be enough to change it.
- nudge_tracker.RecordLocalChange(ModelTypeSet(BOOKMARKS));
+ nudge_tracker_.RecordLocalChange(ModelTypeSet(BOOKMARKS));
EXPECT_EQ(sync_pb::GetUpdatesCallerInfo::DATATYPE_REFRESH,
- nudge_tracker.updates_source());
+ nudge_tracker_.updates_source());
// An invalidation will override the refresh request source.
ObjectIdInvalidationMap invalidation_map =
BuildInvalidationMap(PREFERENCES, 1, "hint");
- nudge_tracker.RecordRemoteInvalidation(invalidation_map);
+ nudge_tracker_.RecordRemoteInvalidation(invalidation_map);
EXPECT_EQ(sync_pb::GetUpdatesCallerInfo::NOTIFICATION,
- nudge_tracker.updates_source());
+ nudge_tracker_.updates_source());
// Neither local nudges nor refresh requests will override it.
- nudge_tracker.RecordLocalChange(ModelTypeSet(BOOKMARKS));
+ nudge_tracker_.RecordLocalChange(ModelTypeSet(BOOKMARKS));
EXPECT_EQ(sync_pb::GetUpdatesCallerInfo::NOTIFICATION,
- nudge_tracker.updates_source());
- nudge_tracker.RecordLocalRefreshRequest(ModelTypeSet(TYPED_URLS));
+ nudge_tracker_.updates_source());
+ nudge_tracker_.RecordLocalRefreshRequest(ModelTypeSet(TYPED_URLS));
EXPECT_EQ(sync_pb::GetUpdatesCallerInfo::NOTIFICATION,
- nudge_tracker.updates_source());
+ nudge_tracker_.updates_source());
}
TEST_F(NudgeTrackerTest, HintCoalescing) {
- NudgeTracker nudge_tracker;
-
// Easy case: record one hint.
{
ObjectIdInvalidationMap invalidation_map =
BuildInvalidationMap(BOOKMARKS, 1, "bm_hint_1");
- nudge_tracker.RecordRemoteInvalidation(invalidation_map);
+ nudge_tracker_.RecordRemoteInvalidation(invalidation_map);
sync_pb::GetUpdateTriggers gu_trigger;
- nudge_tracker.FillProtoMessage(BOOKMARKS, &gu_trigger);
+ nudge_tracker_.FillProtoMessage(BOOKMARKS, &gu_trigger);
ASSERT_EQ(1, gu_trigger.notification_hint_size());
EXPECT_EQ("bm_hint_1", gu_trigger.notification_hint(0));
EXPECT_FALSE(gu_trigger.client_dropped_hints());
@@ -126,10 +133,10 @@ TEST_F(NudgeTrackerTest, HintCoalescing) {
{
ObjectIdInvalidationMap invalidation_map =
BuildInvalidationMap(BOOKMARKS, 2, "bm_hint_2");
- nudge_tracker.RecordRemoteInvalidation(invalidation_map);
+ nudge_tracker_.RecordRemoteInvalidation(invalidation_map);
sync_pb::GetUpdateTriggers gu_trigger;
- nudge_tracker.FillProtoMessage(BOOKMARKS, &gu_trigger);
+ nudge_tracker_.FillProtoMessage(BOOKMARKS, &gu_trigger);
ASSERT_EQ(2, gu_trigger.notification_hint_size());
// Expect the most hint recent is last in the list.
@@ -142,11 +149,11 @@ TEST_F(NudgeTrackerTest, HintCoalescing) {
{
ObjectIdInvalidationMap invalidation_map =
BuildInvalidationMap(PASSWORDS, 1, "pw_hint_1");
- nudge_tracker.RecordRemoteInvalidation(invalidation_map);
+ nudge_tracker_.RecordRemoteInvalidation(invalidation_map);
// Re-verify the bookmarks to make sure they're unaffected.
sync_pb::GetUpdateTriggers bm_gu_trigger;
- nudge_tracker.FillProtoMessage(BOOKMARKS, &bm_gu_trigger);
+ nudge_tracker_.FillProtoMessage(BOOKMARKS, &bm_gu_trigger);
ASSERT_EQ(2, bm_gu_trigger.notification_hint_size());
EXPECT_EQ("bm_hint_1", bm_gu_trigger.notification_hint(0));
EXPECT_EQ("bm_hint_2",
@@ -155,7 +162,7 @@ TEST_F(NudgeTrackerTest, HintCoalescing) {
// Verify the new type, too.
sync_pb::GetUpdateTriggers pw_gu_trigger;
- nudge_tracker.FillProtoMessage(PASSWORDS, &pw_gu_trigger);
+ nudge_tracker_.FillProtoMessage(PASSWORDS, &pw_gu_trigger);
ASSERT_EQ(1, pw_gu_trigger.notification_hint_size());
EXPECT_EQ("pw_hint_1", pw_gu_trigger.notification_hint(0));
EXPECT_FALSE(pw_gu_trigger.client_dropped_hints());
@@ -163,16 +170,15 @@ TEST_F(NudgeTrackerTest, HintCoalescing) {
}
TEST_F(NudgeTrackerTest, DropHintsLocally) {
- NudgeTracker nudge_tracker;
ObjectIdInvalidationMap invalidation_map =
BuildInvalidationMap(BOOKMARKS, 1, "hint");
for (size_t i = 0; i < GetHintBufferSize(); ++i) {
- nudge_tracker.RecordRemoteInvalidation(invalidation_map);
+ nudge_tracker_.RecordRemoteInvalidation(invalidation_map);
}
{
sync_pb::GetUpdateTriggers gu_trigger;
- nudge_tracker.FillProtoMessage(BOOKMARKS, &gu_trigger);
+ nudge_tracker_.FillProtoMessage(BOOKMARKS, &gu_trigger);
EXPECT_EQ(GetHintBufferSize(),
static_cast<size_t>(gu_trigger.notification_hint_size()));
EXPECT_FALSE(gu_trigger.client_dropped_hints());
@@ -181,11 +187,11 @@ TEST_F(NudgeTrackerTest, DropHintsLocally) {
// Force an overflow.
ObjectIdInvalidationMap invalidation_map2 =
BuildInvalidationMap(BOOKMARKS, 1000, "new_hint");
- nudge_tracker.RecordRemoteInvalidation(invalidation_map2);
+ nudge_tracker_.RecordRemoteInvalidation(invalidation_map2);
{
sync_pb::GetUpdateTriggers gu_trigger;
- nudge_tracker.FillProtoMessage(BOOKMARKS, &gu_trigger);
+ nudge_tracker_.FillProtoMessage(BOOKMARKS, &gu_trigger);
EXPECT_EQ(GetHintBufferSize(),
static_cast<size_t>(gu_trigger.notification_hint_size()));
EXPECT_TRUE(gu_trigger.client_dropped_hints());
@@ -203,225 +209,218 @@ TEST_F(NudgeTrackerTest, DropHintsLocally) {
// Checks the behaviour of the invalidations-out-of-sync flag.
TEST_F(NudgeTrackerTest, EnableDisableInvalidations) {
- NudgeTracker nudge_tracker;
-
- // By default, assume we're out of sync with the invalidation server.
- EXPECT_TRUE(InvalidationsOutOfSync(nudge_tracker));
+ // Start with invalidations offline.
+ nudge_tracker_.OnInvalidationsDisabled();
+ EXPECT_TRUE(InvalidationsOutOfSync());
+ EXPECT_TRUE(nudge_tracker_.IsGetUpdatesRequired());
// Simply enabling invalidations does not bring us back into sync.
- nudge_tracker.OnInvalidationsEnabled();
- EXPECT_TRUE(InvalidationsOutOfSync(nudge_tracker));
+ nudge_tracker_.OnInvalidationsEnabled();
+ EXPECT_TRUE(InvalidationsOutOfSync());
+ EXPECT_TRUE(nudge_tracker_.IsGetUpdatesRequired());
// We must successfully complete a sync cycle while invalidations are enabled
// to be sure that we're in sync.
- nudge_tracker.RecordSuccessfulSyncCycle();
- EXPECT_FALSE(InvalidationsOutOfSync(nudge_tracker));
+ nudge_tracker_.RecordSuccessfulSyncCycle();
+ EXPECT_FALSE(InvalidationsOutOfSync());
+ EXPECT_FALSE(nudge_tracker_.IsGetUpdatesRequired());
// If the invalidator malfunctions, we go become unsynced again.
- nudge_tracker.OnInvalidationsDisabled();
- EXPECT_TRUE(InvalidationsOutOfSync(nudge_tracker));
+ nudge_tracker_.OnInvalidationsDisabled();
+ EXPECT_TRUE(InvalidationsOutOfSync());
+ EXPECT_TRUE(nudge_tracker_.IsGetUpdatesRequired());
// A sync cycle while invalidations are disabled won't reset the flag.
- nudge_tracker.RecordSuccessfulSyncCycle();
- EXPECT_TRUE(InvalidationsOutOfSync(nudge_tracker));
+ nudge_tracker_.RecordSuccessfulSyncCycle();
+ EXPECT_TRUE(InvalidationsOutOfSync());
+ EXPECT_TRUE(nudge_tracker_.IsGetUpdatesRequired());
// Nor will the re-enabling of invalidations be sufficient, even now that
// we've had a successful sync cycle.
- nudge_tracker.RecordSuccessfulSyncCycle();
- EXPECT_TRUE(InvalidationsOutOfSync(nudge_tracker));
+ nudge_tracker_.RecordSuccessfulSyncCycle();
+ EXPECT_TRUE(InvalidationsOutOfSync());
+ EXPECT_TRUE(nudge_tracker_.IsGetUpdatesRequired());
}
// Tests that locally modified types are correctly written out to the
// GetUpdateTriggers proto.
TEST_F(NudgeTrackerTest, WriteLocallyModifiedTypesToProto) {
- NudgeTracker nudge_tracker;
-
// Should not be locally modified by default.
- EXPECT_EQ(0, ProtoLocallyModifiedCount(nudge_tracker, PREFERENCES));
+ EXPECT_EQ(0, ProtoLocallyModifiedCount(PREFERENCES));
// Record a local bookmark change. Verify it was registered correctly.
- nudge_tracker.RecordLocalChange(ModelTypeSet(PREFERENCES));
- EXPECT_EQ(1, ProtoLocallyModifiedCount(nudge_tracker, PREFERENCES));
+ nudge_tracker_.RecordLocalChange(ModelTypeSet(PREFERENCES));
+ EXPECT_EQ(1, ProtoLocallyModifiedCount(PREFERENCES));
// Record a successful sync cycle. Verify the count is cleared.
- nudge_tracker.RecordSuccessfulSyncCycle();
- EXPECT_EQ(0, ProtoLocallyModifiedCount(nudge_tracker, PREFERENCES));
+ nudge_tracker_.RecordSuccessfulSyncCycle();
+ EXPECT_EQ(0, ProtoLocallyModifiedCount(PREFERENCES));
}
// Tests that refresh requested types are correctly written out to the
// GetUpdateTriggers proto.
TEST_F(NudgeTrackerTest, WriteRefreshRequestedTypesToProto) {
- NudgeTracker nudge_tracker;
-
// There should be no refresh requested by default.
- EXPECT_EQ(0, ProtoRefreshRequestedCount(nudge_tracker, SESSIONS));
+ EXPECT_EQ(0, ProtoRefreshRequestedCount(SESSIONS));
// Record a local refresh request. Verify it was registered correctly.
- nudge_tracker.RecordLocalRefreshRequest(ModelTypeSet(SESSIONS));
- EXPECT_EQ(1, ProtoRefreshRequestedCount(nudge_tracker, SESSIONS));
+ nudge_tracker_.RecordLocalRefreshRequest(ModelTypeSet(SESSIONS));
+ EXPECT_EQ(1, ProtoRefreshRequestedCount(SESSIONS));
// Record a successful sync cycle. Verify the count is cleared.
- nudge_tracker.RecordSuccessfulSyncCycle();
- EXPECT_EQ(0, ProtoRefreshRequestedCount(nudge_tracker, SESSIONS));
+ nudge_tracker_.RecordSuccessfulSyncCycle();
+ EXPECT_EQ(0, ProtoRefreshRequestedCount(SESSIONS));
}
// Basic tests for the IsSyncRequired() flag.
TEST_F(NudgeTrackerTest, IsSyncRequired) {
- NudgeTracker nudge_tracker;
- EXPECT_FALSE(nudge_tracker.IsSyncRequired());
+ EXPECT_FALSE(nudge_tracker_.IsSyncRequired());
// Local changes.
- nudge_tracker.RecordLocalChange(ModelTypeSet(SESSIONS));
- EXPECT_TRUE(nudge_tracker.IsSyncRequired());
- nudge_tracker.RecordSuccessfulSyncCycle();
- EXPECT_FALSE(nudge_tracker.IsSyncRequired());
+ nudge_tracker_.RecordLocalChange(ModelTypeSet(SESSIONS));
+ EXPECT_TRUE(nudge_tracker_.IsSyncRequired());
+ nudge_tracker_.RecordSuccessfulSyncCycle();
+ EXPECT_FALSE(nudge_tracker_.IsSyncRequired());
// Refresh requests.
- nudge_tracker.RecordLocalRefreshRequest(ModelTypeSet(SESSIONS));
- EXPECT_TRUE(nudge_tracker.IsSyncRequired());
- nudge_tracker.RecordSuccessfulSyncCycle();
- EXPECT_FALSE(nudge_tracker.IsSyncRequired());
+ nudge_tracker_.RecordLocalRefreshRequest(ModelTypeSet(SESSIONS));
+ EXPECT_TRUE(nudge_tracker_.IsSyncRequired());
+ nudge_tracker_.RecordSuccessfulSyncCycle();
+ EXPECT_FALSE(nudge_tracker_.IsSyncRequired());
// Invalidations.
ObjectIdInvalidationMap invalidation_map =
BuildInvalidationMap(PREFERENCES, 1, "hint");
- nudge_tracker.RecordRemoteInvalidation(invalidation_map);
- EXPECT_TRUE(nudge_tracker.IsSyncRequired());
- nudge_tracker.RecordSuccessfulSyncCycle();
- EXPECT_FALSE(nudge_tracker.IsSyncRequired());
+ nudge_tracker_.RecordRemoteInvalidation(invalidation_map);
+ EXPECT_TRUE(nudge_tracker_.IsSyncRequired());
+ nudge_tracker_.RecordSuccessfulSyncCycle();
+ EXPECT_FALSE(nudge_tracker_.IsSyncRequired());
}
// Basic tests for the IsGetUpdatesRequired() flag.
TEST_F(NudgeTrackerTest, IsGetUpdatesRequired) {
- NudgeTracker nudge_tracker;
- EXPECT_FALSE(nudge_tracker.IsGetUpdatesRequired());
+ EXPECT_FALSE(nudge_tracker_.IsGetUpdatesRequired());
// Local changes.
- nudge_tracker.RecordLocalChange(ModelTypeSet(SESSIONS));
- EXPECT_FALSE(nudge_tracker.IsGetUpdatesRequired());
- nudge_tracker.RecordSuccessfulSyncCycle();
- EXPECT_FALSE(nudge_tracker.IsGetUpdatesRequired());
+ nudge_tracker_.RecordLocalChange(ModelTypeSet(SESSIONS));
+ EXPECT_FALSE(nudge_tracker_.IsGetUpdatesRequired());
+ nudge_tracker_.RecordSuccessfulSyncCycle();
+ EXPECT_FALSE(nudge_tracker_.IsGetUpdatesRequired());
// Refresh requests.
- nudge_tracker.RecordLocalRefreshRequest(ModelTypeSet(SESSIONS));
- EXPECT_TRUE(nudge_tracker.IsGetUpdatesRequired());
- nudge_tracker.RecordSuccessfulSyncCycle();
- EXPECT_FALSE(nudge_tracker.IsGetUpdatesRequired());
+ nudge_tracker_.RecordLocalRefreshRequest(ModelTypeSet(SESSIONS));
+ EXPECT_TRUE(nudge_tracker_.IsGetUpdatesRequired());
+ nudge_tracker_.RecordSuccessfulSyncCycle();
+ EXPECT_FALSE(nudge_tracker_.IsGetUpdatesRequired());
// Invalidations.
ObjectIdInvalidationMap invalidation_map =
BuildInvalidationMap(PREFERENCES, 1, "hint");
- nudge_tracker.RecordRemoteInvalidation(invalidation_map);
- EXPECT_TRUE(nudge_tracker.IsGetUpdatesRequired());
- nudge_tracker.RecordSuccessfulSyncCycle();
- EXPECT_FALSE(nudge_tracker.IsGetUpdatesRequired());
+ nudge_tracker_.RecordRemoteInvalidation(invalidation_map);
+ EXPECT_TRUE(nudge_tracker_.IsGetUpdatesRequired());
+ nudge_tracker_.RecordSuccessfulSyncCycle();
+ EXPECT_FALSE(nudge_tracker_.IsGetUpdatesRequired());
}
// Test IsSyncRequired() responds correctly to data type throttling.
TEST_F(NudgeTrackerTest, IsSyncRequired_Throttling) {
- NudgeTracker nudge_tracker;
const base::TimeTicks t0 = base::TimeTicks::FromInternalValue(1234);
const base::TimeDelta throttle_length = base::TimeDelta::FromMinutes(10);
const base::TimeTicks t1 = t0 + throttle_length;
- EXPECT_FALSE(nudge_tracker.IsSyncRequired());
+ EXPECT_FALSE(nudge_tracker_.IsSyncRequired());
// A local change to sessions enables the flag.
- nudge_tracker.RecordLocalChange(ModelTypeSet(SESSIONS));
- EXPECT_TRUE(nudge_tracker.IsSyncRequired());
+ nudge_tracker_.RecordLocalChange(ModelTypeSet(SESSIONS));
+ EXPECT_TRUE(nudge_tracker_.IsSyncRequired());
// But the throttling of sessions unsets it.
- nudge_tracker.SetTypesThrottledUntil(ModelTypeSet(SESSIONS),
+ nudge_tracker_.SetTypesThrottledUntil(ModelTypeSet(SESSIONS),
throttle_length,
t0);
- EXPECT_FALSE(nudge_tracker.IsSyncRequired());
+ EXPECT_FALSE(nudge_tracker_.IsSyncRequired());
// A refresh request for bookmarks means we have reason to sync again.
- nudge_tracker.RecordLocalRefreshRequest(ModelTypeSet(BOOKMARKS));
- EXPECT_TRUE(nudge_tracker.IsSyncRequired());
+ nudge_tracker_.RecordLocalRefreshRequest(ModelTypeSet(BOOKMARKS));
+ EXPECT_TRUE(nudge_tracker_.IsSyncRequired());
// A successful sync cycle means we took care of bookmarks.
- nudge_tracker.RecordSuccessfulSyncCycle();
- EXPECT_FALSE(nudge_tracker.IsSyncRequired());
+ nudge_tracker_.RecordSuccessfulSyncCycle();
+ EXPECT_FALSE(nudge_tracker_.IsSyncRequired());
// But we still haven't dealt with sessions. We'll need to remember
// that sessions are out of sync and re-enable the flag when their
// throttling interval expires.
- nudge_tracker.UpdateTypeThrottlingState(t1);
- EXPECT_FALSE(nudge_tracker.IsTypeThrottled(SESSIONS));
- EXPECT_TRUE(nudge_tracker.IsSyncRequired());
+ nudge_tracker_.UpdateTypeThrottlingState(t1);
+ EXPECT_FALSE(nudge_tracker_.IsTypeThrottled(SESSIONS));
+ EXPECT_TRUE(nudge_tracker_.IsSyncRequired());
}
// Test IsGetUpdatesRequired() responds correctly to data type throttling.
TEST_F(NudgeTrackerTest, IsGetUpdatesRequired_Throttling) {
- NudgeTracker nudge_tracker;
const base::TimeTicks t0 = base::TimeTicks::FromInternalValue(1234);
const base::TimeDelta throttle_length = base::TimeDelta::FromMinutes(10);
const base::TimeTicks t1 = t0 + throttle_length;
- EXPECT_FALSE(nudge_tracker.IsGetUpdatesRequired());
+ EXPECT_FALSE(nudge_tracker_.IsGetUpdatesRequired());
// A refresh request to sessions enables the flag.
- nudge_tracker.RecordLocalRefreshRequest(ModelTypeSet(SESSIONS));
- EXPECT_TRUE(nudge_tracker.IsGetUpdatesRequired());
+ nudge_tracker_.RecordLocalRefreshRequest(ModelTypeSet(SESSIONS));
+ EXPECT_TRUE(nudge_tracker_.IsGetUpdatesRequired());
// But the throttling of sessions unsets it.
- nudge_tracker.SetTypesThrottledUntil(ModelTypeSet(SESSIONS),
+ nudge_tracker_.SetTypesThrottledUntil(ModelTypeSet(SESSIONS),
throttle_length,
t0);
- EXPECT_FALSE(nudge_tracker.IsGetUpdatesRequired());
+ EXPECT_FALSE(nudge_tracker_.IsGetUpdatesRequired());
// A refresh request for bookmarks means we have reason to sync again.
- nudge_tracker.RecordLocalRefreshRequest(ModelTypeSet(BOOKMARKS));
- EXPECT_TRUE(nudge_tracker.IsGetUpdatesRequired());
+ nudge_tracker_.RecordLocalRefreshRequest(ModelTypeSet(BOOKMARKS));
+ EXPECT_TRUE(nudge_tracker_.IsGetUpdatesRequired());
// A successful sync cycle means we took care of bookmarks.
- nudge_tracker.RecordSuccessfulSyncCycle();
- EXPECT_FALSE(nudge_tracker.IsGetUpdatesRequired());
+ nudge_tracker_.RecordSuccessfulSyncCycle();
+ EXPECT_FALSE(nudge_tracker_.IsGetUpdatesRequired());
// But we still haven't dealt with sessions. We'll need to remember
// that sessions are out of sync and re-enable the flag when their
// throttling interval expires.
- nudge_tracker.UpdateTypeThrottlingState(t1);
- EXPECT_FALSE(nudge_tracker.IsTypeThrottled(SESSIONS));
- EXPECT_TRUE(nudge_tracker.IsGetUpdatesRequired());
+ nudge_tracker_.UpdateTypeThrottlingState(t1);
+ EXPECT_FALSE(nudge_tracker_.IsTypeThrottled(SESSIONS));
+ EXPECT_TRUE(nudge_tracker_.IsGetUpdatesRequired());
}
// Tests throttling-related getter functions when no types are throttled.
TEST_F(NudgeTrackerTest, NoTypesThrottled) {
- NudgeTracker nudge_tracker;
-
- EXPECT_FALSE(nudge_tracker.IsAnyTypeThrottled());
- EXPECT_FALSE(nudge_tracker.IsTypeThrottled(SESSIONS));
- EXPECT_TRUE(nudge_tracker.GetThrottledTypes().Empty());
+ EXPECT_FALSE(nudge_tracker_.IsAnyTypeThrottled());
+ EXPECT_FALSE(nudge_tracker_.IsTypeThrottled(SESSIONS));
+ EXPECT_TRUE(nudge_tracker_.GetThrottledTypes().Empty());
}
// Tests throttling-related getter functions when some types are throttled.
TEST_F(NudgeTrackerTest, ThrottleAndUnthrottle) {
- NudgeTracker nudge_tracker;
const base::TimeTicks t0 = base::TimeTicks::FromInternalValue(1234);
const base::TimeDelta throttle_length = base::TimeDelta::FromMinutes(10);
const base::TimeTicks t1 = t0 + throttle_length;
- nudge_tracker.SetTypesThrottledUntil(ModelTypeSet(SESSIONS, PREFERENCES),
+ nudge_tracker_.SetTypesThrottledUntil(ModelTypeSet(SESSIONS, PREFERENCES),
throttle_length,
t0);
- EXPECT_TRUE(nudge_tracker.IsAnyTypeThrottled());
- EXPECT_TRUE(nudge_tracker.IsTypeThrottled(SESSIONS));
- EXPECT_TRUE(nudge_tracker.IsTypeThrottled(PREFERENCES));
- EXPECT_FALSE(nudge_tracker.GetThrottledTypes().Empty());
- EXPECT_EQ(throttle_length, nudge_tracker.GetTimeUntilNextUnthrottle(t0));
+ EXPECT_TRUE(nudge_tracker_.IsAnyTypeThrottled());
+ EXPECT_TRUE(nudge_tracker_.IsTypeThrottled(SESSIONS));
+ EXPECT_TRUE(nudge_tracker_.IsTypeThrottled(PREFERENCES));
+ EXPECT_FALSE(nudge_tracker_.GetThrottledTypes().Empty());
+ EXPECT_EQ(throttle_length, nudge_tracker_.GetTimeUntilNextUnthrottle(t0));
- nudge_tracker.UpdateTypeThrottlingState(t1);
+ nudge_tracker_.UpdateTypeThrottlingState(t1);
- EXPECT_FALSE(nudge_tracker.IsAnyTypeThrottled());
- EXPECT_FALSE(nudge_tracker.IsTypeThrottled(SESSIONS));
- EXPECT_TRUE(nudge_tracker.GetThrottledTypes().Empty());
+ EXPECT_FALSE(nudge_tracker_.IsAnyTypeThrottled());
+ EXPECT_FALSE(nudge_tracker_.IsTypeThrottled(SESSIONS));
+ EXPECT_TRUE(nudge_tracker_.GetThrottledTypes().Empty());
}
TEST_F(NudgeTrackerTest, OverlappingThrottleIntervals) {
- NudgeTracker nudge_tracker;
const base::TimeTicks t0 = base::TimeTicks::FromInternalValue(1234);
const base::TimeDelta throttle1_length = base::TimeDelta::FromMinutes(10);
const base::TimeDelta throttle2_length = base::TimeDelta::FromMinutes(20);
@@ -429,39 +428,39 @@ TEST_F(NudgeTrackerTest, OverlappingThrottleIntervals) {
const base::TimeTicks t2 = t0 + throttle2_length;
// Setup the longer of two intervals.
- nudge_tracker.SetTypesThrottledUntil(ModelTypeSet(SESSIONS, PREFERENCES),
+ nudge_tracker_.SetTypesThrottledUntil(ModelTypeSet(SESSIONS, PREFERENCES),
throttle2_length,
t0);
EXPECT_TRUE(ModelTypeSetEquals(
ModelTypeSet(SESSIONS, PREFERENCES),
- nudge_tracker.GetThrottledTypes()));
+ nudge_tracker_.GetThrottledTypes()));
EXPECT_EQ(throttle2_length,
- nudge_tracker.GetTimeUntilNextUnthrottle(t0));
+ nudge_tracker_.GetTimeUntilNextUnthrottle(t0));
// Setup the shorter interval.
- nudge_tracker.SetTypesThrottledUntil(ModelTypeSet(SESSIONS, BOOKMARKS),
+ nudge_tracker_.SetTypesThrottledUntil(ModelTypeSet(SESSIONS, BOOKMARKS),
throttle1_length,
t0);
EXPECT_TRUE(ModelTypeSetEquals(
ModelTypeSet(SESSIONS, PREFERENCES, BOOKMARKS),
- nudge_tracker.GetThrottledTypes()));
+ nudge_tracker_.GetThrottledTypes()));
EXPECT_EQ(throttle1_length,
- nudge_tracker.GetTimeUntilNextUnthrottle(t0));
+ nudge_tracker_.GetTimeUntilNextUnthrottle(t0));
// Expire the first interval.
- nudge_tracker.UpdateTypeThrottlingState(t1);
+ nudge_tracker_.UpdateTypeThrottlingState(t1);
// SESSIONS appeared in both intervals. We expect it will be throttled for
// the longer of the two, so it's still throttled at time t1.
EXPECT_TRUE(ModelTypeSetEquals(
ModelTypeSet(SESSIONS, PREFERENCES),
- nudge_tracker.GetThrottledTypes()));
+ nudge_tracker_.GetThrottledTypes()));
EXPECT_EQ(throttle2_length - throttle1_length,
- nudge_tracker.GetTimeUntilNextUnthrottle(t1));
+ nudge_tracker_.GetTimeUntilNextUnthrottle(t1));
// Expire the second interval.
- nudge_tracker.UpdateTypeThrottlingState(t2);
- EXPECT_TRUE(nudge_tracker.GetThrottledTypes().Empty());
+ nudge_tracker_.UpdateTypeThrottlingState(t2);
+ EXPECT_TRUE(nudge_tracker_.GetThrottledTypes().Empty());
}
} // namespace sessions
diff --git a/chromium/sync/sessions/ordered_commit_set.cc b/chromium/sync/sessions/ordered_commit_set.cc
deleted file mode 100644
index 3bbddb9c289..00000000000
--- a/chromium/sync/sessions/ordered_commit_set.cc
+++ /dev/null
@@ -1,131 +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/sessions/ordered_commit_set.h"
-
-#include <algorithm>
-
-#include "base/logging.h"
-
-namespace syncer {
-namespace sessions {
-
-OrderedCommitSet::OrderedCommitSet(const ModelSafeRoutingInfo& routes)
- : routes_(routes) {
-}
-
-OrderedCommitSet::~OrderedCommitSet() {}
-
-void OrderedCommitSet::AddCommitItem(const int64 metahandle,
- ModelType type) {
- if (!HaveCommitItem(metahandle)) {
- inserted_metahandles_.insert(metahandle);
- metahandle_order_.push_back(metahandle);
- projections_[GetGroupForModelType(type, routes_)].push_back(
- inserted_metahandles_.size() - 1);
- types_.push_back(type);
- types_in_list_.Put(type);
- }
-}
-
-void OrderedCommitSet::AddCommitItems(
- const std::vector<int64> metahandles,
- ModelType type) {
- for (std::vector<int64>::const_iterator it = metahandles.begin();
- it != metahandles.end(); ++it) {
- AddCommitItem(*it, type);
- }
-}
-
-const OrderedCommitSet::Projection& OrderedCommitSet::GetCommitIdProjection(
- ModelSafeGroup group) const {
- Projections::const_iterator i = projections_.find(group);
- DCHECK(i != projections_.end());
- return i->second;
-}
-
-void OrderedCommitSet::Append(const OrderedCommitSet& other) {
- for (size_t i = 0; i < other.Size(); ++i) {
- CommitItem item = other.GetCommitItemAt(i);
- AddCommitItem(item.meta, item.group);
- }
-}
-
-void OrderedCommitSet::AppendReverse(const OrderedCommitSet& other) {
- for (int i = other.Size() - 1; i >= 0; i--) {
- CommitItem item = other.GetCommitItemAt(i);
- AddCommitItem(item.meta, item.group);
- }
-}
-
-void OrderedCommitSet::Truncate(size_t max_size) {
- if (max_size < metahandle_order_.size()) {
- for (size_t i = max_size; i < metahandle_order_.size(); ++i) {
- inserted_metahandles_.erase(metahandle_order_[i]);
- }
-
- // Some projections may refer to indices that are getting chopped.
- // Since projections are in increasing order, it's easy to fix. Except
- // that you can't erase(..) using a reverse_iterator, so we use binary
- // search to find the chop point.
- Projections::iterator it = projections_.begin();
- for (; it != projections_.end(); ++it) {
- // For each projection, chop off any indices larger than or equal to
- // max_size by looking for max_size using binary search.
- Projection& p = it->second;
- Projection::iterator element = std::lower_bound(p.begin(), p.end(),
- max_size);
- if (element != p.end())
- p.erase(element, p.end());
- }
- metahandle_order_.resize(max_size);
- types_.resize(max_size);
- }
-}
-
-void OrderedCommitSet::Clear() {
- inserted_metahandles_.clear();
- metahandle_order_.clear();
- for (Projections::iterator it = projections_.begin();
- it != projections_.end(); ++it) {
- it->second.clear();
- }
- types_.clear();
- types_in_list_.Clear();
-}
-
-OrderedCommitSet::CommitItem OrderedCommitSet::GetCommitItemAt(
- const size_t position) const {
- DCHECK(position < Size());
- CommitItem return_item = {metahandle_order_[position],
- types_[position]};
- return return_item;
-}
-
-bool OrderedCommitSet::HasBookmarkCommitId() const {
- ModelSafeRoutingInfo::const_iterator group = routes_.find(BOOKMARKS);
- if (group == routes_.end())
- return false;
- Projections::const_iterator proj = projections_.find(group->second);
- if (proj == projections_.end())
- return false;
- DCHECK_LE(proj->second.size(), types_.size());
- for (size_t i = 0; i < proj->second.size(); i++) {
- if (types_[proj->second[i]] == BOOKMARKS)
- return true;
- }
- return false;
-}
-
-void OrderedCommitSet::operator=(const OrderedCommitSet& other) {
- inserted_metahandles_ = other.inserted_metahandles_;
- metahandle_order_ = other.metahandle_order_;
- projections_ = other.projections_;
- types_ = other.types_;
- routes_ = other.routes_;
-}
-
-} // namespace sessions
-} // namespace syncer
-
diff --git a/chromium/sync/sessions/ordered_commit_set.h b/chromium/sync/sessions/ordered_commit_set.h
deleted file mode 100644
index a30724e641c..00000000000
--- a/chromium/sync/sessions/ordered_commit_set.h
+++ /dev/null
@@ -1,128 +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.
-
-#ifndef SYNC_SESSIONS_ORDERED_COMMIT_SET_H_
-#define SYNC_SESSIONS_ORDERED_COMMIT_SET_H_
-
-#include <map>
-#include <set>
-#include <vector>
-
-#include "sync/base/sync_export.h"
-#include "sync/internal_api/public/base/model_type.h"
-#include "sync/internal_api/public/engine/model_safe_worker.h"
-
-namespace syncer {
-namespace sessions {
-
-// TODO(ncarter): This code is more generic than just Commit and can
-// be reused elsewhere (e.g. ChangeReorderBuffer do similar things). Merge
-// all these implementations.
-class SYNC_EXPORT_PRIVATE OrderedCommitSet {
- public:
- // A list of indices into the full list of commit ids such that:
- // 1 - each element is an index belonging to a particular ModelSafeGroup.
- // 2 - the vector is in sorted (smallest to largest) order.
- // 3 - each element is a valid index for GetCommitItemAt.
- // See GetCommitIdProjection for usage.
- typedef std::vector<size_t> Projection;
-
- // TODO(chron): Reserve space according to batch size?
- explicit OrderedCommitSet(const ModelSafeRoutingInfo& routes);
- ~OrderedCommitSet();
-
- bool HaveCommitItem(const int64 metahandle) const {
- return inserted_metahandles_.count(metahandle) > 0;
- }
-
- void AddCommitItem(const int64 metahandle, ModelType type);
- void AddCommitItems(const std::vector<int64> metahandles, ModelType type);
-
- const std::vector<int64>& GetAllCommitHandles() const {
- return metahandle_order_;
- }
-
- // Return the handle at index |position| in this OrderedCommitSet. Note that
- // the index uniquely identifies the same logical item in each of:
- // 1) this OrderedCommitSet
- // 2) the CommitRequest sent to the server
- // 3) the list of EntryResponse objects in the CommitResponse.
- // These together allow re-association of the pre-commit Id with the
- // actual committed entry.
- int64 GetCommitHandleAt(const size_t position) const {
- return metahandle_order_[position];
- }
-
- // Same as above, but for ModelType of the item.
- ModelType GetModelTypeAt(const size_t position) const {
- return types_[position];
- }
-
- // Get the projection of commit ids onto the space of commit ids
- // belonging to |group|. This is useful when you need to process a commit
- // response one ModelSafeGroup at a time. See GetCommitIdAt for how the
- // indices contained in the returned Projection can be used.
- const Projection& GetCommitIdProjection(
- ModelSafeGroup group) const;
-
- size_t Size() const {
- return metahandle_order_.size();
- }
-
- bool Empty() const {
- return Size() == 0;
- }
-
- // Returns all the types that are included in this list.
- ModelTypeSet Types() const {
- return types_in_list_;
- }
-
- // Returns true iff any of the commit ids added to this set have model type
- // BOOKMARKS.
- bool HasBookmarkCommitId() const;
-
- void Append(const OrderedCommitSet& other);
- void AppendReverse(const OrderedCommitSet& other);
- void Truncate(size_t max_size);
-
- // Removes all entries from this set.
- void Clear();
-
- void operator=(const OrderedCommitSet& other);
- private:
- // A set of CommitIdProjections associated with particular ModelSafeGroups.
- typedef std::map<ModelSafeGroup, Projection> Projections;
-
- // Helper container for return value of GetCommitItemAt.
- struct CommitItem {
- int64 meta;
- ModelType group;
- };
-
- CommitItem GetCommitItemAt(const size_t position) const;
-
- // These lists are different views of the same items; e.g they are
- // isomorphic.
- std::set<int64> inserted_metahandles_;
- std::vector<int64> metahandle_order_;
- Projections projections_;
-
- // We need this because of operations like AppendReverse that take ids from
- // one OrderedCommitSet and insert into another -- we need to know the
- // group for each ID so that the insertion can update the appropriate
- // projection.
- std::vector<ModelType> types_;
-
- // The set of types which are included in this particular list.
- ModelTypeSet types_in_list_;
-
- ModelSafeRoutingInfo routes_;
-};
-
-} // namespace sessions
-} // namespace syncer
-
-#endif // SYNC_SESSIONS_ORDERED_COMMIT_SET_H_
-
diff --git a/chromium/sync/sessions/ordered_commit_set_unittest.cc b/chromium/sync/sessions/ordered_commit_set_unittest.cc
deleted file mode 100644
index 4aca4f406c7..00000000000
--- a/chromium/sync/sessions/ordered_commit_set_unittest.cc
+++ /dev/null
@@ -1,134 +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/sessions/ordered_commit_set.h"
-#include "sync/test/engine/test_id_factory.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-using std::vector;
-
-namespace syncer {
-namespace sessions {
-namespace {
-
-class OrderedCommitSetTest : public testing::Test {
- public:
- OrderedCommitSetTest() {
- routes_[BOOKMARKS] = GROUP_UI;
- routes_[PREFERENCES] = GROUP_UI;
- routes_[AUTOFILL] = GROUP_DB;
- routes_[SESSIONS] = GROUP_PASSIVE;
- }
- protected:
- TestIdFactory ids_;
- ModelSafeRoutingInfo routes_;
-};
-
-TEST_F(OrderedCommitSetTest, Projections) {
- vector<int64> expected;
- for (int64 i = 0; i < 8; i++)
- expected.push_back(i);
-
- OrderedCommitSet commit_set1(routes_), commit_set2(routes_);
- commit_set1.AddCommitItem(expected[0], BOOKMARKS);
- commit_set1.AddCommitItem(expected[1], BOOKMARKS);
- commit_set1.AddCommitItem(expected[2], PREFERENCES);
- // Duplicates should be dropped.
- commit_set1.AddCommitItem(expected[2], PREFERENCES);
- commit_set1.AddCommitItem(expected[3], SESSIONS);
- commit_set1.AddCommitItem(expected[4], SESSIONS);
- commit_set2.AddCommitItem(expected[7], AUTOFILL);
- commit_set2.AddCommitItem(expected[6], AUTOFILL);
- commit_set2.AddCommitItem(expected[5], AUTOFILL);
- // Add something in set1 to set2, which should get dropped by AppendReverse.
- commit_set2.AddCommitItem(expected[0], BOOKMARKS);
- commit_set1.AppendReverse(commit_set2);
-
- EXPECT_EQ(8U, commit_set1.Size());
-
- // First, we should verify the projections are correct. Second, we want to
- // do the same verification after truncating by 1. Next, try truncating
- // the set to a size of 4, so that the DB projection is wiped out and
- // PASSIVE has one element removed. Finally, truncate to 1 so only UI is
- // remaining.
- std::vector<size_t> sizes;
- sizes.push_back(8);
- sizes.push_back(7);
- sizes.push_back(4);
- sizes.push_back(1);
- for (std::vector<size_t>::iterator it = sizes.begin();
- it != sizes.end(); ++it) {
- commit_set1.Truncate(*it);
- size_t expected_size = *it;
-
- SCOPED_TRACE(::testing::Message("Iteration size = ") << *it);
- std::vector<int64> all_ids = commit_set1.GetAllCommitHandles();
- EXPECT_EQ(expected_size, all_ids.size());
- for (size_t i = 0; i < expected_size; i++) {
- EXPECT_TRUE(expected[i] == all_ids[i]);
- EXPECT_TRUE(expected[i] == commit_set1.GetCommitHandleAt(i));
- }
-
- OrderedCommitSet::Projection p1, p2, p3;
- p1 = commit_set1.GetCommitIdProjection(GROUP_UI);
- p2 = commit_set1.GetCommitIdProjection(GROUP_PASSIVE);
- p3 = commit_set1.GetCommitIdProjection(GROUP_DB);
- EXPECT_TRUE(p1.size() + p2.size() + p3.size() == expected_size) << "Sum"
- << "of sizes of projections should equal full expected size!";
-
- for (size_t i = 0; i < p1.size(); i++) {
- SCOPED_TRACE(::testing::Message("UI projection mismatch at i = ") << i);
- EXPECT_TRUE(expected[p1[i]] == commit_set1.GetCommitHandleAt(p1[i]))
- << "expected[p1[i]] = " << expected[p1[i]]
- << ", commit_set1[p1[i]] = " << commit_set1.GetCommitHandleAt(p1[i]);
- }
- for (size_t i = 0; i < p2.size(); i++) {
- SCOPED_TRACE(::testing::Message("PASSIVE projection mismatch at i = ")
- << i);
- EXPECT_TRUE(expected[p2[i]] == commit_set1.GetCommitHandleAt(p2[i]))
- << "expected[p2[i]] = " << expected[p2[i]]
- << ", commit_set1[p2[i]] = " << commit_set1.GetCommitHandleAt(p2[i]);
- }
- for (size_t i = 0; i < p3.size(); i++) {
- SCOPED_TRACE(::testing::Message("DB projection mismatch at i = ") << i);
- EXPECT_TRUE(expected[p3[i]] == commit_set1.GetCommitHandleAt(p3[i]))
- << "expected[p3[i]] = " << expected[p3[i]]
- << ", commit_set1[p3[i]] = " << commit_set1.GetCommitHandleAt(p3[i]);
- }
- }
-}
-
-TEST_F(OrderedCommitSetTest, HasBookmarkCommitId) {
- OrderedCommitSet commit_set(routes_);
-
- commit_set.AddCommitItem(0, AUTOFILL);
- commit_set.AddCommitItem(1, SESSIONS);
- EXPECT_FALSE(commit_set.HasBookmarkCommitId());
-
- commit_set.AddCommitItem(2, PREFERENCES);
- commit_set.AddCommitItem(3, PREFERENCES);
- EXPECT_FALSE(commit_set.HasBookmarkCommitId());
-
- commit_set.AddCommitItem(4, BOOKMARKS);
- EXPECT_TRUE(commit_set.HasBookmarkCommitId());
-
- commit_set.Truncate(4);
- EXPECT_FALSE(commit_set.HasBookmarkCommitId());
-}
-
-TEST_F(OrderedCommitSetTest, AddAndRemoveEntries) {
- OrderedCommitSet commit_set(routes_);
-
- ASSERT_TRUE(commit_set.Empty());
-
- commit_set.AddCommitItem(0, AUTOFILL);
- ASSERT_EQ(static_cast<size_t>(1), commit_set.Size());
-
- commit_set.Clear();
- ASSERT_TRUE(commit_set.Empty());
-}
-
-} // namespace
-} // namespace sessions
-} // namespace syncer
diff --git a/chromium/sync/sessions/status_controller.cc b/chromium/sync/sessions/status_controller.cc
index abd6f1ecbd6..752b9ab47f6 100644
--- a/chromium/sync/sessions/status_controller.cc
+++ b/chromium/sync/sessions/status_controller.cc
@@ -13,9 +13,7 @@
namespace syncer {
namespace sessions {
-StatusController::StatusController()
- : group_restriction_in_effect_(false),
- group_restriction_(GROUP_PASSIVE) {
+StatusController::StatusController() {
}
StatusController::~StatusController() {}
@@ -105,17 +103,6 @@ SyncerError StatusController::last_get_key_result() const {
return model_neutral_.last_get_key_result;
}
-// Returns the number of updates received from the sync server.
-int64 StatusController::CountUpdates() const {
- const sync_pb::ClientToServerResponse& updates =
- model_neutral_.updates_response;
- if (updates.has_get_updates()) {
- return updates.get_updates().entries().size();
- } else {
- return 0;
- }
-}
-
int StatusController::num_updates_applied() const {
return model_neutral_.num_updates_applied;
}
@@ -129,20 +116,14 @@ int StatusController::num_encryption_conflicts() const {
}
int StatusController::num_hierarchy_conflicts() const {
- DCHECK(!group_restriction_in_effect_)
- << "num_hierarchy_conflicts applies to all ModelSafeGroups";
return model_neutral_.num_hierarchy_conflicts;
}
int StatusController::num_server_conflicts() const {
- DCHECK(!group_restriction_in_effect_)
- << "num_server_conflicts applies to all ModelSafeGroups";
return model_neutral_.num_server_conflicts;
}
int StatusController::TotalNumConflictingItems() const {
- DCHECK(!group_restriction_in_effect_)
- << "TotalNumConflictingItems applies to all ModelSafeGroups";
int sum = 0;
sum += num_encryption_conflicts();
sum += num_hierarchy_conflicts();
@@ -150,26 +131,5 @@ int StatusController::TotalNumConflictingItems() const {
return sum;
}
-bool StatusController::ServerSaysNothingMoreToDownload() const {
- if (!download_updates_succeeded())
- return false;
-
- if (!updates_response().get_updates().has_changes_remaining()) {
- NOTREACHED(); // Server should always send changes remaining.
- return false; // Avoid looping forever.
- }
- // Changes remaining is an estimate, but if it's estimated to be
- // zero, that's firm and we don't have to ask again.
- return updates_response().get_updates().changes_remaining() == 0;
-}
-
-void StatusController::set_debug_info_sent() {
- model_neutral_.debug_info_sent = true;
-}
-
-bool StatusController::debug_info_sent() const {
- return model_neutral_.debug_info_sent;
-}
-
} // namespace sessions
} // namespace syncer
diff --git a/chromium/sync/sessions/status_controller.h b/chromium/sync/sessions/status_controller.h
index a547c1b67da..005f158a81e 100644
--- a/chromium/sync/sessions/status_controller.h
+++ b/chromium/sync/sessions/status_controller.h
@@ -5,25 +5,14 @@
// StatusController handles all counter and status related number crunching and
// state tracking on behalf of a SyncSession.
//
-// The most important feature of StatusController is the
-// ScopedModelSafeGroupRestriction. Some of its functions expose per-thread
-// state, and can be called only when the restriction is in effect. For
-// example, if GROUP_UI is set then the value returned from
-// commit_id_projection() will be useful for iterating over the commit IDs of
-// items that live on the UI thread.
+// This object may be accessed from many different threads. It will be accessed
+// most often from the syncer thread. However, when update application is in
+// progress it may also be accessed from the worker threads. This is safe
+// because only one of them will run at a time, and the syncer thread will be
+// blocked until update application completes.
//
-// Other parts of its state are global, and do not require the restriction.
-//
-// NOTE: There is no concurrent access protection provided by this class. It
-// assumes one single thread is accessing this class for each unique
-// ModelSafeGroup, and also only one single thread (in practice, the
-// SyncerThread) responsible for all "shared" access when no restriction is in
-// place. Thus, every bit of data is to be accessed mutually exclusively with
-// respect to threads.
-//
-// StatusController can also track if changes occur to certain parts of state
-// so that various parts of the sync engine can avoid broadcasting
-// notifications if no changes occurred.
+// This object contains only global state. None of its members are per model
+// type counters.
#ifndef SYNC_SESSIONS_STATUS_CONTROLLER_H_
#define SYNC_SESSIONS_STATUS_CONTROLLER_H_
@@ -35,8 +24,8 @@
#include "base/stl_util.h"
#include "base/time/time.h"
#include "sync/base/sync_export.h"
+#include "sync/internal_api/public/engine/model_safe_worker.h"
#include "sync/internal_api/public/sessions/model_neutral_state.h"
-#include "sync/sessions/ordered_commit_set.h"
namespace syncer {
namespace sessions {
@@ -47,37 +36,18 @@ class SYNC_EXPORT_PRIVATE StatusController {
~StatusController();
// ClientToServer messages.
- const ModelTypeSet updates_request_types() const {
- return model_neutral_.updates_request_types;
- }
- void set_updates_request_types(ModelTypeSet value) {
- model_neutral_.updates_request_types = value;
- }
const ModelTypeSet commit_request_types() const {
return model_neutral_.commit_request_types;
}
void set_commit_request_types(ModelTypeSet value) {
model_neutral_.commit_request_types = value;
}
- const sync_pb::ClientToServerResponse& updates_response() const {
- return model_neutral_.updates_response;
- }
- sync_pb::ClientToServerResponse* mutable_updates_response() {
- return &model_neutral_.updates_response;
- }
// Changelog related state.
int64 num_server_changes_remaining() const {
return model_neutral_.num_server_changes_remaining;
}
- const OrderedCommitSet::Projection& commit_id_projection(
- const sessions::OrderedCommitSet &commit_set) {
- DCHECK(group_restriction_in_effect_)
- << "No group restriction for projection.";
- return commit_set.GetCommitIdProjection(group_restriction_);
- }
-
// Various conflict counters.
int num_encryption_conflicts() const;
int num_hierarchy_conflicts() const;
@@ -91,28 +61,6 @@ class SYNC_EXPORT_PRIVATE StatusController {
int num_server_overwrites() const;
- // Returns the number of updates received from the sync server.
- int64 CountUpdates() const;
-
- // Returns true if the last download_updates_command received a valid
- // server response.
- bool download_updates_succeeded() const {
- return model_neutral_.last_download_updates_result
- == SYNCER_OK;
- }
-
- // Returns true if the last updates response indicated that we were fully
- // up to date. This is subtle: if it's false, it could either mean that
- // the server said there WAS more to download, or it could mean that we
- // were unable to reach the server. If we didn't request every enabled
- // datatype, then we can't say for sure that there's nothing left to
- // download: in that case, this also returns false.
- bool ServerSaysNothingMoreToDownload() const;
-
- ModelSafeGroup group_restriction() const {
- return group_restriction_;
- }
-
base::Time sync_start_time() const {
// The time at which we sent the first GetUpdates command for this sync.
return sync_start_time_;
@@ -154,45 +102,14 @@ class SYNC_EXPORT_PRIVATE StatusController {
void UpdateStartTime();
- void set_debug_info_sent();
-
- bool debug_info_sent() const;
-
private:
- friend class ScopedModelSafeGroupRestriction;
-
ModelNeutralState model_neutral_;
- // Used to fail read/write operations on state that don't obey the current
- // active ModelSafeWorker contract.
- bool group_restriction_in_effect_;
- ModelSafeGroup group_restriction_;
-
base::Time sync_start_time_;
DISALLOW_COPY_AND_ASSIGN(StatusController);
};
-// A utility to restrict access to only those parts of the given
-// StatusController that pertain to the specified ModelSafeGroup.
-class ScopedModelSafeGroupRestriction {
- public:
- ScopedModelSafeGroupRestriction(StatusController* to_restrict,
- ModelSafeGroup restriction)
- : status_(to_restrict) {
- DCHECK(!status_->group_restriction_in_effect_);
- status_->group_restriction_ = restriction;
- status_->group_restriction_in_effect_ = true;
- }
- ~ScopedModelSafeGroupRestriction() {
- DCHECK(status_->group_restriction_in_effect_);
- status_->group_restriction_in_effect_ = false;
- }
- private:
- StatusController* status_;
- DISALLOW_COPY_AND_ASSIGN(ScopedModelSafeGroupRestriction);
-};
-
} // namespace sessions
} // namespace syncer
diff --git a/chromium/sync/sessions/status_controller_unittest.cc b/chromium/sync/sessions/status_controller_unittest.cc
index e6b59e8b30f..c29bc5f717a 100644
--- a/chromium/sync/sessions/status_controller_unittest.cc
+++ b/chromium/sync/sessions/status_controller_unittest.cc
@@ -31,16 +31,6 @@ TEST_F(StatusControllerTest, ReadYourWrites) {
EXPECT_EQ(14, status.model_neutral_state().num_successful_commits);
}
-TEST_F(StatusControllerTest, CountUpdates) {
- StatusController status;
- EXPECT_EQ(0, status.CountUpdates());
- sync_pb::ClientToServerResponse* response(status.mutable_updates_response());
- sync_pb::SyncEntity* entity1 = response->mutable_get_updates()->add_entries();
- sync_pb::SyncEntity* entity2 = response->mutable_get_updates()->add_entries();
- ASSERT_TRUE(entity1 != NULL && entity2 != NULL);
- EXPECT_EQ(2, status.CountUpdates());
-}
-
// Test TotalNumConflictingItems
TEST_F(StatusControllerTest, TotalNumConflictingItems) {
StatusController status;
@@ -52,14 +42,5 @@ TEST_F(StatusControllerTest, TotalNumConflictingItems) {
EXPECT_EQ(6, status.TotalNumConflictingItems());
}
-// Basic test that non group-restricted state accessors don't cause violations.
-TEST_F(StatusControllerTest, Unrestricted) {
- StatusController status;
- status.model_neutral_state();
- status.download_updates_succeeded();
- status.ServerSaysNothingMoreToDownload();
- status.group_restriction();
-}
-
} // namespace sessions
} // namespace syncer
diff --git a/chromium/sync/sessions/sync_session.h b/chromium/sync/sessions/sync_session.h
index cd4a22ccc19..f5767206d2a 100644
--- a/chromium/sync/sessions/sync_session.h
+++ b/chromium/sync/sessions/sync_session.h
@@ -4,12 +4,8 @@
// A class representing an attempt to synchronize the local syncable data
// store with a sync server. A SyncSession instance is passed as a stateful
-// bundle to and from various SyncerCommands with the goal of converging the
-// client view of data with that of the server. The commands twiddle with
-// session status in response to events and hiccups along the way, set and
-// query session progress with regards to conflict resolution and applying
-// server updates, and access the SyncSessionContext for the current session
-// via SyncSession instances.
+// bundle throughout the sync cycle. The SyncSession is not reused across
+// sync cycles; each cycle starts with a new one.
#ifndef SYNC_SESSIONS_SYNC_SESSION_H_
#define SYNC_SESSIONS_SYNC_SESSION_H_
@@ -27,7 +23,6 @@
#include "sync/internal_api/public/base/model_type.h"
#include "sync/internal_api/public/engine/model_safe_worker.h"
#include "sync/internal_api/public/sessions/sync_session_snapshot.h"
-#include "sync/sessions/ordered_commit_set.h"
#include "sync/sessions/status_controller.h"
#include "sync/sessions/sync_session_context.h"
@@ -78,17 +73,6 @@ class SYNC_EXPORT_PRIVATE SyncSession {
virtual void OnReceivedSessionsCommitDelay(
const base::TimeDelta& new_delay) = 0;
- // The client needs to cease and desist syncing at once. This occurs when
- // the Syncer detects that the backend store has fundamentally changed or
- // is a different instance altogether (e.g. swapping from a test instance
- // to production, or a global stop syncing operation has wiped the store).
- // TODO(lipalani) : Replace this function with the one below. This function
- // stops the current sync cycle and purges the client. In the new model
- // the former would be done by the |SyncProtocolError| and
- // the latter(which is an action) would be done in ProfileSyncService
- // along with the rest of the actions.
- virtual void OnShouldStopSyncingPermanently() = 0;
-
// Called for the syncer to respond to the error sent by the server.
virtual void OnSyncProtocolError(
const sessions::SyncSessionSnapshot& snapshot) = 0;
diff --git a/chromium/sync/sessions/sync_session_context.cc b/chromium/sync/sessions/sync_session_context.cc
index 98ab5f01a92..aa5dfa54044 100644
--- a/chromium/sync/sessions/sync_session_context.cc
+++ b/chromium/sync/sessions/sync_session_context.cc
@@ -10,9 +10,6 @@
namespace syncer {
namespace sessions {
-const unsigned int kMaxMessagesToRecord = 10;
-const unsigned int kMaxMessageSizeToRecord = 5 * 1024;
-
SyncSessionContext::SyncSessionContext(
ServerConnectionManager* connection_manager,
syncable::Directory* directory,
@@ -26,6 +23,8 @@ SyncSessionContext::SyncSessionContext(
const std::string& invalidator_client_id)
: connection_manager_(connection_manager),
directory_(directory),
+ update_handler_deleter_(&update_handler_map_),
+ commit_contributor_deleter_(&commit_contributor_map_),
extensions_activity_(extensions_activity),
notifications_enabled_(false),
max_commit_batch_size_(kDefaultMaxCommitBatchSize),
@@ -36,8 +35,10 @@ SyncSessionContext::SyncSessionContext(
server_enabled_pre_commit_update_avoidance_(false),
client_enabled_pre_commit_update_avoidance_(
client_enabled_pre_commit_update_avoidance) {
- for (size_t i = 0u; i < workers.size(); ++i)
- workers_.push_back(workers[i]);
+ for (size_t i = 0u; i < workers.size(); ++i) {
+ workers_.insert(
+ std::make_pair(workers[i]->GetModelSafeGroup(), workers[i]));
+ }
std::vector<SyncEngineEventListener*>::const_iterator it;
for (it = listeners.begin(); it != listeners.end(); ++it)
@@ -47,5 +48,32 @@ SyncSessionContext::SyncSessionContext(
SyncSessionContext::~SyncSessionContext() {
}
+void SyncSessionContext::set_routing_info(
+ const ModelSafeRoutingInfo& routing_info) {
+ enabled_types_ = GetRoutingInfoTypes(routing_info);
+
+ // TODO(rlarocque): This is not a good long-term solution. We must find a
+ // better way to initialize the set of CommitContributors and UpdateHandlers.
+ STLDeleteValues<UpdateHandlerMap>(&update_handler_map_);
+ STLDeleteValues<CommitContributorMap>(&commit_contributor_map_);
+ for (ModelSafeRoutingInfo::const_iterator routing_iter = routing_info.begin();
+ routing_iter != routing_info.end(); ++routing_iter) {
+ ModelType type = routing_iter->first;
+ ModelSafeGroup group = routing_iter->second;
+ std::map<ModelSafeGroup, scoped_refptr<ModelSafeWorker> >::iterator
+ worker_it = workers_.find(group);
+ DCHECK(worker_it != workers_.end());
+ scoped_refptr<ModelSafeWorker> worker = worker_it->second;
+
+ SyncDirectoryUpdateHandler* handler =
+ new SyncDirectoryUpdateHandler(directory(), type, worker);
+ update_handler_map_.insert(std::make_pair(type, handler));
+
+ SyncDirectoryCommitContributor* contributor =
+ new SyncDirectoryCommitContributor(directory(), type);
+ commit_contributor_map_.insert(std::make_pair(type, contributor));
+ }
+}
+
} // namespace sessions
} // namespace syncer
diff --git a/chromium/sync/sessions/sync_session_context.h b/chromium/sync/sessions/sync_session_context.h
index 718cc6caad0..5995ab151db 100644
--- a/chromium/sync/sessions/sync_session_context.h
+++ b/chromium/sync/sessions/sync_session_context.h
@@ -3,15 +3,12 @@
// found in the LICENSE file.
// SyncSessionContext encapsulates the contextual information and engine
-// components specific to a SyncSession. A context is accessible via
-// a SyncSession so that session SyncerCommands and parts of the engine have
-// a convenient way to access other parts. In this way it can be thought of as
-// the surrounding environment for the SyncSession. The components of this
-// environment are either valid or not valid for the entire context lifetime,
-// or they are valid for explicitly scoped periods of time by using Scoped
-// installation utilities found below. This means that the context assumes no
-// ownership whatsoever of any object that was not created by the context
-// itself.
+// components specific to a SyncSession. Unlike the SyncSession, the context
+// can be reused across several sync cycles.
+//
+// The context does not take ownership of its pointer members. It's up to
+// the surrounding classes to ensure those members remain valid while the
+// context is in use.
//
// It can only be used from the SyncerThread.
@@ -22,7 +19,10 @@
#include <string>
#include <vector>
+#include "base/stl_util.h"
#include "sync/base/sync_export.h"
+#include "sync/engine/sync_directory_commit_contributor.h"
+#include "sync/engine/sync_directory_update_handler.h"
#include "sync/engine/sync_engine_event.h"
#include "sync/engine/syncer_types.h"
#include "sync/engine/traffic_recorder.h"
@@ -67,16 +67,18 @@ class SYNC_EXPORT_PRIVATE SyncSessionContext {
return directory_;
}
- const ModelSafeRoutingInfo& routing_info() const {
- return routing_info_;
+ ModelTypeSet enabled_types() const {
+ return enabled_types_;
}
- void set_routing_info(const ModelSafeRoutingInfo& routing_info) {
- routing_info_ = routing_info;
+ void set_routing_info(const ModelSafeRoutingInfo& routing_info);
+
+ UpdateHandlerMap* update_handler_map() {
+ return &update_handler_map_;
}
- const std::vector<scoped_refptr<ModelSafeWorker> >& workers() const {
- return workers_;
+ CommitContributorMap* commit_contributor_map() {
+ return &commit_contributor_map_;
}
ExtensionsActivity* extensions_activity() {
@@ -150,12 +152,28 @@ class SYNC_EXPORT_PRIVATE SyncSessionContext {
ServerConnectionManager* const connection_manager_;
syncable::Directory* const directory_;
- // A cached copy of SyncBackendRegistrar's routing info.
- // Must be updated manually when SBR's state is modified.
- ModelSafeRoutingInfo routing_info_;
+ // The set of enabled types. Derrived from the routing info set with
+ // set_routing_info().
+ ModelTypeSet enabled_types_;
+
+ // A map of 'update handlers', one for each enabled type.
+ // This must be kept in sync with the routing info. Our temporary solution to
+ // that problem is to initialize this map in set_routing_info().
+ UpdateHandlerMap update_handler_map_;
+
+ // Deleter for the |update_handler_map_|.
+ STLValueDeleter<UpdateHandlerMap> update_handler_deleter_;
+
+ // A map of 'commit contributors', one for each enabled type.
+ // This must be kept in sync with the routing info. Our temporary solution to
+ // that problem is to initialize this map in set_routing_info().
+ CommitContributorMap commit_contributor_map_;
+
+ // Deleter for the |commit_contributor_map_|.
+ STLValueDeleter<CommitContributorMap> commit_contributor_deleter_;
// The set of ModelSafeWorkers. Used to execute tasks of various threads.
- std::vector<scoped_refptr<ModelSafeWorker> > workers_;
+ std::map<ModelSafeGroup, scoped_refptr<ModelSafeWorker> > workers_;
// We use this to stuff extensions activity into CommitMessages so the server
// can correlate commit traffic with extension-related bookmark mutations.
diff --git a/chromium/sync/sessions/sync_session_unittest.cc b/chromium/sync/sessions/sync_session_unittest.cc
index f751e25cd90..e712552f580 100644
--- a/chromium/sync/sessions/sync_session_unittest.cc
+++ b/chromium/sync/sessions/sync_session_unittest.cc
@@ -104,9 +104,6 @@ class SyncSessionTest : public testing::Test,
FailControllerInvocationIfDisabled(
"OnReceivedClientInvalidationHintBufferSize");
}
- virtual void OnShouldStopSyncingPermanently() OVERRIDE {
- FailControllerInvocationIfDisabled("OnShouldStopSyncingPermanently");
- }
virtual void OnSyncProtocolError(
const sessions::SyncSessionSnapshot& snapshot) OVERRIDE {
FailControllerInvocationIfDisabled("SyncProtocolError");
@@ -148,38 +145,6 @@ class SyncSessionTest : public testing::Test,
scoped_refptr<ExtensionsActivity> extensions_activity_;
};
-TEST_F(SyncSessionTest, MoreToDownloadIfDownloadFailed) {
- status()->set_updates_request_types(ParamsMeaningAllEnabledTypes());
-
- status()->set_last_download_updates_result(NETWORK_IO_ERROR);
-
- // When DownloadUpdatesCommand fails, these should be false.
- EXPECT_FALSE(status()->ServerSaysNothingMoreToDownload());
- EXPECT_FALSE(status()->download_updates_succeeded());
-}
-
-TEST_F(SyncSessionTest, MoreToDownloadIfGotChangesRemaining) {
- status()->set_updates_request_types(ParamsMeaningAllEnabledTypes());
-
- // When the server returns changes_remaining, that means there's
- // more to download.
- status()->set_last_download_updates_result(SYNCER_OK);
- status()->mutable_updates_response()->mutable_get_updates()
- ->set_changes_remaining(1000L);
- EXPECT_FALSE(status()->ServerSaysNothingMoreToDownload());
- EXPECT_TRUE(status()->download_updates_succeeded());
-}
-
-TEST_F(SyncSessionTest, MoreToDownloadIfGotNoChangesRemaining) {
- status()->set_updates_request_types(ParamsMeaningAllEnabledTypes());
-
- status()->set_last_download_updates_result(SYNCER_OK);
- status()->mutable_updates_response()->mutable_get_updates()
- ->set_changes_remaining(0);
- EXPECT_TRUE(status()->ServerSaysNothingMoreToDownload());
- EXPECT_TRUE(status()->download_updates_succeeded());
-}
-
} // namespace
} // namespace sessions
} // namespace syncer