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

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

Issue 2452713003: [Sync] Implement MemoryDumpProvider. (Closed)
Patch Set: Fix presumit; fix Windows; git cl format Created 4 years, 1 month 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 COMPONENTS_SYNC_SYNCABLE_ENTRY_KERNEL_H_ 5 #ifndef COMPONENTS_SYNC_SYNCABLE_ENTRY_KERNEL_H_
6 #define COMPONENTS_SYNC_SYNCABLE_ENTRY_KERNEL_H_ 6 #define COMPONENTS_SYNC_SYNCABLE_ENTRY_KERNEL_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 218
219 // Set the dirty bit, and optionally add this entry's metahandle to 219 // Set the dirty bit, and optionally add this entry's metahandle to
220 // a provided index on dirty bits in |dirty_index|. Parameter may be null, 220 // a provided index on dirty bits in |dirty_index|. Parameter may be null,
221 // and will result only in setting the dirty bit of this entry. 221 // and will result only in setting the dirty bit of this entry.
222 inline void mark_dirty(syncable::MetahandleSet* dirty_index) { 222 inline void mark_dirty(syncable::MetahandleSet* dirty_index) {
223 if (!dirty_ && dirty_index) { 223 if (!dirty_ && dirty_index) {
224 DCHECK_NE(0, ref(META_HANDLE)); 224 DCHECK_NE(0, ref(META_HANDLE));
225 dirty_index->insert(ref(META_HANDLE)); 225 dirty_index->insert(ref(META_HANDLE));
226 } 226 }
227 dirty_ = true; 227 dirty_ = true;
228 memory_usage_ = kMemoryUsageUnknown;
228 } 229 }
229 230
230 // Clear the dirty bit, and optionally remove this entry's metahandle from 231 // Clear the dirty bit, and optionally remove this entry's metahandle from
231 // a provided index on dirty bits in |dirty_index|. Parameter may be null, 232 // a provided index on dirty bits in |dirty_index|. Parameter may be null,
232 // and will result only in clearing dirty bit of this entry. 233 // and will result only in clearing dirty bit of this entry.
233 inline void clear_dirty(syncable::MetahandleSet* dirty_index) { 234 inline void clear_dirty(syncable::MetahandleSet* dirty_index) {
234 if (dirty_ && dirty_index) { 235 if (dirty_ && dirty_index) {
235 DCHECK_NE(0, ref(META_HANDLE)); 236 DCHECK_NE(0, ref(META_HANDLE));
236 dirty_index->erase(ref(META_HANDLE)); 237 dirty_index->erase(ref(META_HANDLE));
237 } 238 }
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 bool ShouldMaintainPosition() const; 371 bool ShouldMaintainPosition() const;
371 bool ShouldMaintainHierarchy() const; 372 bool ShouldMaintainHierarchy() const;
372 373
373 // Dumps all kernel info into a DictionaryValue and returns it. 374 // Dumps all kernel info into a DictionaryValue and returns it.
374 // Transfers ownership of the DictionaryValue to the caller. 375 // Transfers ownership of the DictionaryValue to the caller.
375 // Note: |cryptographer| is an optional parameter for use in decrypting 376 // Note: |cryptographer| is an optional parameter for use in decrypting
376 // encrypted specifics. If it is null or the specifics are not decryptsble, 377 // encrypted specifics. If it is null or the specifics are not decryptsble,
377 // they will be serialized as empty proto's. 378 // they will be serialized as empty proto's.
378 base::DictionaryValue* ToValue(Cryptographer* cryptographer) const; 379 base::DictionaryValue* ToValue(Cryptographer* cryptographer) const;
379 380
381 size_t EstimateMemoryUsage() const;
382
380 private: 383 private:
381 // Tracks whether this entry needs to be saved to the database. 384 // Tracks whether this entry needs to be saved to the database.
382 bool dirty_; 385 bool dirty_;
386 mutable size_t memory_usage_;
387 constexpr static size_t kMemoryUsageUnknown = size_t(-1);
383 }; 388 };
384 389
385 template <typename T> 390 template <typename T>
386 class EntryKernelLessByMetaHandle { 391 class EntryKernelLessByMetaHandle {
387 public: 392 public:
388 inline bool operator()(T a, T b) const { 393 inline bool operator()(T a, T b) const {
389 return a->ref(META_HANDLE) < b->ref(META_HANDLE); 394 return a->ref(META_HANDLE) < b->ref(META_HANDLE);
390 } 395 }
391 }; 396 };
392 397
(...skipping 19 matching lines...) Expand all
412 417
413 std::unique_ptr<base::ListValue> EntryKernelMutationMapToValue( 418 std::unique_ptr<base::ListValue> EntryKernelMutationMapToValue(
414 const EntryKernelMutationMap& mutations); 419 const EntryKernelMutationMap& mutations);
415 420
416 std::ostream& operator<<(std::ostream& os, const EntryKernel& entry_kernel); 421 std::ostream& operator<<(std::ostream& os, const EntryKernel& entry_kernel);
417 422
418 } // namespace syncable 423 } // namespace syncable
419 } // namespace syncer 424 } // namespace syncer
420 425
421 #endif // COMPONENTS_SYNC_SYNCABLE_ENTRY_KERNEL_H_ 426 #endif // COMPONENTS_SYNC_SYNCABLE_ENTRY_KERNEL_H_
OLDNEW
« no previous file with comments | « components/sync/syncable/directory_backing_store.cc ('k') | components/sync/syncable/entry_kernel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698