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

Side by Side Diff: chrome/browser/sync/syncable/syncable.h

Issue 7033043: [Sync] Speed up sync node browser/search in about:sync (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_ 5 #ifndef CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_
6 #define CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_ 6 #define CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <bitset> 10 #include <bitset>
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 typedef DirectoryEvent EventType; 840 typedef DirectoryEvent EventType;
841 static inline bool IsChannelShutdownEvent(const DirectoryEvent& event) { 841 static inline bool IsChannelShutdownEvent(const DirectoryEvent& event) {
842 return DIRECTORY_DESTROYED == event; 842 return DIRECTORY_DESTROYED == event;
843 } 843 }
844 }; 844 };
845 public: 845 public:
846 typedef EventChannel<DirectoryEventTraits, base::Lock> Channel; 846 typedef EventChannel<DirectoryEventTraits, base::Lock> Channel;
847 typedef std::vector<int64> ChildHandles; 847 typedef std::vector<int64> ChildHandles;
848 848
849 // Returns the child meta handles for given parent id. 849 // Returns the child meta handles for given parent id.
850 void GetChildHandles(BaseTransaction*, const Id& parent_id, 850 void GetChildHandlesById(BaseTransaction*, const Id& parent_id,
851 ChildHandles* result);
852
853 // Returns the child meta handles for given meta handle.
854 void GetChildHandlesByHandle(BaseTransaction*, int64 handle,
851 ChildHandles* result); 855 ChildHandles* result);
852 856
853 // Find the first or last child in the positional ordering under a parent, 857 // Find the first or last child in the positional ordering under a parent,
854 // and return its id. Returns a root Id if parent has no children. 858 // and return its id. Returns a root Id if parent has no children.
855 virtual Id GetFirstChildId(BaseTransaction* trans, const Id& parent_id); 859 virtual Id GetFirstChildId(BaseTransaction* trans, const Id& parent_id);
856 Id GetLastChildId(BaseTransaction* trans, const Id& parent_id); 860 Id GetLastChildId(BaseTransaction* trans, const Id& parent_id);
857 861
858 // Compute a local predecessor position for |update_item|. The position 862 // Compute a local predecessor position for |update_item|. The position
859 // is determined by the SERVER_POSITION_IN_PARENT value of |update_item|, 863 // is determined by the SERVER_POSITION_IN_PARENT value of |update_item|,
860 // as well as the SERVER_POSITION_IN_PARENT values of any up-to-date 864 // as well as the SERVER_POSITION_IN_PARENT values of any up-to-date
861 // children of |parent_id|. 865 // children of |parent_id|.
862 Id ComputePrevIdFromServerPosition( 866 Id ComputePrevIdFromServerPosition(
863 const EntryKernel* update_item, 867 const EntryKernel* update_item,
864 const syncable::Id& parent_id); 868 const syncable::Id& parent_id);
865 869
866 // SaveChanges works by taking a consistent snapshot of the current Directory 870 // SaveChanges works by taking a consistent snapshot of the current Directory
867 // state and indices (by deep copy) under a ReadTransaction, passing this 871 // state and indices (by deep copy) under a ReadTransaction, passing this
868 // snapshot to the backing store under no transaction, and finally cleaning 872 // snapshot to the backing store under no transaction, and finally cleaning
869 // up by either purging entries no longer needed (this part done under a 873 // up by either purging entries no longer needed (this part done under a
870 // WriteTransaction) or rolling back the dirty bits. It also uses 874 // WriteTransaction) or rolling back the dirty bits. It also uses
871 // internal locking to enforce SaveChanges operations are mutually exclusive. 875 // internal locking to enforce SaveChanges operations are mutually exclusive.
872 // 876 //
873 // WARNING: THIS METHOD PERFORMS SYNCHRONOUS I/O VIA SQLITE. 877 // WARNING: THIS METHOD PERFORMS SYNCHRONOUS I/O VIA SQLITE.
874 bool SaveChanges(); 878 bool SaveChanges();
875 879
880 // Fill in |result| with all meta handles.
881 void GetAllMetaHandles(BaseTransaction* trans, MetahandleSet* result);
882
876 // Returns the number of entities with the unsynced bit set. 883 // Returns the number of entities with the unsynced bit set.
877 int64 unsynced_entity_count() const; 884 int64 unsynced_entity_count() const;
878 885
879 // Get GetUnsyncedMetaHandles should only be called after SaveChanges and 886 // Get GetUnsyncedMetaHandles should only be called after SaveChanges and
880 // before any new entries have been created. The intention is that the 887 // before any new entries have been created. The intention is that the
881 // syncer should call it from its PerformSyncQueries member. 888 // syncer should call it from its PerformSyncQueries member.
882 typedef std::vector<int64> UnsyncedMetaHandles; 889 typedef std::vector<int64> UnsyncedMetaHandles;
883 void GetUnsyncedMetaHandles(BaseTransaction* trans, 890 void GetUnsyncedMetaHandles(BaseTransaction* trans,
884 UnsyncedMetaHandles* result); 891 UnsyncedMetaHandles* result);
885 892
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 942
936 // Rolls back dirty bits in the event that the SaveChanges that 943 // Rolls back dirty bits in the event that the SaveChanges that
937 // processed |snapshot| failed, for example, due to no disk space. 944 // processed |snapshot| failed, for example, due to no disk space.
938 void HandleSaveChangesFailure(const SaveChangesSnapshot& snapshot); 945 void HandleSaveChangesFailure(const SaveChangesSnapshot& snapshot);
939 946
940 // For new entry creation only 947 // For new entry creation only
941 void InsertEntry(EntryKernel* entry, ScopedKernelLock* lock); 948 void InsertEntry(EntryKernel* entry, ScopedKernelLock* lock);
942 void InsertEntry(EntryKernel* entry); 949 void InsertEntry(EntryKernel* entry);
943 950
944 // Used by CheckTreeInvariants 951 // Used by CheckTreeInvariants
945 void GetAllMetaHandles(BaseTransaction* trans, MetahandleSet* result);
946 bool SafeToPurgeFromMemory(const EntryKernel* const entry) const; 952 bool SafeToPurgeFromMemory(const EntryKernel* const entry) const;
947 953
948 // Internal setters that do not acquire a lock internally. These are unsafe 954 // Internal setters that do not acquire a lock internally. These are unsafe
949 // on their own; caller must guarantee exclusive access manually by holding 955 // on their own; caller must guarantee exclusive access manually by holding
950 // a ScopedKernelLock. 956 // a ScopedKernelLock.
951 void set_initial_sync_ended_for_type_unsafe(ModelType type, bool x); 957 void set_initial_sync_ended_for_type_unsafe(ModelType type, bool x);
952 void SetNotificationStateUnsafe(const std::string& notification_state); 958 void SetNotificationStateUnsafe(const std::string& notification_state);
953 959
954 Directory& operator = (const Directory&); 960 Directory& operator = (const Directory&);
955 961
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1065 ParentIdChildIndex::iterator GetParentChildIndexLowerBound( 1071 ParentIdChildIndex::iterator GetParentChildIndexLowerBound(
1066 const ScopedKernelLock& lock, 1072 const ScopedKernelLock& lock,
1067 const Id& parent_id); 1073 const Id& parent_id);
1068 1074
1069 // Return an iterator to just past the end of the range of the 1075 // Return an iterator to just past the end of the range of the
1070 // children of |parent_id| in the kernel's parent_id_child_index. 1076 // children of |parent_id| in the kernel's parent_id_child_index.
1071 ParentIdChildIndex::iterator GetParentChildIndexUpperBound( 1077 ParentIdChildIndex::iterator GetParentChildIndexUpperBound(
1072 const ScopedKernelLock& lock, 1078 const ScopedKernelLock& lock,
1073 const Id& parent_id); 1079 const Id& parent_id);
1074 1080
1081 // Fill in |result| with the handles of the children of |parent_id|.
1082 void GetChildHandles(
1083 const ScopedKernelLock& lock,
1084 const Id& parent_id, Directory::ChildHandles* result);
1085
1075 Kernel* kernel_; 1086 Kernel* kernel_;
1076 1087
1077 DirectoryBackingStore* store_; 1088 DirectoryBackingStore* store_;
1078 }; 1089 };
1079 1090
1080 class ScopedKernelLock { 1091 class ScopedKernelLock {
1081 public: 1092 public:
1082 explicit ScopedKernelLock(const Directory*); 1093 explicit ScopedKernelLock(const Directory*);
1083 ~ScopedKernelLock() {} 1094 ~ScopedKernelLock() {}
1084 1095
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 1184
1174 // This is not a reset. It just sets the numeric fields which are not 1185 // This is not a reset. It just sets the numeric fields which are not
1175 // initialized by the constructor to zero. 1186 // initialized by the constructor to zero.
1176 void ZeroFields(EntryKernel* entry, int first_field); 1187 void ZeroFields(EntryKernel* entry, int first_field);
1177 1188
1178 } // namespace syncable 1189 } // namespace syncable
1179 1190
1180 std::ostream& operator <<(std::ostream&, const syncable::Blob&); 1191 std::ostream& operator <<(std::ostream&, const syncable::Blob&);
1181 1192
1182 #endif // CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_ 1193 #endif // CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698