Chromium Code Reviews| Index: sync/syncable/directory_backing_store.h |
| diff --git a/sync/syncable/directory_backing_store.h b/sync/syncable/directory_backing_store.h |
| index a3e17d87c10cc0633b820615f74e285503d97ecd..7b1a35bcca98465c2f056937863eab883c8fdc69 100644 |
| --- a/sync/syncable/directory_backing_store.h |
| +++ b/sync/syncable/directory_backing_store.h |
| @@ -25,6 +25,7 @@ namespace syncable { |
| struct ColumnSpec; |
| typedef Directory::MetahandlesIndex MetahandlesIndex; |
| +typedef Directory::IdsIndex IdsIndex; |
| // Interface that provides persistence for a syncable::Directory object. You can |
| // load all the persisted data to prime a syncable::Directory on startup by |
| @@ -56,6 +57,7 @@ class DirectoryBackingStore : public base::NonThreadSafe { |
| // NOTE: On success (return value of OPENED), the buckets are populated with |
| // newly allocated items, meaning ownership is bestowed upon the caller. |
| virtual DirOpenResult Load(MetahandlesIndex* entry_bucket, |
| + IdsIndex* delete_journals, |
| Directory::KernelLoadInfo* kernel_load_info) = 0; |
| // Updates the on-disk store with the input |snapshot| as a database |
| @@ -79,7 +81,8 @@ class DirectoryBackingStore : public base::NonThreadSafe { |
| bool CreateShareInfoTable(bool is_temporary); |
| bool CreateShareInfoTableVersion71(bool is_temporary); |
| - // Create 'metas' or 'temp_metas' depending on value of is_temporary. |
| + // Create 'metas' or 'temp_metas' depending on value of is_temporary. Also |
| + // create a 'deleted_metas' table using same schema. |
| bool CreateMetasTable(bool is_temporary); |
| bool CreateModelsTable(); |
| bool CreateV71ModelsTable(); |
| @@ -92,10 +95,12 @@ class DirectoryBackingStore : public base::NonThreadSafe { |
| // Load helpers for entries and attributes. |
| bool LoadEntries(MetahandlesIndex* entry_bucket); |
| + bool LoadDeleteJournals(IdsIndex* delete_journals); |
| bool LoadInfo(Directory::KernelLoadInfo* info); |
| // Save/update helpers for entries. Return false if sqlite commit fails. |
| - bool SaveEntryToDB(const EntryKernel& entry); |
| + static bool SaveEntryToDB(sql::Statement* save_statement, |
| + const EntryKernel& entry); |
| bool SaveNewEntryToDB(const EntryKernel& entry); |
| bool UpdateEntryToDB(const EntryKernel& entry); |
| @@ -105,9 +110,10 @@ class DirectoryBackingStore : public base::NonThreadSafe { |
| // Close save_dbhandle_. Broken out for testing. |
| void EndSave(); |
| - // Removes each entry whose metahandle is in |handles| from the database. |
| + // Removes each entry whose metahandle is in |handles| from metas table if |
| + // |meta_delete| is true, or from delete journals table if it's false. |
| // Does synchronous I/O. Returns false on error. |
| - bool DeleteEntries(const MetahandleSet& handles); |
| + bool DeleteEntries(bool meta_delete, const MetahandleSet& handles); |
|
tim (not reviewing)
2012/12/13 23:41:30
Can you make this an enum with DELETE_FROM_METAS a
haitaol1
2012/12/14 19:22:38
Done.
|
| // Drop all tables in preparation for reinitialization. |
| void DropAllTables(); |
| @@ -158,15 +164,26 @@ class DirectoryBackingStore : public base::NonThreadSafe { |
| bool MigrateVersion80To81(); |
| bool MigrateVersion81To82(); |
| bool MigrateVersion82To83(); |
| + bool MigrateVersion83To84(); |
| scoped_ptr<sql::Connection> db_; |
| - sql::Statement save_entry_statement_; |
| + sql::Statement save_meta_statment_; |
| + sql::Statement save_delete_journal_statment_; |
| std::string dir_name_; |
| // Set to true if migration left some old columns around that need to be |
| // discarded. |
| bool needs_column_refresh_; |
| + private: |
| + // Helper function for loading entries from specified table. |
| + template<class T> |
| + bool LoadEntriesInternal(const std::string& table, T* bucket); |
| + |
| + // Prepares |save_statement| for saving entries in |table|. |
| + void PrepareSaveEntryStatement(const std::string& table, |
| + sql::Statement* save_statement); |
| + |
| DISALLOW_COPY_AND_ASSIGN(DirectoryBackingStore); |
| }; |