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 #include "sync/engine/non_blocking_type_commit_contribution.h" | 5 #include "components/sync/engine_impl/non_blocking_type_commit_contribution.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
11 | 11 |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "sync/engine/model_type_worker.h" | 13 #include "components/sync/core/non_blocking_sync_common.h" |
14 #include "sync/internal_api/public/non_blocking_sync_common.h" | 14 #include "components/sync/engine_impl/model_type_worker.h" |
15 #include "sync/protocol/proto_value_conversions.h" | 15 #include "components/sync/protocol/proto_value_conversions.h" |
16 | 16 |
17 namespace syncer_v2 { | 17 namespace syncer_v2 { |
18 | 18 |
19 NonBlockingTypeCommitContribution::NonBlockingTypeCommitContribution( | 19 NonBlockingTypeCommitContribution::NonBlockingTypeCommitContribution( |
20 const sync_pb::DataTypeContext& context, | 20 const sync_pb::DataTypeContext& context, |
21 const google::protobuf::RepeatedPtrField<sync_pb::SyncEntity>& entities, | 21 const google::protobuf::RepeatedPtrField<sync_pb::SyncEntity>& entities, |
22 ModelTypeWorker* worker) | 22 ModelTypeWorker* worker) |
23 : worker_(worker), | 23 : worker_(worker), |
24 context_(context), | 24 context_(context), |
25 entities_(entities), | 25 entities_(entities), |
26 cleaned_up_(false) {} | 26 cleaned_up_(false) {} |
27 | 27 |
28 NonBlockingTypeCommitContribution::~NonBlockingTypeCommitContribution() { | 28 NonBlockingTypeCommitContribution::~NonBlockingTypeCommitContribution() { |
29 DCHECK(cleaned_up_); | 29 DCHECK(cleaned_up_); |
30 } | 30 } |
31 | 31 |
32 void NonBlockingTypeCommitContribution::AddToCommitMessage( | 32 void NonBlockingTypeCommitContribution::AddToCommitMessage( |
33 sync_pb::ClientToServerMessage* msg) { | 33 sync_pb::ClientToServerMessage* msg) { |
34 sync_pb::CommitMessage* commit_message = msg->mutable_commit(); | 34 sync_pb::CommitMessage* commit_message = msg->mutable_commit(); |
35 entries_start_index_ = commit_message->entries_size(); | 35 entries_start_index_ = commit_message->entries_size(); |
36 | 36 |
37 std::copy(entities_.begin(), | 37 std::copy(entities_.begin(), entities_.end(), |
38 entities_.end(), | |
39 RepeatedPtrFieldBackInserter(commit_message->mutable_entries())); | 38 RepeatedPtrFieldBackInserter(commit_message->mutable_entries())); |
40 if (!context_.context().empty()) | 39 if (!context_.context().empty()) |
41 commit_message->add_client_contexts()->CopyFrom(context_); | 40 commit_message->add_client_contexts()->CopyFrom(context_); |
42 } | 41 } |
43 | 42 |
44 syncer::SyncerError NonBlockingTypeCommitContribution::ProcessCommitResponse( | 43 syncer::SyncerError NonBlockingTypeCommitContribution::ProcessCommitResponse( |
45 const sync_pb::ClientToServerResponse& response, | 44 const sync_pb::ClientToServerResponse& response, |
46 syncer::sessions::StatusController* status) { | 45 syncer::sessions::StatusController* status) { |
47 const sync_pb::CommitResponse& commit_response = response.commit(); | 46 const sync_pb::CommitResponse& commit_response = response.commit(); |
48 | 47 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 // We could inform our parent NonBlockingCommitContributor that a commit is | 111 // We could inform our parent NonBlockingCommitContributor that a commit is |
113 // no longer in progress. The current implementation doesn't really care | 112 // no longer in progress. The current implementation doesn't really care |
114 // either way, so we don't bother sending the signal. | 113 // either way, so we don't bother sending the signal. |
115 } | 114 } |
116 | 115 |
117 size_t NonBlockingTypeCommitContribution::GetNumEntries() const { | 116 size_t NonBlockingTypeCommitContribution::GetNumEntries() const { |
118 return entities_.size(); | 117 return entities_.size(); |
119 } | 118 } |
120 | 119 |
121 } // namespace syncer_v2 | 120 } // namespace syncer_v2 |
OLD | NEW |