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

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

Issue 2781863004: [Sync] Implement EstimateMemoryUsage for SharedModelTypeProcessor and ModelTypeWorker (Closed)
Patch Set: Address comments Created 3 years, 8 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 "base/memory/ptr_util.h"
11 #include "base/trace_event/memory_usage_estimator.h"
11 #include "components/sync/base/model_type.h" 12 #include "components/sync/base/model_type.h"
12 #include "components/sync/base/time.h" 13 #include "components/sync/base/time.h"
13 #include "components/sync/syncable/syncable_util.h" 14 #include "components/sync/syncable/syncable_util.h"
14 15
15 namespace syncer { 16 namespace syncer {
16 17
17 WorkerEntityTracker::WorkerEntityTracker(const std::string& client_tag_hash) 18 WorkerEntityTracker::WorkerEntityTracker(const std::string& client_tag_hash)
18 : client_tag_hash_(client_tag_hash) { 19 : client_tag_hash_(client_tag_hash) {
19 DCHECK(!client_tag_hash_.empty()); 20 DCHECK(!client_tag_hash_.empty());
20 } 21 }
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 } 171 }
171 172
172 UpdateResponseData WorkerEntityTracker::GetEncryptedUpdate() const { 173 UpdateResponseData WorkerEntityTracker::GetEncryptedUpdate() const {
173 return *encrypted_update_; 174 return *encrypted_update_;
174 } 175 }
175 176
176 void WorkerEntityTracker::ClearEncryptedUpdate() { 177 void WorkerEntityTracker::ClearEncryptedUpdate() {
177 encrypted_update_.reset(); 178 encrypted_update_.reset();
178 } 179 }
179 180
181 size_t WorkerEntityTracker::EstimateMemoryUsage() const {
182 using base::trace_event::EstimateMemoryUsage;
183 size_t memory_usage = 0;
184 memory_usage += EstimateMemoryUsage(client_tag_hash_);
185 memory_usage += EstimateMemoryUsage(id_);
186 memory_usage += EstimateMemoryUsage(pending_commit_);
187 memory_usage += EstimateMemoryUsage(pending_commit_specifics_hash_);
188 memory_usage += EstimateMemoryUsage(encrypted_update_);
189 return memory_usage;
190 }
191
180 bool WorkerEntityTracker::IsInConflict() const { 192 bool WorkerEntityTracker::IsInConflict() const {
181 if (!HasPendingCommit()) 193 if (!HasPendingCommit())
182 return false; 194 return false;
183 195
184 if (HasEncryptedUpdate()) 196 if (HasEncryptedUpdate())
185 return true; 197 return true;
186 198
187 if (highest_gu_response_version_ <= highest_commit_response_version_) { 199 if (highest_gu_response_version_ <= highest_commit_response_version_) {
188 // The most recent server state was created in a commit made by this 200 // The most recent server state was created in a commit made by this
189 // client. We're fully up to date, and therefore not in conflict. 201 // client. We're fully up to date, and therefore not in conflict.
(...skipping 13 matching lines...) Expand all
203 bool WorkerEntityTracker::IsServerKnown() const { 215 bool WorkerEntityTracker::IsServerKnown() const {
204 return base_version_ != kUncommittedVersion; 216 return base_version_ != kUncommittedVersion;
205 } 217 }
206 218
207 void WorkerEntityTracker::ClearPendingCommit() { 219 void WorkerEntityTracker::ClearPendingCommit() {
208 pending_commit_.reset(); 220 pending_commit_.reset();
209 pending_commit_specifics_hash_.clear(); 221 pending_commit_specifics_hash_.clear();
210 } 222 }
211 223
212 } // namespace syncer 224 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/engine_impl/worker_entity_tracker.h ('k') | components/sync/model/entity_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698