Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(331)

Unified Diff: sync/engine/build_commit_command.cc

Issue 10038041: sync: Loop committing items without downloading updates (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sync/engine/build_commit_command.cc
diff --git a/sync/engine/build_commit_command.cc b/sync/engine/build_commit_command.cc
index 86d1d8b3096ecbf679a25ad7616def5f155bf35f..8a4243b64ff26c7aa90b927f7029146a3c0b8380 100644
--- a/sync/engine/build_commit_command.cc
+++ b/sync/engine/build_commit_command.cc
@@ -12,9 +12,10 @@
#include "base/string_util.h"
#include "sync/engine/syncer_proto_util.h"
#include "sync/protocol/bookmark_specifics.pb.h"
+#include "sync/sessions/ordered_commit_set.h"
#include "sync/sessions/sync_session.h"
-#include "sync/syncable/syncable.h"
#include "sync/syncable/syncable_changes_version.h"
+#include "sync/syncable/syncable.h"
#include "sync/util/time.h"
using std::set;
@@ -49,7 +50,12 @@ int64 BuildCommitCommand::GetGap() {
return 1LL << 20;
}
-BuildCommitCommand::BuildCommitCommand() {}
+BuildCommitCommand::BuildCommitCommand(
+ const sessions::OrderedCommitSet& batch_commit_set,
+ ClientToServerMessage* commit_message)
+ : batch_commit_set_(batch_commit_set), commit_message_(commit_message) {
+}
+
BuildCommitCommand::~BuildCommitCommand() {}
void BuildCommitCommand::AddExtensionsActivityToMessage(
@@ -57,7 +63,7 @@ void BuildCommitCommand::AddExtensionsActivityToMessage(
// We only send ExtensionsActivity to the server if bookmarks are being
// committed.
ExtensionsActivityMonitor* monitor = session->context()->extensions_monitor();
- if (!session->status_controller().HasBookmarkCommitActivity()) {
+ if (!batch_commit_set_.HasBookmarkCommitId()) {
// Return the records to the activity monitor.
monitor->PutRecords(session->extensions_activity());
session->mutable_extensions_activity()->clear();
@@ -86,16 +92,15 @@ void SetEntrySpecifics(MutableEntry* meta_entry, SyncEntity* sync_entry) {
} // namespace
SyncerError BuildCommitCommand::ExecuteImpl(SyncSession* session) {
- ClientToServerMessage message;
- message.set_share(session->context()->account_name());
- message.set_message_contents(ClientToServerMessage::COMMIT);
+ commit_message_->set_share(session->context()->account_name());
+ commit_message_->set_message_contents(ClientToServerMessage::COMMIT);
- CommitMessage* commit_message = message.mutable_commit();
+ CommitMessage* commit_message = commit_message_->mutable_commit();
commit_message->set_cache_guid(
session->write_transaction()->directory()->cache_guid());
AddExtensionsActivityToMessage(session, commit_message);
SyncerProtoUtil::AddRequestBirthday(
- session->write_transaction()->directory(), &message);
+ session->write_transaction()->directory(), commit_message_);
// Cache previously computed position values. Because |commit_ids|
// is already in sibling order, we should always hit this map after
@@ -105,9 +110,8 @@ SyncerError BuildCommitCommand::ExecuteImpl(SyncSession* session) {
// whose ID is the map's key.
std::map<Id, std::pair<int64, int64> > position_map;
- const vector<Id>& commit_ids = session->status_controller().commit_ids();
- for (size_t i = 0; i < commit_ids.size(); i++) {
- Id id = commit_ids[i];
+ for (size_t i = 0; i < batch_commit_set_.Size(); i++) {
+ Id id = batch_commit_set_.GetCommitIdAt(i);
SyncEntity* sync_entry =
static_cast<SyncEntity*>(commit_message->add_entries());
sync_entry->set_id(id);
@@ -208,8 +212,6 @@ SyncerError BuildCommitCommand::ExecuteImpl(SyncSession* session) {
SetEntrySpecifics(&meta_entry, sync_entry);
}
}
- session->mutable_status_controller()->
- mutable_commit_message()->CopyFrom(message);
return SYNCER_OK;
}

Powered by Google App Engine
This is Rietveld 408576698