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