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.
5 #ifndef SYNC_ENGINE_COMMIT_CONTRIBUTION_H_
6 #define SYNC_ENGINE_COMMIT_CONTRIBUTION_H_
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"
16 class StatusController
;
17 } // namespace sessions
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.
22 // This class handles the bookkeeping related to the commit of these items.
23 class SYNC_EXPORT_PRIVATE CommitContribution
{
26 virtual ~CommitContribution() = 0;
28 // Serialize this contribution's entries to the given commit request |msg|.
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;
35 // Updates this contribution's contents in accordance with the provided
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;
44 // Cleans up any temproary state associated with the commit. Must be called
45 // before destruction.
46 virtual void CleanUp() = 0;
48 // Returns the number of entries included in this contribution.
49 virtual size_t GetNumEntries() const = 0;
54 #endif // SYNC_ENGINE_COMMIT_CONTRIBUTION_H_