blob: 8f51f200cfa8d6be3ebc88310b9de434e9fa0813 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
// 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/engine/post_commit_message_command.h"
#include <vector>
#include "base/location.h"
#include "sync/engine/syncer_proto_util.h"
#include "sync/engine/syncproto.h"
#include "sync/sessions/sync_session.h"
using std::vector;
namespace browser_sync {
PostCommitMessageCommand::PostCommitMessageCommand() {}
PostCommitMessageCommand::~PostCommitMessageCommand() {}
SyncerError PostCommitMessageCommand::ExecuteImpl(
sessions::SyncSession* session) {
if (session->status_controller().commit_ids().empty())
return SYNCER_OK; // Nothing to commit.
ClientToServerResponse response;
syncable::Directory* dir = session->context()->directory();
sessions::StatusController* status = session->mutable_status_controller();
SyncerError result = SyncerProtoUtil::PostClientToServerMessage(
status->commit_message(), &response, session);
if (result != SYNCER_OK) {
// None of our changes got through. Clear the SYNCING bit which was
// set to true during BuildCommitCommand, and which may still be true.
// Not to be confused with IS_UNSYNCED, this bit is used to detect local
// changes to items that happen during the server Commit operation.
syncable::WriteTransaction trans(FROM_HERE, syncable::SYNCER, dir);
const vector<syncable::Id>& commit_ids = status->commit_ids();
for (size_t i = 0; i < commit_ids.size(); i++) {
syncable::MutableEntry entry(&trans, syncable::GET_BY_ID, commit_ids[i]);
entry.Put(syncable::SYNCING, false);
}
return result;
}
status->set_items_committed();
status->mutable_commit_response()->CopyFrom(response);
return SYNCER_OK;
}
} // namespace browser_sync
|