summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sync/engine/commit.cc8
-rw-r--r--sync/engine/commit.h6
-rw-r--r--sync/engine/commit_contribution.cc13
-rw-r--r--sync/engine/commit_contribution.h54
-rw-r--r--sync/engine/commit_contributor.cc13
-rw-r--r--sync/engine/commit_contributor.h38
-rw-r--r--sync/engine/commit_processor.cc8
-rw-r--r--sync/engine/commit_processor.h13
-rw-r--r--sync/engine/directory_commit_contribution.cc (renamed from sync/engine/sync_directory_commit_contribution.cc)25
-rw-r--r--sync/engine/directory_commit_contribution.h (renamed from sync/engine/sync_directory_commit_contribution.h)37
-rw-r--r--sync/engine/directory_commit_contribution_unittest.cc (renamed from sync/engine/sync_directory_commit_contribution_unittest.cc)44
-rw-r--r--sync/engine/directory_commit_contributor.cc25
-rw-r--r--sync/engine/directory_commit_contributor.h45
-rw-r--r--sync/engine/directory_update_handler.cc (renamed from sync/engine/sync_directory_update_handler.cc)27
-rw-r--r--sync/engine/directory_update_handler.h (renamed from sync/engine/sync_directory_update_handler.h)37
-rw-r--r--sync/engine/directory_update_handler_unittest.cc (renamed from sync/engine/sync_directory_update_handler_unittest.cc)74
-rw-r--r--sync/engine/download_unittest.cc32
-rw-r--r--sync/engine/get_updates_delegate.cc2
-rw-r--r--sync/engine/get_updates_processor.cc5
-rw-r--r--sync/engine/get_updates_processor.h4
-rw-r--r--sync/engine/sync_directory_commit_contributor.cc24
-rw-r--r--sync/engine/sync_directory_commit_contributor.h41
-rw-r--r--sync/engine/update_handler.cc14
-rw-r--r--sync/engine/update_handler.h63
-rw-r--r--sync/sessions/model_type_registry.cc12
-rw-r--r--sync/sessions/model_type_registry.h9
-rw-r--r--sync/sync_core.gypi26
-rw-r--r--sync/sync_tests.gypi6
-rw-r--r--sync/test/engine/mock_update_handler.cc37
-rw-r--r--sync/test/engine/mock_update_handler.h36
30 files changed, 525 insertions, 253 deletions
diff --git a/sync/engine/commit.cc b/sync/engine/commit.cc
index 0a37656..90b9742 100644
--- a/sync/engine/commit.cc
+++ b/sync/engine/commit.cc
@@ -5,9 +5,9 @@
#include "sync/engine/commit.h"
#include "base/debug/trace_event.h"
+#include "sync/engine/commit_contribution.h"
#include "sync/engine/commit_processor.h"
#include "sync/engine/commit_util.h"
-#include "sync/engine/sync_directory_commit_contribution.h"
#include "sync/engine/syncer.h"
#include "sync/engine/syncer_proto_util.h"
#include "sync/sessions/sync_session.h"
@@ -15,7 +15,7 @@
namespace syncer {
Commit::Commit(
- const std::map<ModelType, SyncDirectoryCommitContribution*>& contributions,
+ const std::map<ModelType, CommitContribution*>& contributions,
const sync_pb::ClientToServerMessage& message,
ExtensionsActivity::Records extensions_activity_buffer)
: contributions_(contributions),
@@ -71,7 +71,7 @@ Commit* Commit::Init(
commit_message);
// Finally, serialize all our contributions.
- for (std::map<ModelType, SyncDirectoryCommitContribution*>::iterator it =
+ for (std::map<ModelType, CommitContribution*>::iterator it =
contributions.begin(); it != contributions.end(); ++it) {
it->second->AddToCommitMessage(&message);
}
@@ -130,7 +130,7 @@ SyncerError Commit::PostAndProcessResponse(
// Let the contributors process the responses to each of their requests.
SyncerError processing_result = SYNCER_OK;
- for (std::map<ModelType, SyncDirectoryCommitContribution*>::iterator it =
+ for (std::map<ModelType, CommitContribution*>::iterator it =
contributions_.begin(); it != contributions_.end(); ++it) {
TRACE_EVENT1("sync", "ProcessCommitResponse",
"type", ModelTypeToString(it->first));
diff --git a/sync/engine/commit.h b/sync/engine/commit.h
index 236b514..993bd872 100644
--- a/sync/engine/commit.h
+++ b/sync/engine/commit.h
@@ -9,7 +9,7 @@
#include "base/stl_util.h"
#include "sync/base/sync_export.h"
-#include "sync/engine/sync_directory_commit_contribution.h"
+#include "sync/engine/commit_contribution.h"
#include "sync/internal_api/public/base/model_type.h"
#include "sync/internal_api/public/engine/model_safe_worker.h"
#include "sync/internal_api/public/util/syncer_error.h"
@@ -37,7 +37,7 @@ class Syncer;
class SYNC_EXPORT_PRIVATE Commit {
public:
Commit(
- const std::map<ModelType, SyncDirectoryCommitContribution*>&
+ const std::map<ModelType, CommitContribution*>&
contributions,
const sync_pb::ClientToServerMessage& message,
ExtensionsActivity::Records extensions_activity_buffer);
@@ -64,7 +64,7 @@ class SYNC_EXPORT_PRIVATE Commit {
void CleanUp();
private:
- typedef std::map<ModelType, SyncDirectoryCommitContribution*> ContributionMap;
+ typedef std::map<ModelType, CommitContribution*> ContributionMap;
ContributionMap contributions_;
STLValueDeleter<ContributionMap> deleter_;
diff --git a/sync/engine/commit_contribution.cc b/sync/engine/commit_contribution.cc
new file mode 100644
index 0000000..cef02b5
--- /dev/null
+++ b/sync/engine/commit_contribution.cc
@@ -0,0 +1,13 @@
+// Copyright 2014 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/engine/commit_contribution.h"
+
+namespace syncer {
+
+CommitContribution::CommitContribution() {}
+
+CommitContribution::~CommitContribution() {}
+
+} // namespace syncer
diff --git a/sync/engine/commit_contribution.h b/sync/engine/commit_contribution.h
new file mode 100644
index 0000000..e2e9108
--- /dev/null
+++ b/sync/engine/commit_contribution.h
@@ -0,0 +1,54 @@
+// Copyright 2014 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_ENGINE_COMMIT_CONTRIBUTION_H_
+#define SYNC_ENGINE_COMMIT_CONTRIBUTION_H_
+
+#include "sync/base/sync_export.h"
+#include "sync/internal_api/public/util/syncer_error.h"
+#include "sync/protocol/sync.pb.h"
+#include "sync/sessions/status_controller.h"
+
+namespace syncer {
+
+namespace sessions {
+class StatusController;
+} // namespace sessions
+
+// This class represents a set of items belonging to a particular data type that
+// have been selected from a CommitContributor and prepared for commit.
+//
+// This class handles the bookkeeping related to the commit of these items.
+class SYNC_EXPORT_PRIVATE CommitContribution {
+ public:
+ CommitContribution();
+ virtual ~CommitContribution() = 0;
+
+ // Serialize this contribution's entries to the given commit request |msg|.
+ //
+ // This function is not const. It may update some state in this contribution
+ // that will be used when processing the associated commit response. This
+ // function should not be called more than once.
+ virtual void AddToCommitMessage(sync_pb::ClientToServerMessage* msg) = 0;
+
+ // Updates this contribution's contents in accordance with the provided
+ // |response|.
+ //
+ // It is not valid to call this function unless AddToCommitMessage() was
+ // called earlier. This function should not be called more than once.
+ virtual SyncerError ProcessCommitResponse(
+ const sync_pb::ClientToServerResponse& response,
+ sessions::StatusController* status) = 0;
+
+ // Cleans up any temproary state associated with the commit. Must be called
+ // before destruction.
+ virtual void CleanUp() = 0;
+
+ // Returns the number of entries included in this contribution.
+ virtual size_t GetNumEntries() const = 0;
+};
+
+} // namespace syncer
+
+#endif // SYNC_ENGINE_COMMIT_CONTRIBUTION_H_
diff --git a/sync/engine/commit_contributor.cc b/sync/engine/commit_contributor.cc
new file mode 100644
index 0000000..6410c63
--- /dev/null
+++ b/sync/engine/commit_contributor.cc
@@ -0,0 +1,13 @@
+// Copyright 2014 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/engine/commit_contributor.h"
+
+namespace syncer {
+
+CommitContributor::CommitContributor() {}
+
+CommitContributor::~CommitContributor() {}
+
+} // namespace syncer
diff --git a/sync/engine/commit_contributor.h b/sync/engine/commit_contributor.h
new file mode 100644
index 0000000..2d190af
--- /dev/null
+++ b/sync/engine/commit_contributor.h
@@ -0,0 +1,38 @@
+// Copyright 2014 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_ENGINE_COMMIT_CONTRIBUTOR_H_
+#define SYNC_ENGINE_COMMIT_CONTRIBUTOR_H_
+
+#include <cstddef>
+
+#include "base/memory/scoped_ptr.h"
+
+namespace syncer {
+
+class CommitContribution;
+
+namespace syncable {
+class Directory;
+}
+
+// This class represents a source of items to commit to the sync server.
+//
+// When asked, it can return CommitContribution objects that contain a set of
+// items to be committed from this source.
+class CommitContributor {
+ public:
+ CommitContributor();
+ virtual ~CommitContributor() = 0;
+
+ // Gathers up to |max_entries| unsynced items from this contributor into a
+ // CommitContribution. Returns NULL when the contributor has nothing to
+ // contribute.
+ virtual scoped_ptr<CommitContribution> GetContribution(
+ size_t max_entries) = 0;
+};
+
+} // namespace
+
+#endif // SYNC_ENGINE_COMMIT_CONTRIBUTOR_H_
diff --git a/sync/engine/commit_processor.cc b/sync/engine/commit_processor.cc
index c54217b..d9bd423 100644
--- a/sync/engine/commit_processor.cc
+++ b/sync/engine/commit_processor.cc
@@ -6,8 +6,8 @@
#include <map>
-#include "sync/engine/sync_directory_commit_contribution.h"
-#include "sync/engine/sync_directory_commit_contributor.h"
+#include "sync/engine/commit_contribution.h"
+#include "sync/engine/commit_contributor.h"
#include "sync/protocol/sync.pb.h"
namespace syncer {
@@ -35,11 +35,11 @@ void CommitProcessor::GatherCommitContributions(
continue;
}
size_t spaces_remaining = max_entries - num_entries;
- SyncDirectoryCommitContribution* contribution =
+ scoped_ptr<CommitContribution> contribution =
cm_it->second->GetContribution(spaces_remaining);
if (contribution) {
num_entries += contribution->GetNumEntries();
- contributions->insert(std::make_pair(it.Get(), contribution));
+ contributions->insert(std::make_pair(it.Get(), contribution.release()));
}
if (num_entries >= max_entries) {
DCHECK_EQ(num_entries, max_entries)
diff --git a/sync/engine/commit_processor.h b/sync/engine/commit_processor.h
index 9ab0957..c3af5d81 100644
--- a/sync/engine/commit_processor.h
+++ b/sync/engine/commit_processor.h
@@ -20,8 +20,8 @@ namespace syncable {
class Directory;
} // namespace syncable
-class SyncDirectoryCommitContributor;
-class SyncDirectoryCommitContribution;
+class CommitContributor;
+class CommitContribution;
// This class manages the set of per-type committer objects.
//
@@ -31,12 +31,19 @@ class SyncDirectoryCommitContribution;
// contains a type which was not previously registered.
class SYNC_EXPORT_PRIVATE CommitProcessor {
public:
- typedef std::map<ModelType, SyncDirectoryCommitContribution*> ContributionMap;
+ typedef std::map<ModelType, CommitContribution*> ContributionMap;
+ // Contructs a CommitProcessor from a map of CommitContributors.
+ // The CommitProcessor does not own this map.
explicit CommitProcessor(CommitContributorMap* commit_contributor_map);
~CommitProcessor();
// Gathers a set of contributions to be used to populate a commit message.
+ //
+ // For each of the |commit_types| in this CommitProcessor's CommitContributor
+ // map, gather any entries queued for commit into CommitContributions. The
+ // total number of entries in all the returned CommitContributions shall not
+ // exceed |max_entries|.
void GatherCommitContributions(
ModelTypeSet commit_types,
size_t max_entries,
diff --git a/sync/engine/sync_directory_commit_contribution.cc b/sync/engine/directory_commit_contribution.cc
index f43131e3..2fd7b30 100644
--- a/sync/engine/sync_directory_commit_contribution.cc
+++ b/sync/engine/directory_commit_contribution.cc
@@ -1,8 +1,8 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 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/engine/sync_directory_commit_contribution.h"
+#include "sync/engine/directory_commit_contribution.h"
#include "sync/engine/commit_util.h"
#include "sync/engine/get_commit_ids.h"
@@ -15,12 +15,12 @@ namespace syncer {
using syncable::GET_BY_HANDLE;
using syncable::SYNCER;
-SyncDirectoryCommitContribution::~SyncDirectoryCommitContribution() {
+DirectoryCommitContribution::~DirectoryCommitContribution() {
DCHECK(!syncing_bits_set_);
}
// static.
-SyncDirectoryCommitContribution* SyncDirectoryCommitContribution::Build(
+scoped_ptr<DirectoryCommitContribution> DirectoryCommitContribution::Build(
syncable::Directory* dir,
ModelType type,
size_t max_entries) {
@@ -30,7 +30,7 @@ SyncDirectoryCommitContribution* SyncDirectoryCommitContribution::Build(
GetCommitIdsForType(&trans, type, max_entries, &metahandles);
if (metahandles.empty())
- return NULL;
+ return scoped_ptr<DirectoryCommitContribution>();
google::protobuf::RepeatedPtrField<sync_pb::SyncEntity> entities;
for (std::vector<int64>::iterator it = metahandles.begin();
@@ -41,10 +41,11 @@ SyncDirectoryCommitContribution* SyncDirectoryCommitContribution::Build(
entry.PutSyncing(true);
}
- return new SyncDirectoryCommitContribution(metahandles, entities, dir);
+ return scoped_ptr<DirectoryCommitContribution>(
+ new DirectoryCommitContribution(metahandles, entities, dir));
}
-void SyncDirectoryCommitContribution::AddToCommitMessage(
+void DirectoryCommitContribution::AddToCommitMessage(
sync_pb::ClientToServerMessage* msg) {
DCHECK(syncing_bits_set_);
sync_pb::CommitMessage* commit_message = msg->mutable_commit();
@@ -54,7 +55,7 @@ void SyncDirectoryCommitContribution::AddToCommitMessage(
RepeatedPtrFieldBackInserter(commit_message->mutable_entries()));
}
-SyncerError SyncDirectoryCommitContribution::ProcessCommitResponse(
+SyncerError DirectoryCommitContribution::ProcessCommitResponse(
const sync_pb::ClientToServerResponse& response,
sessions::StatusController* status) {
DCHECK(syncing_bits_set_);
@@ -131,16 +132,16 @@ SyncerError SyncDirectoryCommitContribution::ProcessCommitResponse(
}
}
-void SyncDirectoryCommitContribution::CleanUp() {
+void DirectoryCommitContribution::CleanUp() {
DCHECK(syncing_bits_set_);
UnsetSyncingBits();
}
-size_t SyncDirectoryCommitContribution::GetNumEntries() const {
+size_t DirectoryCommitContribution::GetNumEntries() const {
return metahandles_.size();
}
-SyncDirectoryCommitContribution::SyncDirectoryCommitContribution(
+DirectoryCommitContribution::DirectoryCommitContribution(
const std::vector<int64>& metahandles,
const google::protobuf::RepeatedPtrField<sync_pb::SyncEntity>& entities,
syncable::Directory* dir)
@@ -151,7 +152,7 @@ SyncDirectoryCommitContribution::SyncDirectoryCommitContribution(
syncing_bits_set_(true) {
}
-void SyncDirectoryCommitContribution::UnsetSyncingBits() {
+void DirectoryCommitContribution::UnsetSyncingBits() {
syncable::ModelNeutralWriteTransaction trans(FROM_HERE, SYNCER, dir_);
for (std::vector<int64>::const_iterator it = metahandles_.begin();
it != metahandles_.end(); ++it) {
diff --git a/sync/engine/sync_directory_commit_contribution.h b/sync/engine/directory_commit_contribution.h
index 8934056..508ac7c 100644
--- a/sync/engine/sync_directory_commit_contribution.h
+++ b/sync/engine/directory_commit_contribution.h
@@ -1,14 +1,16 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 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_ENGINE_SYNC_DIRECTORY_COMMIT_CONTRIBUTION_H_
-#define SYNC_ENGINE_SYNC_DIRECTORY_COMMIT_CONTRIBUTION_H_
+#ifndef SYNC_ENGINE_DIRECTORY_COMMIT_CONTRIBUTION_H_
+#define SYNC_ENGINE_DIRECTORY_COMMIT_CONTRIBUTION_H_
#include <vector>
#include "base/gtest_prod_util.h"
+#include "base/memory/scoped_ptr.h"
#include "sync/base/sync_export.h"
+#include "sync/engine/commit_contribution.h"
#include "sync/internal_api/public/base/model_type.h"
#include "sync/internal_api/public/util/syncer_error.h"
#include "sync/protocol/sync.pb.h"
@@ -30,10 +32,11 @@ class Directory;
// This class handles the bookkeeping related to the commit of these items,
// including processing the commit response message and setting and unsetting
// the SYNCING bits.
-class SYNC_EXPORT_PRIVATE SyncDirectoryCommitContribution {
+class SYNC_EXPORT_PRIVATE DirectoryCommitContribution
+ : public CommitContribution {
public:
// This destructor will DCHECK if UnsetSyncingBits() has not been called yet.
- ~SyncDirectoryCommitContribution();
+ virtual ~DirectoryCommitContribution();
// Build a CommitContribution from the IS_UNSYNCED items in |dir| with the
// given |type|. The contribution will include at most |max_items| entries.
@@ -41,7 +44,7 @@ class SYNC_EXPORT_PRIVATE SyncDirectoryCommitContribution {
// This function may return NULL if this type has no items ready for and
// requiring commit. This function may make model neutral changes to the
// directory.
- static SyncDirectoryCommitContribution* Build(
+ static scoped_ptr<DirectoryCommitContribution> Build(
syncable::Directory* dir,
ModelType type,
size_t max_items);
@@ -51,7 +54,7 @@ class SYNC_EXPORT_PRIVATE SyncDirectoryCommitContribution {
// This function is not const. It will update some state in this contribution
// that will be used when processing the associated commit response. This
// function should not be called more than once.
- void AddToCommitMessage(sync_pb::ClientToServerMessage* msg);
+ virtual void AddToCommitMessage(sync_pb::ClientToServerMessage* msg) OVERRIDE;
// Updates this contribution's contents in accordance with the provided
// |response|.
@@ -59,24 +62,24 @@ class SYNC_EXPORT_PRIVATE SyncDirectoryCommitContribution {
// This function may make model-neutral changes to the directory. It is not
// valid to call this function unless AddToCommitMessage() was called earlier.
// This function should not be called more than once.
- SyncerError ProcessCommitResponse(
+ virtual SyncerError ProcessCommitResponse(
const sync_pb::ClientToServerResponse& response,
- sessions::StatusController* status);
+ sessions::StatusController* status) OVERRIDE;
// Cleans up any temproary state associated with the commit. Must be called
// before destruction.
- void CleanUp();
+ virtual void CleanUp() OVERRIDE;
// Returns the number of entries included in this contribution.
- size_t GetNumEntries() const;
+ virtual size_t GetNumEntries() const OVERRIDE;
private:
- class SyncDirectoryCommitContributionTest;
- FRIEND_TEST_ALL_PREFIXES(SyncDirectoryCommitContributionTest, GatherByTypes);
- FRIEND_TEST_ALL_PREFIXES(SyncDirectoryCommitContributionTest,
+ class DirectoryCommitContributionTest;
+ FRIEND_TEST_ALL_PREFIXES(DirectoryCommitContributionTest, GatherByTypes);
+ FRIEND_TEST_ALL_PREFIXES(DirectoryCommitContributionTest,
GatherAndTruncate);
- SyncDirectoryCommitContribution(
+ DirectoryCommitContribution(
const std::vector<int64>& metahandles,
const google::protobuf::RepeatedPtrField<sync_pb::SyncEntity>& entities,
syncable::Directory* directory);
@@ -94,9 +97,9 @@ class SYNC_EXPORT_PRIVATE SyncDirectoryCommitContribution {
// called. This flag must be unset by the time our destructor is called.
bool syncing_bits_set_;
- DISALLOW_COPY_AND_ASSIGN(SyncDirectoryCommitContribution);
+ DISALLOW_COPY_AND_ASSIGN(DirectoryCommitContribution);
};
} // namespace syncer
-#endif // SYNC_ENGINE_SYNC_DIRECTORY_COMMIT_CONTRIBUTION_H_
+#endif // SYNC_ENGINE_DIRECTORY_COMMIT_CONTRIBUTION_H_
diff --git a/sync/engine/sync_directory_commit_contribution_unittest.cc b/sync/engine/directory_commit_contribution_unittest.cc
index 75f88bd..e17817c 100644
--- a/sync/engine/sync_directory_commit_contribution_unittest.cc
+++ b/sync/engine/directory_commit_contribution_unittest.cc
@@ -1,8 +1,8 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 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/engine/sync_directory_commit_contribution.h"
+#include "sync/engine/directory_commit_contribution.h"
#include "base/message_loop/message_loop.h"
#include "sync/sessions/status_controller.h"
@@ -17,7 +17,7 @@
namespace syncer {
-class SyncDirectoryCommitContributionTest : public ::testing::Test {
+class DirectoryCommitContributionTest : public ::testing::Test {
public:
virtual void SetUp() OVERRIDE {
dir_maker_.SetUp();
@@ -74,9 +74,9 @@ class SyncDirectoryCommitContributionTest : public ::testing::Test {
TestDirectorySetterUpper dir_maker_;
};
-// Verify that the SyncDirectoryCommitContribution contains only entries of its
+// Verify that the DirectoryCommitContribution contains only entries of its
// specified type.
-TEST_F(SyncDirectoryCommitContributionTest, GatherByTypes) {
+TEST_F(DirectoryCommitContributionTest, GatherByTypes) {
int64 pref1;
{
syncable::WriteTransaction trans(FROM_HERE, syncable::UNITTEST, dir());
@@ -85,8 +85,8 @@ TEST_F(SyncDirectoryCommitContributionTest, GatherByTypes) {
CreateUnsyncedItem(&trans, EXTENSIONS, "extension1");
}
- scoped_ptr<SyncDirectoryCommitContribution> cc(
- SyncDirectoryCommitContribution::Build(dir(), PREFERENCES, 5));
+ scoped_ptr<DirectoryCommitContribution> cc(
+ DirectoryCommitContribution::Build(dir(), PREFERENCES, 5));
ASSERT_EQ(2U, cc->GetNumEntries());
const std::vector<int64>& metahandles = cc->metahandles_;
@@ -98,9 +98,9 @@ TEST_F(SyncDirectoryCommitContributionTest, GatherByTypes) {
cc->CleanUp();
}
-// Verify that the SyncDirectoryCommitContributionTest builder function
+// Verify that the DirectoryCommitContributionTest builder function
// truncates if necessary.
-TEST_F(SyncDirectoryCommitContributionTest, GatherAndTruncate) {
+TEST_F(DirectoryCommitContributionTest, GatherAndTruncate) {
int64 pref1;
int64 pref2;
{
@@ -110,8 +110,8 @@ TEST_F(SyncDirectoryCommitContributionTest, GatherAndTruncate) {
CreateUnsyncedItem(&trans, EXTENSIONS, "extension1");
}
- scoped_ptr<SyncDirectoryCommitContribution> cc(
- SyncDirectoryCommitContribution::Build(dir(), PREFERENCES, 1));
+ scoped_ptr<DirectoryCommitContribution> cc(
+ DirectoryCommitContribution::Build(dir(), PREFERENCES, 1));
ASSERT_EQ(1U, cc->GetNumEntries());
int64 only_metahandle = cc->metahandles_[0];
@@ -120,11 +120,11 @@ TEST_F(SyncDirectoryCommitContributionTest, GatherAndTruncate) {
cc->CleanUp();
}
-// Sanity check for building commits from SyncDirectoryCommitContributions.
+// Sanity check for building commits from DirectoryCommitContributions.
// This test makes two CommitContribution objects of different types and uses
// them to initialize a commit message. Then it checks that the contents of the
// commit message match those of the directory they came from.
-TEST_F(SyncDirectoryCommitContributionTest, PrepareCommit) {
+TEST_F(DirectoryCommitContributionTest, PrepareCommit) {
{
syncable::WriteTransaction trans(FROM_HERE, syncable::UNITTEST, dir());
CreateUnsyncedItem(&trans, PREFERENCES, "pref1");
@@ -132,10 +132,10 @@ TEST_F(SyncDirectoryCommitContributionTest, PrepareCommit) {
CreateUnsyncedItem(&trans, EXTENSIONS, "extension1");
}
- scoped_ptr<SyncDirectoryCommitContribution> pref_cc(
- SyncDirectoryCommitContribution::Build(dir(), PREFERENCES, 25));
- scoped_ptr<SyncDirectoryCommitContribution> ext_cc(
- SyncDirectoryCommitContribution::Build(dir(), EXTENSIONS, 25));
+ scoped_ptr<DirectoryCommitContribution> pref_cc(
+ DirectoryCommitContribution::Build(dir(), PREFERENCES, 25));
+ scoped_ptr<DirectoryCommitContribution> ext_cc(
+ DirectoryCommitContribution::Build(dir(), EXTENSIONS, 25));
sync_pb::ClientToServerMessage message;
pref_cc->AddToCommitMessage(&message);
@@ -173,7 +173,7 @@ TEST_F(SyncDirectoryCommitContributionTest, PrepareCommit) {
// Creates some unsynced items, pretends to commit them, and hands back a
// specially crafted response to the syncer in order to test commit response
// processing. The response simulates a succesful commit scenario.
-TEST_F(SyncDirectoryCommitContributionTest, ProcessCommitResponse) {
+TEST_F(DirectoryCommitContributionTest, ProcessCommitResponse) {
int64 pref1_handle;
int64 pref2_handle;
int64 ext1_handle;
@@ -184,10 +184,10 @@ TEST_F(SyncDirectoryCommitContributionTest, ProcessCommitResponse) {
ext1_handle = CreateUnsyncedItem(&trans, EXTENSIONS, "extension1");
}
- scoped_ptr<SyncDirectoryCommitContribution> pref_cc(
- SyncDirectoryCommitContribution::Build(dir(), PREFERENCES, 25));
- scoped_ptr<SyncDirectoryCommitContribution> ext_cc(
- SyncDirectoryCommitContribution::Build(dir(), EXTENSIONS, 25));
+ scoped_ptr<DirectoryCommitContribution> pref_cc(
+ DirectoryCommitContribution::Build(dir(), PREFERENCES, 25));
+ scoped_ptr<DirectoryCommitContribution> ext_cc(
+ DirectoryCommitContribution::Build(dir(), EXTENSIONS, 25));
sync_pb::ClientToServerMessage message;
pref_cc->AddToCommitMessage(&message);
diff --git a/sync/engine/directory_commit_contributor.cc b/sync/engine/directory_commit_contributor.cc
new file mode 100644
index 0000000..41d1e12
--- /dev/null
+++ b/sync/engine/directory_commit_contributor.cc
@@ -0,0 +1,25 @@
+// Copyright 2014 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/engine/directory_commit_contributor.h"
+
+#include "sync/engine/directory_commit_contribution.h"
+
+namespace syncer {
+
+DirectoryCommitContributor::DirectoryCommitContributor(
+ syncable::Directory* dir,
+ ModelType type)
+ : dir_(dir),
+ type_(type) {}
+
+DirectoryCommitContributor::~DirectoryCommitContributor() {}
+
+scoped_ptr<CommitContribution>
+DirectoryCommitContributor::GetContribution(size_t max_entries) {
+ return DirectoryCommitContribution::Build(dir_, type_, max_entries)
+ .PassAs<CommitContribution>();
+}
+
+} // namespace syncer
diff --git a/sync/engine/directory_commit_contributor.h b/sync/engine/directory_commit_contributor.h
new file mode 100644
index 0000000..abc1a6c
--- /dev/null
+++ b/sync/engine/directory_commit_contributor.h
@@ -0,0 +1,45 @@
+// Copyright 2014 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_ENGINE_DIRECTORY_COMMIT_CONTRIBUTOR_H_
+#define SYNC_ENGINE_DIRECTORY_COMMIT_CONTRIBUTOR_H_
+
+#include <map>
+
+#include "base/memory/scoped_ptr.h"
+#include "sync/engine/commit_contributor.h"
+#include "sync/engine/directory_commit_contribution.h"
+#include "sync/internal_api/public/base/model_type.h"
+
+namespace syncer {
+
+namespace syncable {
+class Directory;
+}
+
+// This class represents the syncable::Directory as a source of items to commit
+// to the sync server.
+//
+// Each instance of this class represents a particular type within the
+// syncable::Directory. When asked, it will iterate through the directory, grab
+// any items of its type that are ready for commit, and return them in the form
+// of a DirectoryCommitContribution.
+class DirectoryCommitContributor : public CommitContributor {
+ public:
+ DirectoryCommitContributor(syncable::Directory* dir, ModelType type);
+ virtual ~DirectoryCommitContributor();
+
+ virtual scoped_ptr<CommitContribution> GetContribution(
+ size_t max_entries) OVERRIDE;
+
+ private:
+ syncable::Directory* dir_;
+ ModelType type_;
+
+ DISALLOW_COPY_AND_ASSIGN(DirectoryCommitContributor);
+};
+
+} // namespace
+
+#endif // SYNC_ENGINE_DIRECTORY_COMMIT_CONTRIBUTOR_H_
diff --git a/sync/engine/sync_directory_update_handler.cc b/sync/engine/directory_update_handler.cc
index 3acfea4..be36082 100644
--- a/sync/engine/sync_directory_update_handler.cc
+++ b/sync/engine/directory_update_handler.cc
@@ -1,8 +1,8 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 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/engine/sync_directory_update_handler.h"
+#include "sync/engine/directory_update_handler.h"
#include "sync/engine/conflict_resolver.h"
#include "sync/engine/process_updates_util.h"
@@ -16,7 +16,7 @@ namespace syncer {
using syncable::SYNCER;
-SyncDirectoryUpdateHandler::SyncDirectoryUpdateHandler(
+DirectoryUpdateHandler::DirectoryUpdateHandler(
syncable::Directory* dir,
ModelType type,
scoped_refptr<ModelSafeWorker> worker)
@@ -24,14 +24,14 @@ SyncDirectoryUpdateHandler::SyncDirectoryUpdateHandler(
type_(type),
worker_(worker) {}
-SyncDirectoryUpdateHandler::~SyncDirectoryUpdateHandler() {}
+DirectoryUpdateHandler::~DirectoryUpdateHandler() {}
-void SyncDirectoryUpdateHandler::GetDownloadProgress(
+void DirectoryUpdateHandler::GetDownloadProgress(
sync_pb::DataTypeProgressMarker* progress_marker) const {
dir_->GetDownloadProgress(type_, progress_marker);
}
-void SyncDirectoryUpdateHandler::ProcessGetUpdatesResponse(
+void DirectoryUpdateHandler::ProcessGetUpdatesResponse(
const sync_pb::DataTypeProgressMarker& progress_marker,
const SyncEntityList& applicable_updates,
sessions::StatusController* status) {
@@ -40,8 +40,7 @@ void SyncDirectoryUpdateHandler::ProcessGetUpdatesResponse(
UpdateProgressMarker(progress_marker);
}
-void SyncDirectoryUpdateHandler::ApplyUpdates(
- sessions::StatusController* status) {
+void DirectoryUpdateHandler::ApplyUpdates(sessions::StatusController* status) {
if (!IsApplyUpdatesRequired()) {
return;
}
@@ -49,14 +48,14 @@ void SyncDirectoryUpdateHandler::ApplyUpdates(
// This will invoke handlers that belong to the model and its thread, so we
// switch to the appropriate thread before we start this work.
WorkCallback c = base::Bind(
- &SyncDirectoryUpdateHandler::ApplyUpdatesImpl,
+ &DirectoryUpdateHandler::ApplyUpdatesImpl,
// We wait until the callback is executed. We can safely use Unretained.
base::Unretained(this),
base::Unretained(status));
worker_->DoWorkAndWaitUntilDone(c);
}
-void SyncDirectoryUpdateHandler::PassiveApplyUpdates(
+void DirectoryUpdateHandler::PassiveApplyUpdates(
sessions::StatusController* status) {
if (!IsApplyUpdatesRequired()) {
return;
@@ -66,7 +65,7 @@ void SyncDirectoryUpdateHandler::PassiveApplyUpdates(
ApplyUpdatesImpl(status);
}
-SyncerError SyncDirectoryUpdateHandler::ApplyUpdatesImpl(
+SyncerError DirectoryUpdateHandler::ApplyUpdatesImpl(
sessions::StatusController* status) {
syncable::WriteTransaction trans(FROM_HERE, syncable::SYNCER, dir_);
@@ -133,7 +132,7 @@ SyncerError SyncDirectoryUpdateHandler::ApplyUpdatesImpl(
return SYNCER_OK;
}
-bool SyncDirectoryUpdateHandler::IsApplyUpdatesRequired() {
+bool DirectoryUpdateHandler::IsApplyUpdatesRequired() {
if (IsControlType(type_)) {
return false; // We don't process control types here.
}
@@ -141,14 +140,14 @@ bool SyncDirectoryUpdateHandler::IsApplyUpdatesRequired() {
return dir_->TypeHasUnappliedUpdates(type_);
}
-void SyncDirectoryUpdateHandler::UpdateSyncEntities(
+void DirectoryUpdateHandler::UpdateSyncEntities(
syncable::ModelNeutralWriteTransaction* trans,
const SyncEntityList& applicable_updates,
sessions::StatusController* status) {
ProcessDownloadedUpdates(dir_, trans, type_, applicable_updates, status);
}
-void SyncDirectoryUpdateHandler::UpdateProgressMarker(
+void DirectoryUpdateHandler::UpdateProgressMarker(
const sync_pb::DataTypeProgressMarker& progress_marker) {
int field_number = progress_marker.data_type_id();
ModelType model_type = GetModelTypeFromSpecificsFieldNumber(field_number);
diff --git a/sync/engine/sync_directory_update_handler.h b/sync/engine/directory_update_handler.h
index 2e4f33e..25acbd9 100644
--- a/sync/engine/sync_directory_update_handler.h
+++ b/sync/engine/directory_update_handler.h
@@ -1,9 +1,9 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 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_ENGINE_SYNC_DIRECTORY_UPDATE_HANDLER_H_
-#define SYNC_ENGINE_SYNC_DIRECTORY_UPDATE_HANDLER_H_
+#ifndef SYNC_ENGINE_DIRECTORY_UPDATE_HANDLER_H_
+#define SYNC_ENGINE_DIRECTORY_UPDATE_HANDLER_H_
#include <map>
@@ -11,6 +11,7 @@
#include "base/memory/ref_counted.h"
#include "sync/base/sync_export.h"
#include "sync/engine/process_updates_util.h"
+#include "sync/engine/update_handler.h"
#include "sync/internal_api/public/base/model_type.h"
#include "sync/internal_api/public/util/syncer_error.h"
@@ -37,16 +38,16 @@ class ModelSafeWorker;
// Each instance of this class represents a particular type in the
// syncable::Directory. It can store and retreive that type's progress markers.
// It can also process a set of received SyncEntities and store their data.
-class SYNC_EXPORT_PRIVATE SyncDirectoryUpdateHandler {
+class SYNC_EXPORT_PRIVATE DirectoryUpdateHandler : public UpdateHandler {
public:
- SyncDirectoryUpdateHandler(syncable::Directory* dir,
- ModelType type,
- scoped_refptr<ModelSafeWorker> worker);
- ~SyncDirectoryUpdateHandler();
+ DirectoryUpdateHandler(syncable::Directory* dir,
+ ModelType type,
+ scoped_refptr<ModelSafeWorker> worker);
+ virtual ~DirectoryUpdateHandler();
// Fills the given parameter with the stored progress marker for this type.
- void GetDownloadProgress(
- sync_pb::DataTypeProgressMarker* progress_marker) const;
+ virtual void GetDownloadProgress(
+ sync_pb::DataTypeProgressMarker* progress_marker) const OVERRIDE;
// Processes the contents of a GetUpdates response message.
//
@@ -54,22 +55,22 @@ class SYNC_EXPORT_PRIVATE SyncDirectoryUpdateHandler {
// single GetUpdates response message. The progress marker's type must match
// this update handler's type, and the set of SyncEntities must include all
// entities of this type found in the response message.
- void ProcessGetUpdatesResponse(
+ virtual void ProcessGetUpdatesResponse(
const sync_pb::DataTypeProgressMarker& progress_marker,
const SyncEntityList& applicable_updates,
- sessions::StatusController* status);
+ sessions::StatusController* status) OVERRIDE;
// If there are updates to apply, apply them on the proper thread.
// Delegates to ApplyUpdatesImpl().
- void ApplyUpdates(sessions::StatusController* status);
+ virtual void ApplyUpdates(sessions::StatusController* status) OVERRIDE;
// Apply updates on the sync thread. This is for use during initial sync
// prior to model association.
- void PassiveApplyUpdates(sessions::StatusController* status);
+ virtual void PassiveApplyUpdates(sessions::StatusController* status) OVERRIDE;
private:
- friend class SyncDirectoryUpdateHandlerApplyUpdateTest;
- friend class SyncDirectoryUpdateHandlerProcessUpdateTest;
+ friend class DirectoryUpdateHandlerApplyUpdateTest;
+ friend class DirectoryUpdateHandlerProcessUpdateTest;
// Sometimes there is nothing to do, so we can return without doing anything.
bool IsApplyUpdatesRequired();
@@ -93,9 +94,9 @@ class SYNC_EXPORT_PRIVATE SyncDirectoryUpdateHandler {
ModelType type_;
scoped_refptr<ModelSafeWorker> worker_;
- DISALLOW_COPY_AND_ASSIGN(SyncDirectoryUpdateHandler);
+ DISALLOW_COPY_AND_ASSIGN(DirectoryUpdateHandler);
};
} // namespace syncer
-#endif // SYNC_ENGINE_SYNC_DIRECTORY_UPDATE_HANDLER_H_
+#endif // SYNC_ENGINE_DIRECTORY_UPDATE_HANDLER_H_
diff --git a/sync/engine/sync_directory_update_handler_unittest.cc b/sync/engine/directory_update_handler_unittest.cc
index 3cc8e7d..0352505 100644
--- a/sync/engine/sync_directory_update_handler_unittest.cc
+++ b/sync/engine/directory_update_handler_unittest.cc
@@ -1,8 +1,8 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 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/engine/sync_directory_update_handler.h"
+#include "sync/engine/directory_update_handler.h"
#include "base/compiler_specific.h"
#include "base/message_loop/message_loop.h"
@@ -34,13 +34,13 @@ using syncable::UNITTEST;
// Update processing is what occurs when we first download updates. It converts
// the received protobuf message into information in the syncable::Directory.
// Any invalid or redundant updates will be dropped at this point.
-class SyncDirectoryUpdateHandlerProcessUpdateTest : public ::testing::Test {
+class DirectoryUpdateHandlerProcessUpdateTest : public ::testing::Test {
public:
- SyncDirectoryUpdateHandlerProcessUpdateTest()
+ DirectoryUpdateHandlerProcessUpdateTest()
: ui_worker_(new FakeModelWorker(GROUP_UI)) {
}
- virtual ~SyncDirectoryUpdateHandlerProcessUpdateTest() {}
+ virtual ~DirectoryUpdateHandlerProcessUpdateTest() {}
virtual void SetUp() OVERRIDE {
dir_maker_.SetUp();
@@ -62,13 +62,13 @@ class SyncDirectoryUpdateHandlerProcessUpdateTest : public ::testing::Test {
// This exists mostly to give tests access to the protected member function.
// Warning: This takes the syncable directory lock.
void UpdateSyncEntities(
- SyncDirectoryUpdateHandler* handler,
+ DirectoryUpdateHandler* handler,
const SyncEntityList& applicable_updates,
sessions::StatusController* status);
// Another function to access private member functions.
void UpdateProgressMarkers(
- SyncDirectoryUpdateHandler* handler,
+ DirectoryUpdateHandler* handler,
const sync_pb::DataTypeProgressMarker& progress);
scoped_refptr<FakeModelWorker> ui_worker() {
@@ -82,7 +82,7 @@ class SyncDirectoryUpdateHandlerProcessUpdateTest : public ::testing::Test {
};
scoped_ptr<sync_pb::SyncEntity>
-SyncDirectoryUpdateHandlerProcessUpdateTest::CreateUpdate(
+DirectoryUpdateHandlerProcessUpdateTest::CreateUpdate(
const std::string& id,
const std::string& parent,
const ModelType& type) {
@@ -96,16 +96,16 @@ SyncDirectoryUpdateHandlerProcessUpdateTest::CreateUpdate(
return e.Pass();
}
-void SyncDirectoryUpdateHandlerProcessUpdateTest::UpdateSyncEntities(
- SyncDirectoryUpdateHandler* handler,
+void DirectoryUpdateHandlerProcessUpdateTest::UpdateSyncEntities(
+ DirectoryUpdateHandler* handler,
const SyncEntityList& applicable_updates,
sessions::StatusController* status) {
syncable::ModelNeutralWriteTransaction trans(FROM_HERE, UNITTEST, dir());
handler->UpdateSyncEntities(&trans, applicable_updates, status);
}
-void SyncDirectoryUpdateHandlerProcessUpdateTest::UpdateProgressMarkers(
- SyncDirectoryUpdateHandler* handler,
+void DirectoryUpdateHandlerProcessUpdateTest::UpdateProgressMarkers(
+ DirectoryUpdateHandler* handler,
const sync_pb::DataTypeProgressMarker& progress) {
handler->UpdateProgressMarker(progress);
}
@@ -113,8 +113,8 @@ void SyncDirectoryUpdateHandlerProcessUpdateTest::UpdateProgressMarkers(
static const char kCacheGuid[] = "IrcjZ2jyzHDV9Io4+zKcXQ==";
// Test that the bookmark tag is set on newly downloaded items.
-TEST_F(SyncDirectoryUpdateHandlerProcessUpdateTest, NewBookmarkTag) {
- SyncDirectoryUpdateHandler handler(dir(), BOOKMARKS, ui_worker());
+TEST_F(DirectoryUpdateHandlerProcessUpdateTest, NewBookmarkTag) {
+ DirectoryUpdateHandler handler(dir(), BOOKMARKS, ui_worker());
sync_pb::GetUpdatesResponse gu_response;
sessions::StatusController status;
@@ -150,9 +150,9 @@ TEST_F(SyncDirectoryUpdateHandlerProcessUpdateTest, NewBookmarkTag) {
}
// Test the receipt of a type root node.
-TEST_F(SyncDirectoryUpdateHandlerProcessUpdateTest,
+TEST_F(DirectoryUpdateHandlerProcessUpdateTest,
ReceiveServerCreatedBookmarkFolders) {
- SyncDirectoryUpdateHandler handler(dir(), BOOKMARKS, ui_worker());
+ DirectoryUpdateHandler handler(dir(), BOOKMARKS, ui_worker());
sync_pb::GetUpdatesResponse gu_response;
sessions::StatusController status;
@@ -185,8 +185,8 @@ TEST_F(SyncDirectoryUpdateHandlerProcessUpdateTest,
}
// Test the receipt of a non-bookmark item.
-TEST_F(SyncDirectoryUpdateHandlerProcessUpdateTest, ReceiveNonBookmarkItem) {
- SyncDirectoryUpdateHandler handler(dir(), PREFERENCES, ui_worker());
+TEST_F(DirectoryUpdateHandlerProcessUpdateTest, ReceiveNonBookmarkItem) {
+ DirectoryUpdateHandler handler(dir(), PREFERENCES, ui_worker());
sync_pb::GetUpdatesResponse gu_response;
sessions::StatusController status;
@@ -216,8 +216,8 @@ TEST_F(SyncDirectoryUpdateHandlerProcessUpdateTest, ReceiveNonBookmarkItem) {
}
// Tests the setting of progress markers.
-TEST_F(SyncDirectoryUpdateHandlerProcessUpdateTest, ProcessNewProgressMarkers) {
- SyncDirectoryUpdateHandler handler(dir(), BOOKMARKS, ui_worker());
+TEST_F(DirectoryUpdateHandlerProcessUpdateTest, ProcessNewProgressMarkers) {
+ DirectoryUpdateHandler handler(dir(), BOOKMARKS, ui_worker());
sync_pb::DataTypeProgressMarker progress;
progress.set_data_type_id(GetSpecificsFieldNumberFromModelType(BOOKMARKS));
@@ -247,9 +247,9 @@ TEST_F(SyncDirectoryUpdateHandlerProcessUpdateTest, ProcessNewProgressMarkers) {
// update processing tests. Currently, we're bypassing most of those issues by
// using FakeModelWorkers, so there's not much difference between the two test
// harnesses.
-class SyncDirectoryUpdateHandlerApplyUpdateTest : public ::testing::Test {
+class DirectoryUpdateHandlerApplyUpdateTest : public ::testing::Test {
public:
- SyncDirectoryUpdateHandlerApplyUpdateTest()
+ DirectoryUpdateHandlerApplyUpdateTest()
: ui_worker_(new FakeModelWorker(GROUP_UI)),
password_worker_(new FakeModelWorker(GROUP_PASSWORD)),
passive_worker_(new FakeModelWorker(GROUP_PASSIVE)),
@@ -261,10 +261,10 @@ class SyncDirectoryUpdateHandlerApplyUpdateTest : public ::testing::Test {
update_handler_map_.insert(std::make_pair(
BOOKMARKS,
- new SyncDirectoryUpdateHandler(directory(), BOOKMARKS, ui_worker_)));
+ new DirectoryUpdateHandler(directory(), BOOKMARKS, ui_worker_)));
update_handler_map_.insert(std::make_pair(
PASSWORDS,
- new SyncDirectoryUpdateHandler(directory(),
+ new DirectoryUpdateHandler(directory(),
PASSWORDS,
password_worker_)));
}
@@ -291,7 +291,7 @@ class SyncDirectoryUpdateHandlerApplyUpdateTest : public ::testing::Test {
}
private:
- typedef std::map<ModelType, SyncDirectoryUpdateHandler*> UpdateHandlerMap;
+ typedef std::map<ModelType, UpdateHandler*> UpdateHandlerMap;
base::MessageLoop loop_; // Needed to initialize the directory.
TestDirectorySetterUpper dir_maker_;
@@ -314,7 +314,7 @@ sync_pb::EntitySpecifics DefaultBookmarkSpecifics() {
} // namespace
// Test update application for a few bookmark items.
-TEST_F(SyncDirectoryUpdateHandlerApplyUpdateTest, SimpleBookmark) {
+TEST_F(DirectoryUpdateHandlerApplyUpdateTest, SimpleBookmark) {
sessions::StatusController status;
std::string root_server_id = syncable::GetNullId().GetServerId();
@@ -351,7 +351,7 @@ TEST_F(SyncDirectoryUpdateHandlerApplyUpdateTest, SimpleBookmark) {
}
// Test that the applicator can handle updates delivered out of order.
-TEST_F(SyncDirectoryUpdateHandlerApplyUpdateTest,
+TEST_F(DirectoryUpdateHandlerApplyUpdateTest,
BookmarkChildrenBeforeParent) {
// Start with some bookmarks whose parents are unknown.
std::string root_server_id = syncable::GetNullId().GetServerId();
@@ -409,7 +409,7 @@ TEST_F(SyncDirectoryUpdateHandlerApplyUpdateTest,
// Try to apply changes on an item that is both IS_UNSYNCED and
// IS_UNAPPLIED_UPDATE. Conflict resolution should be performed.
-TEST_F(SyncDirectoryUpdateHandlerApplyUpdateTest, SimpleBookmarkConflict) {
+TEST_F(DirectoryUpdateHandlerApplyUpdateTest, SimpleBookmarkConflict) {
int64 handle = entry_factory()->CreateUnappliedAndUnsyncedBookmarkItem("x");
int original_server_version = -10;
@@ -445,7 +445,7 @@ TEST_F(SyncDirectoryUpdateHandlerApplyUpdateTest, SimpleBookmarkConflict) {
// follow the normal "server wins" logic, we'd end up violating hierarchy
// constraints. The hierarchy conflict must take precedence. We can not allow
// the update to be applied. The item must remain in the conflict state.
-TEST_F(SyncDirectoryUpdateHandlerApplyUpdateTest, HierarchyAndSimpleConflict) {
+TEST_F(DirectoryUpdateHandlerApplyUpdateTest, HierarchyAndSimpleConflict) {
// Create a simply-conflicting item. It will start with valid parent ids.
int64 handle = entry_factory()->CreateUnappliedAndUnsyncedBookmarkItem(
"orphaned_by_server");
@@ -476,7 +476,7 @@ TEST_F(SyncDirectoryUpdateHandlerApplyUpdateTest, HierarchyAndSimpleConflict) {
// Attempt to apply an udpate that would create a bookmark folder loop. This
// application should fail.
-TEST_F(SyncDirectoryUpdateHandlerApplyUpdateTest, BookmarkFolderLoop) {
+TEST_F(DirectoryUpdateHandlerApplyUpdateTest, BookmarkFolderLoop) {
// Item 'X' locally has parent of 'root'. Server is updating it to have
// parent of 'Y'.
@@ -521,7 +521,7 @@ TEST_F(SyncDirectoryUpdateHandlerApplyUpdateTest, BookmarkFolderLoop) {
// Test update application where the update has been orphaned by a local folder
// deletion. The update application attempt should fail.
-TEST_F(SyncDirectoryUpdateHandlerApplyUpdateTest,
+TEST_F(DirectoryUpdateHandlerApplyUpdateTest,
HierarchyConflictDeletedParent) {
// Create a locally deleted parent item.
int64 parent_handle;
@@ -559,7 +559,7 @@ TEST_F(SyncDirectoryUpdateHandlerApplyUpdateTest,
// Attempt to apply an update that deletes a folder where the folder has
// locally-created children. The update application should fail.
-TEST_F(SyncDirectoryUpdateHandlerApplyUpdateTest,
+TEST_F(DirectoryUpdateHandlerApplyUpdateTest,
HierarchyConflictDeleteNonEmptyDirectory) {
// Create a server-deleted folder as a child of root node.
int64 parent_handle =
@@ -603,7 +603,7 @@ TEST_F(SyncDirectoryUpdateHandlerApplyUpdateTest,
// Attempt to apply updates where the updated item's parent is not known to this
// client. The update application attempt should fail.
-TEST_F(SyncDirectoryUpdateHandlerApplyUpdateTest,
+TEST_F(DirectoryUpdateHandlerApplyUpdateTest,
HierarchyConflictUnknownParent) {
// We shouldn't be able to do anything with either of these items.
int64 x_handle = entry_factory()->CreateUnappliedNewItemWithParent(
@@ -634,7 +634,7 @@ TEST_F(SyncDirectoryUpdateHandlerApplyUpdateTest,
// Attempt application of a mix of items. Some update application attempts will
// fail due to hierarchy conflicts. Others should succeed.
-TEST_F(SyncDirectoryUpdateHandlerApplyUpdateTest, ItemsBothKnownAndUnknown) {
+TEST_F(DirectoryUpdateHandlerApplyUpdateTest, ItemsBothKnownAndUnknown) {
// See what happens when there's a mixture of good and bad updates.
std::string root_server_id = syncable::GetNullId().GetServerId();
int64 u1_handle = entry_factory()->CreateUnappliedNewItemWithParent(
@@ -682,7 +682,7 @@ TEST_F(SyncDirectoryUpdateHandlerApplyUpdateTest, ItemsBothKnownAndUnknown) {
}
// Attempt application of password upates where the passphrase is known.
-TEST_F(SyncDirectoryUpdateHandlerApplyUpdateTest, DecryptablePassword) {
+TEST_F(DirectoryUpdateHandlerApplyUpdateTest, DecryptablePassword) {
// Decryptable password updates should be applied.
Cryptographer* cryptographer;
{
@@ -720,7 +720,7 @@ TEST_F(SyncDirectoryUpdateHandlerApplyUpdateTest, DecryptablePassword) {
}
// Attempt application of encrypted items when the passphrase is not known.
-TEST_F(SyncDirectoryUpdateHandlerApplyUpdateTest, UndecryptableData) {
+TEST_F(DirectoryUpdateHandlerApplyUpdateTest, UndecryptableData) {
// Undecryptable updates should not be applied.
sync_pb::EntitySpecifics encrypted_bookmark;
encrypted_bookmark.mutable_encrypted();
@@ -765,7 +765,7 @@ TEST_F(SyncDirectoryUpdateHandlerApplyUpdateTest, UndecryptableData) {
}
// Test a mix of decryptable and undecryptable updates.
-TEST_F(SyncDirectoryUpdateHandlerApplyUpdateTest, SomeUndecryptablePassword) {
+TEST_F(DirectoryUpdateHandlerApplyUpdateTest, SomeUndecryptablePassword) {
Cryptographer* cryptographer;
int64 decryptable_handle = -1;
diff --git a/sync/engine/download_unittest.cc b/sync/engine/download_unittest.cc
index 1a0c5b9..e114022 100644
--- a/sync/engine/download_unittest.cc
+++ b/sync/engine/download_unittest.cc
@@ -7,15 +7,14 @@
#include "base/message_loop/message_loop.h"
#include "base/stl_util.h"
#include "sync/engine/get_updates_delegate.h"
-#include "sync/engine/sync_directory_update_handler.h"
+#include "sync/engine/update_handler.h"
#include "sync/internal_api/public/base/model_type_test_util.h"
#include "sync/protocol/sync.pb.h"
#include "sync/sessions/debug_info_getter.h"
#include "sync/sessions/nudge_tracker.h"
#include "sync/sessions/status_controller.h"
-#include "sync/syncable/directory.h"
#include "sync/test/engine/fake_model_worker.h"
-#include "sync/test/engine/test_directory_setter_upper.h"
+#include "sync/test/engine/mock_update_handler.h"
#include "sync/test/sessions/mock_debug_info_getter.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -31,25 +30,15 @@ class DownloadUpdatesTest : public ::testing::Test {
update_handler_deleter_(&update_handler_map_) {}
virtual void SetUp() {
- dir_maker_.SetUp();
-
- AddUpdateHandler(AUTOFILL, GROUP_DB);
- AddUpdateHandler(BOOKMARKS, GROUP_UI);
- AddUpdateHandler(PREFERENCES, GROUP_UI);
- }
-
- virtual void TearDown() {
- dir_maker_.TearDown();
+ AddUpdateHandler(AUTOFILL);
+ AddUpdateHandler(BOOKMARKS);
+ AddUpdateHandler(PREFERENCES);
}
ModelTypeSet request_types() {
return request_types_;
}
- syncable::Directory* directory() {
- return dir_maker_.directory();
- }
-
scoped_ptr<GetUpdatesProcessor> BuildGetUpdatesProcessor(
const GetUpdatesDelegate& delegate) {
return scoped_ptr<GetUpdatesProcessor>(
@@ -72,20 +61,13 @@ class DownloadUpdatesTest : public ::testing::Test {
const base::TimeTicks kTestStartTime;
private:
- void AddUpdateHandler(ModelType type, ModelSafeGroup group) {
- DCHECK(directory());
-
+ void AddUpdateHandler(ModelType type) {
request_types_.Put(type);
- scoped_refptr<ModelSafeWorker> worker = new FakeModelWorker(group);
- SyncDirectoryUpdateHandler* handler =
- new SyncDirectoryUpdateHandler(directory(), type, worker);
+ UpdateHandler* handler = new MockUpdateHandler(type);
update_handler_map_.insert(std::make_pair(type, handler));
}
- base::MessageLoop loop_; // Needed for directory init.
- TestDirectorySetterUpper dir_maker_;
-
ModelTypeSet request_types_;
UpdateHandlerMap update_handler_map_;
STLValueDeleter<UpdateHandlerMap> update_handler_deleter_;
diff --git a/sync/engine/get_updates_delegate.cc b/sync/engine/get_updates_delegate.cc
index 32cc0f1..d0c7a17 100644
--- a/sync/engine/get_updates_delegate.cc
+++ b/sync/engine/get_updates_delegate.cc
@@ -4,8 +4,8 @@
#include "sync/engine/get_updates_delegate.h"
+#include "sync/engine/directory_update_handler.h"
#include "sync/engine/get_updates_processor.h"
-#include "sync/engine/sync_directory_update_handler.h"
namespace syncer {
diff --git a/sync/engine/get_updates_processor.cc b/sync/engine/get_updates_processor.cc
index 16207b8..449f718 100644
--- a/sync/engine/get_updates_processor.cc
+++ b/sync/engine/get_updates_processor.cc
@@ -7,9 +7,12 @@
#include <map>
#include "sync/engine/get_updates_delegate.h"
-#include "sync/engine/sync_directory_update_handler.h"
+#include "sync/engine/update_handler.h"
#include "sync/protocol/sync.pb.h"
+typedef std::vector<const sync_pb::SyncEntity*> SyncEntityList;
+typedef std::map<syncer::ModelType, SyncEntityList> TypeSyncEntityMap;
+
namespace syncer {
typedef std::map<ModelType, size_t> TypeToIndexMap;
diff --git a/sync/engine/get_updates_processor.h b/sync/engine/get_updates_processor.h
index 4058091..13a9c83 100644
--- a/sync/engine/get_updates_processor.h
+++ b/sync/engine/get_updates_processor.h
@@ -30,10 +30,6 @@ class Directory;
} // namespace syncable
class GetUpdatesDelegate;
-class SyncDirectoryUpdateHandler;
-
-typedef std::vector<const sync_pb::SyncEntity*> SyncEntityList;
-typedef std::map<ModelType, SyncEntityList> TypeSyncEntityMap;
// This class manages the set of per-type syncer objects.
//
diff --git a/sync/engine/sync_directory_commit_contributor.cc b/sync/engine/sync_directory_commit_contributor.cc
deleted file mode 100644
index c87c8ed..0000000
--- a/sync/engine/sync_directory_commit_contributor.cc
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright 2013 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/engine/sync_directory_commit_contributor.h"
-
-#include "sync/engine/sync_directory_commit_contribution.h"
-
-namespace syncer {
-
-SyncDirectoryCommitContributor::SyncDirectoryCommitContributor(
- syncable::Directory* dir,
- ModelType type)
- : dir_(dir),
- type_(type) {}
-
-SyncDirectoryCommitContributor::~SyncDirectoryCommitContributor() {}
-
-SyncDirectoryCommitContribution*
-SyncDirectoryCommitContributor::GetContribution(size_t max_entries) {
- return SyncDirectoryCommitContribution::Build(dir_, type_, max_entries);
-}
-
-} // namespace syncer
diff --git a/sync/engine/sync_directory_commit_contributor.h b/sync/engine/sync_directory_commit_contributor.h
deleted file mode 100644
index 4a90075..0000000
--- a/sync/engine/sync_directory_commit_contributor.h
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright 2013 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_ENGINE_SYNC_DIRECTORY_COMMIT_CONTRIBUTOR_H_
-#define SYNC_ENGINE_SYNC_DIRECTORY_COMMIT_CONTRIBUTOR_H_
-
-#include <map>
-
-#include "sync/internal_api/public/base/model_type.h"
-
-namespace syncer {
-
-class SyncDirectoryCommitContribution;
-
-namespace syncable {
-class Directory;
-}
-
-// This class represents the syncable::Directory as a source of items to commit
-// to the sync server.
-//
-// Each instance of this class represents a particular type within the
-// syncable::Directory. When asked, it will iterate through the directory, grab
-// any items of its type that are ready for commit, and return them in the form
-// of a SyncDirectoryCommitContribution.
-class SyncDirectoryCommitContributor {
- public:
- SyncDirectoryCommitContributor(syncable::Directory* dir, ModelType type);
- ~SyncDirectoryCommitContributor();
-
- SyncDirectoryCommitContribution* GetContribution(size_t max_entries);
-
- private:
- syncable::Directory* dir_;
- ModelType type_;
-};
-
-} // namespace
-
-#endif // SYNC_ENGINE_SYNC_DIRECTORY_COMMIT_CONTRIBUTOR_H_
diff --git a/sync/engine/update_handler.cc b/sync/engine/update_handler.cc
new file mode 100644
index 0000000..308fee9
--- /dev/null
+++ b/sync/engine/update_handler.cc
@@ -0,0 +1,14 @@
+// Copyright 2014 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/engine/update_handler.h"
+
+namespace syncer {
+
+UpdateHandler::UpdateHandler() {}
+
+UpdateHandler::~UpdateHandler() {}
+
+
+} // namespace syncer
diff --git a/sync/engine/update_handler.h b/sync/engine/update_handler.h
new file mode 100644
index 0000000..eb1ee4d
--- /dev/null
+++ b/sync/engine/update_handler.h
@@ -0,0 +1,63 @@
+// Copyright 2014 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_ENGINE_UPDATE_HANDLER_H_
+#define SYNC_ENGINE_UPDATE_HANDLER_H_
+
+#include <vector>
+
+#include "sync/base/sync_export.h"
+
+namespace sync_pb {
+class DataTypeProgressMarker;
+class SyncEntity;
+}
+
+typedef std::vector<const sync_pb::SyncEntity*> SyncEntityList;
+
+namespace syncer {
+
+namespace sessions {
+class StatusController;
+}
+
+class ModelSafeWorker;
+
+// This class represents an entity that can request, receive, and apply updates
+// from the sync server.
+class SYNC_EXPORT_PRIVATE UpdateHandler {
+ public:
+ UpdateHandler();
+ virtual ~UpdateHandler() = 0;
+
+ // Fills the given parameter with the stored progress marker for this type.
+ virtual void GetDownloadProgress(
+ sync_pb::DataTypeProgressMarker* progress_marker) const = 0;
+
+ // Processes the contents of a GetUpdates response message.
+ //
+ // Should be invoked with the progress marker and set of SyncEntities from a
+ // single GetUpdates response message. The progress marker's type must match
+ // this update handler's type, and the set of SyncEntities must include all
+ // entities of this type found in the response message.
+ //
+ // In this context, "applicable_updates" means the set of updates belonging to
+ // this type.
+ virtual void ProcessGetUpdatesResponse(
+ const sync_pb::DataTypeProgressMarker& progress_marker,
+ const SyncEntityList& applicable_updates,
+ sessions::StatusController* status) = 0;
+
+ // Called at the end of a non-configure GetUpdates loop to apply any unapplied
+ // updates.
+ virtual void ApplyUpdates(sessions::StatusController* status) = 0;
+
+ // Called at the end of a configure GetUpdates loop to perform any required
+ // post-initial-download update application.
+ virtual void PassiveApplyUpdates(sessions::StatusController* status) = 0;
+};
+
+} // namespace syncer
+
+#endif // SYNC_ENGINE_UPDATE_HANDLER_H_
diff --git a/sync/sessions/model_type_registry.cc b/sync/sessions/model_type_registry.cc
index cb689cf..7035755 100644
--- a/sync/sessions/model_type_registry.cc
+++ b/sync/sessions/model_type_registry.cc
@@ -4,8 +4,8 @@
#include "sync/sessions/model_type_registry.h"
-#include "sync/engine/sync_directory_commit_contributor.h"
-#include "sync/engine/sync_directory_update_handler.h"
+#include "sync/engine/directory_commit_contributor.h"
+#include "sync/engine/directory_update_handler.h"
namespace syncer {
@@ -39,10 +39,10 @@ void ModelTypeRegistry::SetEnabledDirectoryTypes(
DCHECK(worker_it != workers_map_.end());
scoped_refptr<ModelSafeWorker> worker = worker_it->second;
- SyncDirectoryCommitContributor* committer =
- new SyncDirectoryCommitContributor(directory_, type);
- SyncDirectoryUpdateHandler* updater =
- new SyncDirectoryUpdateHandler(directory_, type, worker);
+ DirectoryCommitContributor* committer =
+ new DirectoryCommitContributor(directory_, type);
+ DirectoryUpdateHandler* updater =
+ new DirectoryUpdateHandler(directory_, type, worker);
bool inserted1 =
update_handler_map_.insert(std::make_pair(type, updater)).second;
diff --git a/sync/sessions/model_type_registry.h b/sync/sessions/model_type_registry.h
index 126d05b..ad34ada 100644
--- a/sync/sessions/model_type_registry.h
+++ b/sync/sessions/model_type_registry.h
@@ -20,12 +20,11 @@ namespace syncable {
class Directory;
} // namespace syncable
-class SyncDirectoryUpdateHandler;
-class SyncDirectoryCommitContributor;
+class UpdateHandler;
+class CommitContributor;
-typedef std::map<ModelType, SyncDirectoryUpdateHandler*> UpdateHandlerMap;
-typedef std::map<ModelType, SyncDirectoryCommitContributor*>
- CommitContributorMap;
+typedef std::map<ModelType, UpdateHandler*> UpdateHandlerMap;
+typedef std::map<ModelType, CommitContributor*> CommitContributorMap;
// Keeps track of the sets of active update handlers and commit contributors.
class SYNC_EXPORT_PRIVATE ModelTypeRegistry {
diff --git a/sync/sync_core.gypi b/sync/sync_core.gypi
index a3dd9aa..5aa74f6 100644
--- a/sync/sync_core.gypi
+++ b/sync/sync_core.gypi
@@ -35,6 +35,10 @@
'engine/backoff_delay_provider.cc',
'engine/backoff_delay_provider.h',
'engine/commit.cc',
+ 'engine/commit_contribution.cc',
+ 'engine/commit_contribution.h',
+ 'engine/commit_contributor.cc',
+ 'engine/commit_contributor.h',
'engine/commit.h',
'engine/commit_processor.cc',
'engine/commit_processor.h',
@@ -44,6 +48,12 @@
'engine/conflict_resolver.h',
'engine/conflict_util.cc',
'engine/conflict_util.h',
+ 'engine/directory_commit_contribution.cc',
+ 'engine/directory_commit_contribution.h',
+ 'engine/directory_commit_contributor.cc',
+ 'engine/directory_commit_contributor.h',
+ 'engine/directory_update_handler.cc',
+ 'engine/directory_update_handler.h',
'engine/download.cc',
'engine/download.h',
'engine/get_commit_ids.cc',
@@ -62,18 +72,8 @@
'engine/process_updates_util.h',
'engine/sync_cycle_event.cc',
'engine/sync_cycle_event.h',
- 'engine/sync_directory_commit_contribution.cc',
- 'engine/sync_directory_commit_contribution.h',
- 'engine/sync_directory_commit_contributor.cc',
- 'engine/sync_directory_commit_contributor.h',
- 'engine/sync_directory_update_handler.cc',
- 'engine/sync_directory_update_handler.h',
'engine/sync_engine_event_listener.cc',
'engine/sync_engine_event_listener.h',
- 'engine/sync_scheduler.cc',
- 'engine/sync_scheduler.h',
- 'engine/sync_scheduler_impl.cc',
- 'engine/sync_scheduler_impl.h',
'engine/syncer.cc',
'engine/syncer.h',
'engine/syncer_proto_util.cc',
@@ -81,12 +81,18 @@
'engine/syncer_types.h',
'engine/syncer_util.cc',
'engine/syncer_util.h',
+ 'engine/sync_scheduler.cc',
+ 'engine/sync_scheduler.h',
+ 'engine/sync_scheduler_impl.cc',
+ 'engine/sync_scheduler_impl.h',
'engine/traffic_logger.cc',
'engine/traffic_logger.h',
'engine/traffic_recorder.cc',
'engine/traffic_recorder.h',
'engine/update_applicator.cc',
'engine/update_applicator.h',
+ 'engine/update_handler.cc',
+ 'engine/update_handler.h',
'js/js_arg_list.cc',
'js/js_arg_list.h',
'js/js_backend.h',
diff --git a/sync/sync_tests.gypi b/sync/sync_tests.gypi
index e026f00..78b4c12 100644
--- a/sync/sync_tests.gypi
+++ b/sync/sync_tests.gypi
@@ -40,6 +40,8 @@
'test/engine/fake_sync_scheduler.h',
'test/engine/mock_connection_manager.cc',
'test/engine/mock_connection_manager.h',
+ 'test/engine/mock_update_handler.cc',
+ 'test/engine/mock_update_handler.h',
'test/engine/test_directory_setter_upper.cc',
'test/engine/test_directory_setter_upper.h',
'test/engine/test_id_factory.h',
@@ -273,8 +275,8 @@
'engine/apply_control_data_updates_unittest.cc',
'engine/backoff_delay_provider_unittest.cc',
'engine/download_unittest.cc',
- 'engine/sync_directory_commit_contribution_unittest.cc',
- 'engine/sync_directory_update_handler_unittest.cc',
+ 'engine/directory_commit_contribution_unittest.cc',
+ 'engine/directory_update_handler_unittest.cc',
'engine/sync_scheduler_unittest.cc',
'engine/syncer_proto_util_unittest.cc',
'engine/syncer_unittest.cc',
diff --git a/sync/test/engine/mock_update_handler.cc b/sync/test/engine/mock_update_handler.cc
new file mode 100644
index 0000000..41c6d29
--- /dev/null
+++ b/sync/test/engine/mock_update_handler.cc
@@ -0,0 +1,37 @@
+// Copyright 2014 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/test/engine/mock_update_handler.h"
+
+#include "sync/internal_api/public/base/model_type.h"
+
+namespace syncer {
+
+MockUpdateHandler::MockUpdateHandler(ModelType type) {
+ progress_marker_.set_data_type_id(GetSpecificsFieldNumberFromModelType(type));
+ const std::string& token_str =
+ std::string("Mock token: ") + std::string(ModelTypeToString(type));
+ progress_marker_.set_token(token_str);
+}
+
+MockUpdateHandler::~MockUpdateHandler() {}
+
+void MockUpdateHandler::GetDownloadProgress(
+ sync_pb::DataTypeProgressMarker* progress_marker) const {
+ progress_marker->CopyFrom(progress_marker_);
+}
+
+void MockUpdateHandler::ProcessGetUpdatesResponse(
+ const sync_pb::DataTypeProgressMarker& progress_marker,
+ const SyncEntityList& applicable_updates,
+ sessions::StatusController* status) {
+ progress_marker_.CopyFrom(progress_marker);
+}
+
+void MockUpdateHandler::ApplyUpdates(sessions::StatusController* status) {}
+
+void MockUpdateHandler::PassiveApplyUpdates(
+ sessions::StatusController* status) {}
+
+} // namespace syncer
diff --git a/sync/test/engine/mock_update_handler.h b/sync/test/engine/mock_update_handler.h
new file mode 100644
index 0000000..7ee0c37
--- /dev/null
+++ b/sync/test/engine/mock_update_handler.h
@@ -0,0 +1,36 @@
+// Copyright 2014 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_TEST_ENGINE_MOCK_UPDATE_HANDLER_H_
+#define SYNC_TEST_ENGINE_MOCK_UPDATE_HANDLER_H_
+
+#include "base/compiler_specific.h"
+#include "sync/engine/update_handler.h"
+#include "sync/internal_api/public/base/model_type.h"
+#include "sync/protocol/sync.pb.h"
+
+namespace syncer {
+
+class MockUpdateHandler : public UpdateHandler {
+ public:
+ explicit MockUpdateHandler(ModelType type);
+ virtual ~MockUpdateHandler();
+
+ // UpdateHandler implementation.
+ virtual void GetDownloadProgress(
+ sync_pb::DataTypeProgressMarker* progress_marker) const OVERRIDE;
+ virtual void ProcessGetUpdatesResponse(
+ const sync_pb::DataTypeProgressMarker& progress_marker,
+ const SyncEntityList& applicable_updates,
+ sessions::StatusController* status) OVERRIDE;
+ virtual void ApplyUpdates(sessions::StatusController* status) OVERRIDE;
+ virtual void PassiveApplyUpdates(sessions::StatusController* status) OVERRIDE;
+
+ private:
+ sync_pb::DataTypeProgressMarker progress_marker_;
+};
+
+} // namespace syncer
+
+#endif // SYNC_TEST_ENGINE_MOCK_UPDATE_HANDLER_H_