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

Side by Side Diff: sync/syncable/entry_kernel.h

Issue 2084243004: [WIP][tracing] Add memory dump provider for sync Directory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes. Created 4 years, 5 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 SYNC_SYNCABLE_ENTRY_KERNEL_H_ 5 #ifndef SYNC_SYNCABLE_ENTRY_KERNEL_H_
6 #define SYNC_SYNCABLE_ENTRY_KERNEL_H_ 6 #define SYNC_SYNCABLE_ENTRY_KERNEL_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 224
225 // Set the dirty bit, and optionally add this entry's metahandle to 225 // Set the dirty bit, and optionally add this entry's metahandle to
226 // a provided index on dirty bits in |dirty_index|. Parameter may be null, 226 // a provided index on dirty bits in |dirty_index|. Parameter may be null,
227 // and will result only in setting the dirty bit of this entry. 227 // and will result only in setting the dirty bit of this entry.
228 inline void mark_dirty(syncable::MetahandleSet* dirty_index) { 228 inline void mark_dirty(syncable::MetahandleSet* dirty_index) {
229 if (!dirty_ && dirty_index) { 229 if (!dirty_ && dirty_index) {
230 DCHECK_NE(0, ref(META_HANDLE)); 230 DCHECK_NE(0, ref(META_HANDLE));
231 dirty_index->insert(ref(META_HANDLE)); 231 dirty_index->insert(ref(META_HANDLE));
232 } 232 }
233 dirty_ = true; 233 dirty_ = true;
234 cached_size_ = 0;
234 } 235 }
235 236
236 // Clear the dirty bit, and optionally remove this entry's metahandle from 237 // Clear the dirty bit, and optionally remove this entry's metahandle from
237 // a provided index on dirty bits in |dirty_index|. Parameter may be null, 238 // a provided index on dirty bits in |dirty_index|. Parameter may be null,
238 // and will result only in clearing dirty bit of this entry. 239 // and will result only in clearing dirty bit of this entry.
239 inline void clear_dirty(syncable::MetahandleSet* dirty_index) { 240 inline void clear_dirty(syncable::MetahandleSet* dirty_index) {
240 if (dirty_ && dirty_index) { 241 if (dirty_ && dirty_index) {
241 DCHECK_NE(0, ref(META_HANDLE)); 242 DCHECK_NE(0, ref(META_HANDLE));
242 dirty_index->erase(ref(META_HANDLE)); 243 dirty_index->erase(ref(META_HANDLE));
243 } 244 }
244 dirty_ = false; 245 dirty_ = false;
245 } 246 }
246 247
247 inline bool is_dirty() const { 248 inline bool is_dirty() const {
248 return dirty_; 249 return dirty_;
249 } 250 }
250 251
252 inline void set_cached_size(size_t size) { cached_size_ = size; }
253
254 inline size_t cached_size() const { return cached_size_; }
255
251 // Setters. 256 // Setters.
252 inline void put(MetahandleField field, int64_t value) { 257 inline void put(MetahandleField field, int64_t value) {
253 int64_fields[field - INT64_FIELDS_BEGIN] = value; 258 int64_fields[field - INT64_FIELDS_BEGIN] = value;
254 } 259 }
255 inline void put(Int64Field field, int64_t value) { 260 inline void put(Int64Field field, int64_t value) {
256 int64_fields[field - INT64_FIELDS_BEGIN] = value; 261 int64_fields[field - INT64_FIELDS_BEGIN] = value;
257 } 262 }
258 inline void put(TimeField field, const base::Time& value) { 263 inline void put(TimeField field, const base::Time& value) {
259 // Round-trip to proto time format and back so that we have 264 // Round-trip to proto time format and back so that we have
260 // consistent time resolutions (ms). 265 // consistent time resolutions (ms).
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 // Dumps all kernel info into a DictionaryValue and returns it. 386 // Dumps all kernel info into a DictionaryValue and returns it.
382 // Transfers ownership of the DictionaryValue to the caller. 387 // Transfers ownership of the DictionaryValue to the caller.
383 // Note: |cryptographer| is an optional parameter for use in decrypting 388 // Note: |cryptographer| is an optional parameter for use in decrypting
384 // encrypted specifics. If it is NULL or the specifics are not decryptsble, 389 // encrypted specifics. If it is NULL or the specifics are not decryptsble,
385 // they will be serialized as empty proto's. 390 // they will be serialized as empty proto's.
386 base::DictionaryValue* ToValue(Cryptographer* cryptographer) const; 391 base::DictionaryValue* ToValue(Cryptographer* cryptographer) const;
387 392
388 private: 393 private:
389 // Tracks whether this entry needs to be saved to the database. 394 // Tracks whether this entry needs to be saved to the database.
390 bool dirty_; 395 bool dirty_;
396 size_t cached_size_;
391 }; 397 };
392 398
393 class EntryKernelLessByMetaHandle { 399 class EntryKernelLessByMetaHandle {
394 public: 400 public:
395 inline bool operator()(const EntryKernel* a, 401 inline bool operator()(const EntryKernel* a,
396 const EntryKernel* b) const { 402 const EntryKernel* b) const {
397 return a->ref(META_HANDLE) < b->ref(META_HANDLE); 403 return a->ref(META_HANDLE) < b->ref(META_HANDLE);
398 } 404 }
399 }; 405 };
400 406
(...skipping 15 matching lines...) Expand all
416 // Caller owns the return value. 422 // Caller owns the return value.
417 base::ListValue* EntryKernelMutationMapToValue( 423 base::ListValue* EntryKernelMutationMapToValue(
418 const EntryKernelMutationMap& mutations); 424 const EntryKernelMutationMap& mutations);
419 425
420 std::ostream& operator<<(std::ostream& os, const EntryKernel& entry_kernel); 426 std::ostream& operator<<(std::ostream& os, const EntryKernel& entry_kernel);
421 427
422 } // namespace syncable 428 } // namespace syncable
423 } // namespace syncer 429 } // namespace syncer
424 430
425 #endif // SYNC_SYNCABLE_ENTRY_KERNEL_H_ 431 #endif // SYNC_SYNCABLE_ENTRY_KERNEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698