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

Side by Side Diff: chrome/browser/sync/engine/post_commit_message_command.cc

Issue 9695016: Handle errors in posting sync commit messages (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/sync/engine/post_commit_message_command.h" 5 #include "chrome/browser/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 "chrome/browser/sync/engine/syncer_proto_util.h" 10 #include "chrome/browser/sync/engine/syncer_proto_util.h"
11 #include "chrome/browser/sync/engine/syncproto.h" 11 #include "chrome/browser/sync/engine/syncproto.h"
12 #include "chrome/browser/sync/sessions/sync_session.h" 12 #include "chrome/browser/sync/sessions/sync_session.h"
13 13
14 using std::vector; 14 using std::vector;
15 15
16 namespace browser_sync { 16 namespace browser_sync {
17 17
18 PostCommitMessageCommand::PostCommitMessageCommand() {} 18 PostCommitMessageCommand::PostCommitMessageCommand() {}
19 PostCommitMessageCommand::~PostCommitMessageCommand() {} 19 PostCommitMessageCommand::~PostCommitMessageCommand() {}
20 20
21 SyncerError PostCommitMessageCommand::ExecuteImpl( 21 SyncerError PostCommitMessageCommand::ExecuteImpl(
22 sessions::SyncSession* session) { 22 sessions::SyncSession* session) {
23 if (session->status_controller().commit_ids().empty()) 23 if (session->status_controller().commit_ids().empty())
24 return SYNCER_OK; // Nothing to commit. 24 return SYNCER_OK; // Nothing to commit.
25 ClientToServerResponse response; 25 ClientToServerResponse response;
26 syncable::Directory* dir = session->context()->directory(); 26 syncable::Directory* dir = session->context()->directory();
27 sessions::StatusController* status = session->mutable_status_controller(); 27 sessions::StatusController* status = session->mutable_status_controller();
28 if (!SyncerProtoUtil::PostClientToServerMessage(status->commit_message(), 28 SyncerError result = SyncerProtoUtil::PostClientToServerMessage(
29 &response, session)) { 29 status->commit_message(), &response, session);
30 if (result != SYNCER_OK) {
30 // None of our changes got through. Clear the SYNCING bit which was 31 // None of our changes got through. Clear the SYNCING bit which was
31 // set to true during BuildCommitCommand, and which may still be true. 32 // set to true during BuildCommitCommand, and which may still be true.
32 // Not to be confused with IS_UNSYNCED, this bit is used to detect local 33 // Not to be confused with IS_UNSYNCED, this bit is used to detect local
33 // changes to items that happen during the server Commit operation. 34 // changes to items that happen during the server Commit operation.
34 syncable::WriteTransaction trans(FROM_HERE, syncable::SYNCER, dir); 35 syncable::WriteTransaction trans(FROM_HERE, syncable::SYNCER, dir);
35 const vector<syncable::Id>& commit_ids = status->commit_ids(); 36 const vector<syncable::Id>& commit_ids = status->commit_ids();
36 for (size_t i = 0; i < commit_ids.size(); i++) { 37 for (size_t i = 0; i < commit_ids.size(); i++) {
37 syncable::MutableEntry entry(&trans, syncable::GET_BY_ID, commit_ids[i]); 38 syncable::MutableEntry entry(&trans, syncable::GET_BY_ID, commit_ids[i]);
38 entry.Put(syncable::SYNCING, false); 39 entry.Put(syncable::SYNCING, false);
39 } 40 }
40 return SYNCER_OK; // TODO(rlarocque): Return an error here. 41 return result;
41 } else {
42 status->set_items_committed();
43 } 42 }
44 43
44 status->set_items_committed();
45 status->mutable_commit_response()->CopyFrom(response); 45 status->mutable_commit_response()->CopyFrom(response);
46 return SYNCER_OK; 46 return SYNCER_OK;
47 } 47 }
48 48
49 } // namespace browser_sync 49 } // namespace browser_sync
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698