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

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

Issue 1008103002: Sync: Avoid 3 passes over SyncDarta DB when loading the directory from the disk (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed CR feedback. Created 5 years, 9 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/syncable/directory.cc ('k') | sync/syncable/directory_backing_store.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 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_DIRECTORY_BACKING_STORE_H_ 5 #ifndef SYNC_SYNCABLE_DIRECTORY_BACKING_STORE_H_
6 #define SYNC_SYNCABLE_DIRECTORY_BACKING_STORE_H_ 6 #define SYNC_SYNCABLE_DIRECTORY_BACKING_STORE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // 42 //
43 // This class is abstract so that we can extend it in interesting ways for use 43 // This class is abstract so that we can extend it in interesting ways for use
44 // in tests. The concrete class used in non-test scenarios is 44 // in tests. The concrete class used in non-test scenarios is
45 // OnDiskDirectoryBackingStore. 45 // OnDiskDirectoryBackingStore.
46 class SYNC_EXPORT_PRIVATE DirectoryBackingStore : public base::NonThreadSafe { 46 class SYNC_EXPORT_PRIVATE DirectoryBackingStore : public base::NonThreadSafe {
47 public: 47 public:
48 explicit DirectoryBackingStore(const std::string& dir_name); 48 explicit DirectoryBackingStore(const std::string& dir_name);
49 virtual ~DirectoryBackingStore(); 49 virtual ~DirectoryBackingStore();
50 50
51 // Loads and drops all currently persisted meta entries into |handles_map| 51 // Loads and drops all currently persisted meta entries into |handles_map|
52 // and loads appropriate persisted kernel info into |info_bucket|. 52 // and loads appropriate persisted kernel info into |kernel_load_info|.
53 // The function determines which entries can be safely dropped and inserts
54 // their keys into |metahandles_to_purge|. It is up to the caller to
55 // perform the actual cleanup.
53 // 56 //
54 // This function can perform some cleanup tasks behind the scenes. It will 57 // This function will migrate to the latest database version.
55 // clean up unused entries from the database and migrate to the latest
56 // database version. The caller can safely ignore these details.
57 // 58 //
58 // NOTE: On success (return value of OPENED), the buckets are populated with 59 // NOTE: On success (return value of OPENED), the buckets are populated with
59 // newly allocated items, meaning ownership is bestowed upon the caller. 60 // newly allocated items, meaning ownership is bestowed upon the caller.
60 virtual DirOpenResult Load(Directory::MetahandlesMap* handles_map, 61 virtual DirOpenResult Load(Directory::MetahandlesMap* handles_map,
61 JournalIndex* delete_journals, 62 JournalIndex* delete_journals,
63 MetahandleSet* metahandles_to_purge,
62 Directory::KernelLoadInfo* kernel_load_info) = 0; 64 Directory::KernelLoadInfo* kernel_load_info) = 0;
63 65
64 // Updates the on-disk store with the input |snapshot| as a database 66 // Updates the on-disk store with the input |snapshot| as a database
65 // transaction. Does NOT open any syncable transactions as this would cause 67 // transaction. Does NOT open any syncable transactions as this would cause
66 // opening transactions elsewhere to block on synchronous I/O. 68 // opening transactions elsewhere to block on synchronous I/O.
67 // DO NOT CALL THIS FROM MORE THAN ONE THREAD EVER. Also, whichever thread 69 // DO NOT CALL THIS FROM MORE THAN ONE THREAD EVER. Also, whichever thread
68 // calls SaveChanges *must* be the thread that owns/destroys |this|. 70 // calls SaveChanges *must* be the thread that owns/destroys |this|.
69 virtual bool SaveChanges(const Directory::SaveChangesSnapshot& snapshot); 71 virtual bool SaveChanges(const Directory::SaveChangesSnapshot& snapshot);
70 72
71 protected: 73 protected:
(...skipping 11 matching lines...) Expand all
83 85
84 bool CreateShareInfoTableVersion71(bool is_temporary); 86 bool CreateShareInfoTableVersion71(bool is_temporary);
85 // Create 'metas' or 'temp_metas' depending on value of is_temporary. Also 87 // Create 'metas' or 'temp_metas' depending on value of is_temporary. Also
86 // create a 'deleted_metas' table using same schema. 88 // create a 'deleted_metas' table using same schema.
87 bool CreateMetasTable(bool is_temporary); 89 bool CreateMetasTable(bool is_temporary);
88 bool CreateModelsTable(); 90 bool CreateModelsTable();
89 bool CreateV71ModelsTable(); 91 bool CreateV71ModelsTable();
90 bool CreateV75ModelsTable(); 92 bool CreateV75ModelsTable();
91 bool CreateV81ModelsTable(); 93 bool CreateV81ModelsTable();
92 94
93 // We don't need to load any synced and applied deleted entries, we can
94 // in fact just purge them forever on startup.
95 bool DropDeletedEntries();
96 // Drops a table if it exists, harmless if the table did not already exist. 95 // Drops a table if it exists, harmless if the table did not already exist.
97 bool SafeDropTable(const char* table_name); 96 bool SafeDropTable(const char* table_name);
98 97
99 // Load helpers for entries and attributes. 98 // Load helpers for entries and attributes.
100 bool LoadEntries(Directory::MetahandlesMap* handles_map); 99 bool LoadEntries(Directory::MetahandlesMap* handles_map,
100 MetahandleSet* metahandles_to_purge);
101 bool LoadDeleteJournals(JournalIndex* delete_journals); 101 bool LoadDeleteJournals(JournalIndex* delete_journals);
102 bool LoadInfo(Directory::KernelLoadInfo* info); 102 bool LoadInfo(Directory::KernelLoadInfo* info);
103 bool SafeToPurgeOnLoading(const EntryKernel& entry) const;
103 104
104 // Save/update helpers for entries. Return false if sqlite commit fails. 105 // Save/update helpers for entries. Return false if sqlite commit fails.
105 static bool SaveEntryToDB(sql::Statement* save_statement, 106 static bool SaveEntryToDB(sql::Statement* save_statement,
106 const EntryKernel& entry); 107 const EntryKernel& entry);
107 bool SaveNewEntryToDB(const EntryKernel& entry); 108 bool SaveNewEntryToDB(const EntryKernel& entry);
108 bool UpdateEntryToDB(const EntryKernel& entry); 109 bool UpdateEntryToDB(const EntryKernel& entry);
109 110
110 // Close save_dbhandle_. Broken out for testing. 111 // Close save_dbhandle_. Broken out for testing.
111 void EndSave(); 112 void EndSave();
112 113
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 void PrepareSaveEntryStatement(EntryTable table, 190 void PrepareSaveEntryStatement(EntryTable table,
190 sql::Statement* save_statement); 191 sql::Statement* save_statement);
191 192
192 DISALLOW_COPY_AND_ASSIGN(DirectoryBackingStore); 193 DISALLOW_COPY_AND_ASSIGN(DirectoryBackingStore);
193 }; 194 };
194 195
195 } // namespace syncable 196 } // namespace syncable
196 } // namespace syncer 197 } // namespace syncer
197 198
198 #endif // SYNC_SYNCABLE_DIRECTORY_BACKING_STORE_H_ 199 #endif // SYNC_SYNCABLE_DIRECTORY_BACKING_STORE_H_
OLDNEW
« no previous file with comments | « sync/syncable/directory.cc ('k') | sync/syncable/directory_backing_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698