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

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

Issue 15322003: sync: Count nodes more efficiently (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Implement suggestions from review Created 7 years, 6 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
« no previous file with comments | « sync/internal_api/base_node.cc ('k') | sync/syncable/directory.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_DIRECTORY_H_ 5 #ifndef SYNC_SYNCABLE_DIRECTORY_H_
6 #define SYNC_SYNCABLE_DIRECTORY_H_ 6 #define SYNC_SYNCABLE_DIRECTORY_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 // children. 314 // children.
315 bool GetChildHandlesById(BaseTransaction*, const Id& parent_id, 315 bool GetChildHandlesById(BaseTransaction*, const Id& parent_id,
316 ChildHandles* result); 316 ChildHandles* result);
317 317
318 // Returns the child meta handles (even those for deleted/unlinked 318 // Returns the child meta handles (even those for deleted/unlinked
319 // nodes) for given meta handle. Clears |result| if there are no 319 // nodes) for given meta handle. Clears |result| if there are no
320 // children. 320 // children.
321 bool GetChildHandlesByHandle(BaseTransaction*, int64 handle, 321 bool GetChildHandlesByHandle(BaseTransaction*, int64 handle,
322 ChildHandles* result); 322 ChildHandles* result);
323 323
324 // Counts all items under the given node, including the node itself.
325 int GetTotalNodeCount(BaseTransaction*, EntryKernel* kernel_) const;
326
324 // Returns true iff |id| has children. 327 // Returns true iff |id| has children.
325 bool HasChildren(BaseTransaction* trans, const Id& id); 328 bool HasChildren(BaseTransaction* trans, const Id& id);
326 329
327 // Find the first child in the positional ordering under a parent, 330 // Find the first child in the positional ordering under a parent,
328 // and fill in |*first_child_id| with its id. Fills in a root Id if 331 // and fill in |*first_child_id| with its id. Fills in a root Id if
329 // parent has no children. Returns true if the first child was 332 // parent has no children. Returns true if the first child was
330 // successfully found, or false if an error was encountered. 333 // successfully found, or false if an error was encountered.
331 Id GetFirstChildId(BaseTransaction* trans, const EntryKernel* parent); 334 Id GetFirstChildId(BaseTransaction* trans, const EntryKernel* parent);
332 335
333 // These functions allow one to fetch the next or previous item under 336 // These functions allow one to fetch the next or previous item under
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 // For new entry creation only 450 // For new entry creation only
448 bool InsertEntry(WriteTransaction* trans, 451 bool InsertEntry(WriteTransaction* trans,
449 EntryKernel* entry, ScopedKernelLock* lock); 452 EntryKernel* entry, ScopedKernelLock* lock);
450 bool InsertEntry(WriteTransaction* trans, EntryKernel* entry); 453 bool InsertEntry(WriteTransaction* trans, EntryKernel* entry);
451 454
452 // Used by CheckTreeInvariants 455 // Used by CheckTreeInvariants
453 void GetAllMetaHandles(BaseTransaction* trans, MetahandleSet* result); 456 void GetAllMetaHandles(BaseTransaction* trans, MetahandleSet* result);
454 bool SafeToPurgeFromMemory(WriteTransaction* trans, 457 bool SafeToPurgeFromMemory(WriteTransaction* trans,
455 const EntryKernel* const entry) const; 458 const EntryKernel* const entry) const;
456 459
460 // A helper used by GetTotalNodeCount.
461 void GetChildSetForKernel(
462 BaseTransaction*,
463 EntryKernel* kernel_,
464 std::deque<const OrderedChildSet*>* child_sets) const;
465
457 Directory& operator = (const Directory&); 466 Directory& operator = (const Directory&);
458 467
459 public: 468 public:
460 // These contain all items, including IS_DEL items. 469 // These contain all items, including IS_DEL items.
461 typedef Index<MetahandleIndexer>::Set MetahandlesIndex; 470 typedef Index<MetahandleIndexer>::Set MetahandlesIndex;
462 typedef Index<IdIndexer>::Set IdsIndex; 471 typedef Index<IdIndexer>::Set IdsIndex;
463 472
464 // Contains both deleted and existing entries with tags. 473 // Contains both deleted and existing entries with tags.
465 // We can't store only existing tags because the client would create 474 // We can't store only existing tags because the client would create
466 // items that had a duplicated ID in the end, resulting in a DB key 475 // items that had a duplicated ID in the end, resulting in a DB key
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 585
577 // Maintain deleted entries not in |kernel_| until it's verified that they 586 // Maintain deleted entries not in |kernel_| until it's verified that they
578 // are deleted in native models as well. 587 // are deleted in native models as well.
579 scoped_ptr<DeleteJournal> delete_journal_; 588 scoped_ptr<DeleteJournal> delete_journal_;
580 }; 589 };
581 590
582 } // namespace syncable 591 } // namespace syncable
583 } // namespace syncer 592 } // namespace syncer
584 593
585 #endif // SYNC_SYNCABLE_DIRECTORY_H_ 594 #endif // SYNC_SYNCABLE_DIRECTORY_H_
OLDNEW
« no previous file with comments | « sync/internal_api/base_node.cc ('k') | sync/syncable/directory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698