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

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: Remove cbegin/cend references to fix compile Created 7 years, 7 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 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
Nicolas Zea 2013/05/28 22:12:39 remove extra newline, and period at end of comment
rlarocque 2013/05/29 19:01:13 Done.
461 // A helper used by GetTotalNodeCount
462 void GetTotalNodeCountImpl(
463 BaseTransaction*,
464 EntryKernel* kernel_,
465 std::deque<const OrderedChildSet*>* child_sets) const;
466
457 Directory& operator = (const Directory&); 467 Directory& operator = (const Directory&);
458 468
459 public: 469 public:
460 // These contain all items, including IS_DEL items. 470 // These contain all items, including IS_DEL items.
461 typedef Index<MetahandleIndexer>::Set MetahandlesIndex; 471 typedef Index<MetahandleIndexer>::Set MetahandlesIndex;
462 typedef Index<IdIndexer>::Set IdsIndex; 472 typedef Index<IdIndexer>::Set IdsIndex;
463 473
464 // Contains both deleted and existing entries with tags. 474 // Contains both deleted and existing entries with tags.
465 // We can't store only existing tags because the client would create 475 // 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 476 // 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 586
577 // Maintain deleted entries not in |kernel_| until it's verified that they 587 // Maintain deleted entries not in |kernel_| until it's verified that they
578 // are deleted in native models as well. 588 // are deleted in native models as well.
579 scoped_ptr<DeleteJournal> delete_journal_; 589 scoped_ptr<DeleteJournal> delete_journal_;
580 }; 590 };
581 591
582 } // namespace syncable 592 } // namespace syncable
583 } // namespace syncer 593 } // namespace syncer
584 594
585 #endif // SYNC_SYNCABLE_DIRECTORY_H_ 595 #endif // SYNC_SYNCABLE_DIRECTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698