1// Copyright 2013 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef SYNC_ENGINE_BUILD_COMMIT_UTIL_H_
6#define SYNC_ENGINE_BUILD_COMMIT_UTIL_H_
7
8#include "sync/base/sync_export.h"
9#include "sync/internal_api/public/base/model_type.h"
10#include "sync/protocol/sync.pb.h"
11#include "sync/util/extensions_activity.h"
12
13namespace sync_pb {
14class CommitMessage;
15class SyncEntity;
16}
17
18namespace syncer {
19
20namespace syncable {
21class BaseTransaction;
22class Entry;
23class Id;
24class BaseWriteTransaction;
25}
26
27namespace commit_util {
28
29// Adds bookmark extensions activity report to |message|.
30SYNC_EXPORT_PRIVATE void AddExtensionsActivityToMessage(
31    ExtensionsActivity* activity,
32    ExtensionsActivity::Records* extensions_activity_buffer,
33    sync_pb::CommitMessage* message);
34
35// Fills the config_params field of |message|.
36SYNC_EXPORT_PRIVATE void AddClientConfigParamsToMessage(
37    ModelTypeSet enabled_types,
38    sync_pb::CommitMessage* message);
39
40// Takes a snapshot of |meta_entry| and puts it into a protobuf suitable for use
41// in a commit request message.
42SYNC_EXPORT_PRIVATE void BuildCommitItem(
43    const syncable::Entry& meta_entry,
44    sync_pb::SyncEntity* sync_entry);
45
46// Process a single commit response.  Updates the entry's SERVER fields using
47// |pb_commit_response| and |pb_committed_entry|.
48//
49// The |deleted_folders| parameter is a set of IDs that represent deleted
50// folders.  This function will add its entry's ID to this set if it finds
51// itself processing a folder deletion.
52SYNC_EXPORT_PRIVATE
53sync_pb::CommitResponse::ResponseType ProcessSingleCommitResponse(
54    syncable::BaseWriteTransaction* trans,
55    const sync_pb::CommitResponse_EntryResponse& server_entry,
56    const sync_pb::SyncEntity& commit_request_entry,
57    int64 metahandle,
58    std::set<syncable::Id>* deleted_folders);
59
60}  // namespace commit_util
61
62}  // namespace syncer
63
64#endif  // SYNC_ENGINE_BUILD_COMMIT_UTIL_H_
65