1// Copyright 2014 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_COMMIT_CONTRIBUTION_H_
6#define SYNC_ENGINE_COMMIT_CONTRIBUTION_H_
7
8#include "sync/base/sync_export.h"
9#include "sync/internal_api/public/util/syncer_error.h"
10#include "sync/protocol/sync.pb.h"
11#include "sync/sessions/status_controller.h"
12
13namespace syncer {
14
15namespace sessions {
16class StatusController;
17}  // namespace sessions
18
19// This class represents a set of items belonging to a particular data type that
20// have been selected from a CommitContributor and prepared for commit.
21//
22// This class handles the bookkeeping related to the commit of these items.
23class SYNC_EXPORT_PRIVATE CommitContribution {
24 public:
25  CommitContribution();
26  virtual ~CommitContribution() = 0;
27
28  // Serialize this contribution's entries to the given commit request |msg|.
29  //
30  // This function is not const.  It may update some state in this contribution
31  // that will be used when processing the associated commit response.  This
32  // function should not be called more than once.
33  virtual void AddToCommitMessage(sync_pb::ClientToServerMessage* msg) = 0;
34
35  // Updates this contribution's contents in accordance with the provided
36  // |response|.
37  //
38  // It is not valid to call this function unless AddToCommitMessage() was
39  // called earlier.  This function should not be called more than once.
40  virtual SyncerError ProcessCommitResponse(
41      const sync_pb::ClientToServerResponse& response,
42      sessions::StatusController* status) = 0;
43
44  // Cleans up any temproary state associated with the commit.  Must be called
45  // before destruction.
46  virtual void CleanUp() = 0;
47
48  // Returns the number of entries included in this contribution.
49  virtual size_t GetNumEntries() const = 0;
50};
51
52}  // namespace syncer
53
54#endif  // SYNC_ENGINE_COMMIT_CONTRIBUTION_H_
55