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

Side by Side Diff: sync/engine/post_commit_message_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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "sync/engine/post_commit_message_command.h" 5 #include "sync/engine/post_commit_message_command.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "sync/engine/syncer_proto_util.h" 10 #include "sync/engine/syncer_proto_util.h"
11 #include "sync/engine/syncproto.h"
12 #include "sync/sessions/sync_session.h" 11 #include "sync/sessions/sync_session.h"
13 12
14 using std::vector; 13 using std::vector;
15 14
16 namespace browser_sync { 15 namespace browser_sync {
17 16
18 PostCommitMessageCommand::PostCommitMessageCommand() {} 17 PostCommitMessageCommand::PostCommitMessageCommand(
18 const ClientToServerMessage& message,
19 ClientToServerResponse* response)
20 : commit_message_(message), commit_response_(response) {
21 }
22
19 PostCommitMessageCommand::~PostCommitMessageCommand() {} 23 PostCommitMessageCommand::~PostCommitMessageCommand() {}
20 24
21 SyncerError PostCommitMessageCommand::ExecuteImpl( 25 SyncerError PostCommitMessageCommand::ExecuteImpl(
22 sessions::SyncSession* session) { 26 sessions::SyncSession* session) {
23 if (session->status_controller().commit_ids().empty()) 27 return SyncerProtoUtil::PostClientToServerMessage(
rlarocque 2012/04/13 02:02:22 This if statement is no longer necessary, we break
rlarocque 2012/04/13 02:02:22 Seeing how little is left of this class, I intend
24 return SYNCER_OK; // Nothing to commit. 28 commit_message_, commit_response_, session);
25 ClientToServerResponse response;
26 syncable::Directory* dir = session->context()->directory();
27 sessions::StatusController* status = session->mutable_status_controller();
28 SyncerError result = SyncerProtoUtil::PostClientToServerMessage(
29 status->commit_message(), &response, session);
30 if (result != SYNCER_OK) {
rlarocque 2012/04/13 02:02:22 I believe this is the wrong place to put this code
31 // None of our changes got through. Clear the SYNCING bit which was
32 // set to true during BuildCommitCommand, and which may still be true.
33 // Not to be confused with IS_UNSYNCED, this bit is used to detect local
34 // changes to items that happen during the server Commit operation.
35 syncable::WriteTransaction trans(FROM_HERE, syncable::SYNCER, dir);
36 const vector<syncable::Id>& commit_ids = status->commit_ids();
37 for (size_t i = 0; i < commit_ids.size(); i++) {
38 syncable::MutableEntry entry(&trans, syncable::GET_BY_ID, commit_ids[i]);
39 entry.Put(syncable::SYNCING, false);
40 }
41 return result;
42 }
43
44 status->set_items_committed();
45 status->mutable_commit_response()->CopyFrom(response);
46 return SYNCER_OK;
47 } 29 }
48 30
49 } // namespace browser_sync 31 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698