Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: components/sync/engine_impl/worker_entity_tracker.cc

Issue 2422253002: [Sync] Rewriting ".reset(new" pattern to use "= base::MakeUnique" instead. (Closed)
Patch Set: Fixing compile. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "components/sync/engine_impl/worker_entity_tracker.h" 5 #include "components/sync/engine_impl/worker_entity_tracker.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h"
10 #include "components/sync/base/model_type.h" 11 #include "components/sync/base/model_type.h"
11 #include "components/sync/base/time.h" 12 #include "components/sync/base/time.h"
12 #include "components/sync/syncable/syncable_util.h" 13 #include "components/sync/syncable/syncable_util.h"
13 14
14 namespace syncer { 15 namespace syncer {
15 16
16 WorkerEntityTracker::WorkerEntityTracker(const std::string& client_tag_hash) 17 WorkerEntityTracker::WorkerEntityTracker(const std::string& client_tag_hash)
17 : client_tag_hash_(client_tag_hash) { 18 : client_tag_hash_(client_tag_hash) {
18 DCHECK(!client_tag_hash_.empty()); 19 DCHECK(!client_tag_hash_.empty());
19 } 20 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 } 76 }
76 77
77 // We intentionally don't update the id_ here. Good ID values come from the 78 // We intentionally don't update the id_ here. Good ID values come from the
78 // server and always pass through the sync thread first. There's no way the 79 // server and always pass through the sync thread first. There's no way the
79 // model thread could have a better ID value than we do. 80 // model thread could have a better ID value than we do.
80 81
81 // This entity is identified by its client tag. That value can never change. 82 // This entity is identified by its client tag. That value can never change.
82 DCHECK_EQ(client_tag_hash_, data.entity->client_tag_hash); 83 DCHECK_EQ(client_tag_hash_, data.entity->client_tag_hash);
83 // TODO(stanisc): consider simply copying CommitRequestData instead of 84 // TODO(stanisc): consider simply copying CommitRequestData instead of
84 // allocating one dynamically. 85 // allocating one dynamically.
85 pending_commit_.reset(new CommitRequestData(data)); 86 pending_commit_ = base::MakeUnique<CommitRequestData>(data);
86 87
87 // Do our counter values indicate a conflict? If so, don't commit. 88 // Do our counter values indicate a conflict? If so, don't commit.
88 // 89 //
89 // There's no need to inform the model thread of the conflict. The 90 // There's no need to inform the model thread of the conflict. The
90 // conflicting update has already been posted to its task runner; it will 91 // conflicting update has already been posted to its task runner; it will
91 // figure it out as soon as it runs that task. 92 // figure it out as soon as it runs that task.
92 // 93 //
93 // Note that this check must be after pending_commit_ is set. 94 // Note that this check must be after pending_commit_ is set.
94 if (IsInConflict()) { 95 if (IsInConflict()) {
95 ClearPendingCommit(); 96 ClearPendingCommit();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 ClearPendingCommit(); 144 ClearPendingCommit();
144 } 145 }
145 } 146 }
146 147
147 bool WorkerEntityTracker::ReceiveEncryptedUpdate( 148 bool WorkerEntityTracker::ReceiveEncryptedUpdate(
148 const UpdateResponseData& data) { 149 const UpdateResponseData& data) {
149 if (data.response_version < highest_gu_response_version_) 150 if (data.response_version < highest_gu_response_version_)
150 return false; 151 return false;
151 152
152 highest_gu_response_version_ = data.response_version; 153 highest_gu_response_version_ = data.response_version;
153 encrypted_update_.reset(new UpdateResponseData(data)); 154 encrypted_update_ = base::MakeUnique<UpdateResponseData>(data);
154 ClearPendingCommit(); 155 ClearPendingCommit();
155 return true; 156 return true;
156 } 157 }
157 158
158 bool WorkerEntityTracker::HasEncryptedUpdate() const { 159 bool WorkerEntityTracker::HasEncryptedUpdate() const {
159 return !!encrypted_update_; 160 return !!encrypted_update_;
160 } 161 }
161 162
162 UpdateResponseData WorkerEntityTracker::GetEncryptedUpdate() const { 163 UpdateResponseData WorkerEntityTracker::GetEncryptedUpdate() const {
163 return *encrypted_update_; 164 return *encrypted_update_;
(...skipping 29 matching lines...) Expand all
193 bool WorkerEntityTracker::IsServerKnown() const { 194 bool WorkerEntityTracker::IsServerKnown() const {
194 return base_version_ != kUncommittedVersion; 195 return base_version_ != kUncommittedVersion;
195 } 196 }
196 197
197 void WorkerEntityTracker::ClearPendingCommit() { 198 void WorkerEntityTracker::ClearPendingCommit() {
198 pending_commit_.reset(); 199 pending_commit_.reset();
199 pending_commit_specifics_hash_.clear(); 200 pending_commit_specifics_hash_.clear();
200 } 201 }
201 202
202 } // namespace syncer 203 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698