OLD | NEW |
| (Empty) |
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_NON_BLOCKING_TYPE_COMMIT_CONTRIBUTION_H_ | |
6 #define SYNC_ENGINE_NON_BLOCKING_TYPE_COMMIT_CONTRIBUTION_H_ | |
7 | |
8 #include <stddef.h> | |
9 #include <stdint.h> | |
10 | |
11 #include <vector> | |
12 | |
13 #include "base/macros.h" | |
14 #include "sync/engine/commit_contribution.h" | |
15 #include "sync/protocol/sync.pb.h" | |
16 | |
17 namespace syncer_v2 { | |
18 | |
19 class ModelTypeWorker; | |
20 | |
21 // A non-blocking sync type's contribution to an outgoing commit message. | |
22 // | |
23 // Helps build a commit message and process its response. It collaborates | |
24 // closely with the ModelTypeWorker. | |
25 class NonBlockingTypeCommitContribution : public syncer::CommitContribution { | |
26 public: | |
27 NonBlockingTypeCommitContribution( | |
28 const sync_pb::DataTypeContext& context, | |
29 const google::protobuf::RepeatedPtrField<sync_pb::SyncEntity>& entities, | |
30 ModelTypeWorker* worker); | |
31 ~NonBlockingTypeCommitContribution() override; | |
32 | |
33 // Implementation of CommitContribution | |
34 void AddToCommitMessage(sync_pb::ClientToServerMessage* msg) override; | |
35 syncer::SyncerError ProcessCommitResponse( | |
36 const sync_pb::ClientToServerResponse& response, | |
37 syncer::sessions::StatusController* status) override; | |
38 void CleanUp() override; | |
39 size_t GetNumEntries() const override; | |
40 | |
41 private: | |
42 // A non-owned pointer back to the object that created this contribution. | |
43 ModelTypeWorker* const worker_; | |
44 | |
45 // The type-global context information. | |
46 const sync_pb::DataTypeContext context_; | |
47 | |
48 // The set of entities to be committed, serialized as SyncEntities. | |
49 const google::protobuf::RepeatedPtrField<sync_pb::SyncEntity> entities_; | |
50 | |
51 // The index in the commit message where this contribution's entities are | |
52 // added. Used to correlate per-item requests with per-item responses. | |
53 size_t entries_start_index_; | |
54 | |
55 // A flag used to ensure this object's contract is respected. Helps to check | |
56 // that CleanUp() is called before the object is destructed. | |
57 bool cleaned_up_; | |
58 | |
59 DISALLOW_COPY_AND_ASSIGN(NonBlockingTypeCommitContribution); | |
60 }; | |
61 | |
62 } // namespace syncer_v2 | |
63 | |
64 #endif // SYNC_ENGINE_NON_BLOCKING_TYPE_COMMIT_CONTRIBUTION_H_ | |
OLD | NEW |