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

Unified Diff: chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk.h

Issue 428063002: [SyncFS] Replace leveldb classes with LevelDBWrapper (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase on cl/437943002 Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk.h
diff --git a/chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk.h b/chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk.h
index 72193d19d23f8ca5f651971cd9ffd700a6a82af9..f9423804991e9f4c292cfba614a014bc9d589b99 100644
--- a/chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk.h
+++ b/chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk.h
@@ -13,15 +13,12 @@
#include "chrome/browser/sync_file_system/drive_backend/metadata_database_index_interface.h"
#include "chrome/browser/sync_file_system/drive_backend/tracker_id_set.h"
-namespace leveldb {
-class DB;
-}
-
namespace sync_file_system {
namespace drive_backend {
class FileMetadata;
class FileTracker;
+class LevelDBWrapper;
class ServiceMetadata;
struct DatabaseContents;
// TODO(peria): Migrate implementation of ParentIDAndTitle structure from
@@ -31,8 +28,7 @@ struct ParentIDAndTitle;
// Maintains indexes of MetadataDatabase on disk.
class MetadataDatabaseIndexOnDisk : public MetadataDatabaseIndexInterface {
public:
- static scoped_ptr<MetadataDatabaseIndexOnDisk>
- Create(leveldb::DB* db, leveldb::WriteBatch* batch);
+ static scoped_ptr<MetadataDatabaseIndexOnDisk> Create(LevelDBWrapper* db);
virtual ~MetadataDatabaseIndexOnDisk();
@@ -41,14 +37,10 @@ class MetadataDatabaseIndexOnDisk : public MetadataDatabaseIndexInterface {
const std::string& file_id, FileMetadata* metadata) const OVERRIDE;
virtual bool GetFileTracker(
int64 tracker_id, FileTracker* tracker) const OVERRIDE;
- virtual void StoreFileMetadata(
- scoped_ptr<FileMetadata> metadata, leveldb::WriteBatch* batch) OVERRIDE;
- virtual void StoreFileTracker(
- scoped_ptr<FileTracker> tracker, leveldb::WriteBatch* batch) OVERRIDE;
- virtual void RemoveFileMetadata(
- const std::string& file_id, leveldb::WriteBatch* batch) OVERRIDE;
- virtual void RemoveFileTracker(
- int64 tracker_id, leveldb::WriteBatch* batch) OVERRIDE;
+ virtual void StoreFileMetadata(scoped_ptr<FileMetadata> metadata) OVERRIDE;
+ virtual void StoreFileTracker(scoped_ptr<FileTracker> tracker) OVERRIDE;
+ virtual void RemoveFileMetadata(const std::string& file_id) OVERRIDE;
+ virtual void RemoveFileTracker(int64 tracker_id) OVERRIDE;
virtual TrackerIDSet GetFileTrackerIDsByFileID(
const std::string& file_id) const OVERRIDE;
virtual int64 GetAppRootTracker(const std::string& app_id) const OVERRIDE;
@@ -59,19 +51,15 @@ class MetadataDatabaseIndexOnDisk : public MetadataDatabaseIndexInterface {
virtual std::string PickMultiTrackerFileID() const OVERRIDE;
virtual ParentIDAndTitle PickMultiBackingFilePath() const OVERRIDE;
virtual int64 PickDirtyTracker() const OVERRIDE;
- virtual void DemoteDirtyTracker(
- int64 tracker_id, leveldb::WriteBatch* batch) OVERRIDE;
+ virtual void DemoteDirtyTracker(int64 tracker_id) OVERRIDE;
virtual bool HasDemotedDirtyTracker() const OVERRIDE;
- virtual void PromoteDemotedDirtyTrackers(leveldb::WriteBatch* batch) OVERRIDE;
+ virtual void PromoteDemotedDirtyTrackers() OVERRIDE;
virtual size_t CountDirtyTracker() const OVERRIDE;
virtual size_t CountFileMetadata() const OVERRIDE;
virtual size_t CountFileTracker() const OVERRIDE;
- virtual void SetSyncRootTrackerID(int64 sync_root_id,
- leveldb::WriteBatch* batch) const OVERRIDE;
- virtual void SetLargestChangeID(int64 largest_change_id,
- leveldb::WriteBatch* batch) const OVERRIDE;
- virtual void SetNextTrackerID(int64 next_tracker_id,
- leveldb::WriteBatch* batch) const OVERRIDE;
+ virtual void SetSyncRootTrackerID(int64 sync_root_id) const OVERRIDE;
+ virtual void SetLargestChangeID(int64 largest_change_id) const OVERRIDE;
+ virtual void SetNextTrackerID(int64 next_tracker_id) const OVERRIDE;
virtual int64 GetSyncRootTrackerID() const OVERRIDE;
virtual int64 GetLargestChangeID() const OVERRIDE;
virtual int64 GetNextTrackerID() const OVERRIDE;
@@ -80,7 +68,7 @@ class MetadataDatabaseIndexOnDisk : public MetadataDatabaseIndexInterface {
virtual std::vector<std::string> GetAllMetadataIDs() const OVERRIDE;
// Builds on-disk indexes from FileTracker entries on disk.
- void BuildTrackerIndexes(leveldb::WriteBatch* batch);
+ void BuildTrackerIndexes();
private:
enum NumEntries {
@@ -89,43 +77,31 @@ class MetadataDatabaseIndexOnDisk : public MetadataDatabaseIndexInterface {
MULTIPLE, // Two or more entires are found.
};
- explicit MetadataDatabaseIndexOnDisk(leveldb::DB* db);
+ explicit MetadataDatabaseIndexOnDisk(LevelDBWrapper* db);
// Maintain indexes from AppIDs to tracker IDs.
- void AddToAppIDIndex(const FileTracker& new_tracker,
- leveldb::WriteBatch* batch);
+ void AddToAppIDIndex(const FileTracker& new_tracker);
void UpdateInAppIDIndex(const FileTracker& old_tracker,
- const FileTracker& new_tracker,
- leveldb::WriteBatch* batch);
- void RemoveFromAppIDIndex(const FileTracker& tracker,
- leveldb::WriteBatch* batch);
+ const FileTracker& new_tracker);
+ void RemoveFromAppIDIndex(const FileTracker& tracker);
// Maintain indexes from remote file IDs to tracker ID sets.
- void AddToFileIDIndexes(const FileTracker& new_tracker,
- leveldb::WriteBatch* batch);
+ void AddToFileIDIndexes(const FileTracker& new_tracker);
void UpdateInFileIDIndexes(const FileTracker& old_tracker,
- const FileTracker& new_tracker,
- leveldb::WriteBatch* batch);
- void RemoveFromFileIDIndexes(const FileTracker& tracker,
- leveldb::WriteBatch* batch);
+ const FileTracker& new_tracker);
+ void RemoveFromFileIDIndexes(const FileTracker& tracker);
// Maintain indexes from path indexes to tracker ID sets
- void AddToPathIndexes(const FileTracker& new_tracker,
- leveldb::WriteBatch* batch);
+ void AddToPathIndexes(const FileTracker& new_tracker);
void UpdateInPathIndexes(const FileTracker& old_tracker,
- const FileTracker& new_tracker,
- leveldb::WriteBatch* batch);
- void RemoveFromPathIndexes(const FileTracker& tracker,
- leveldb::WriteBatch* batch);
+ const FileTracker& new_tracker);
+ void RemoveFromPathIndexes(const FileTracker& tracker);
// Maintain dirty tracker IDs.
- void AddToDirtyTrackerIndexes(const FileTracker& new_tracker,
- leveldb::WriteBatch* batch);
+ void AddToDirtyTrackerIndexes(const FileTracker& new_tracker);
void UpdateInDirtyTrackerIndexes(const FileTracker& old_tracker,
- const FileTracker& new_tracker,
- leveldb::WriteBatch* batch);
- void RemoveFromDirtyTrackerIndexes(const FileTracker& tracker,
- leveldb::WriteBatch* batch);
+ const FileTracker& new_tracker);
+ void RemoveFromDirtyTrackerIndexes(const FileTracker& tracker);
// Returns a TrackerIDSet built from IDs which are found with given key
// and key prefix.
@@ -141,32 +117,28 @@ class MetadataDatabaseIndexOnDisk : public MetadataDatabaseIndexInterface {
void AddToTrackerIDSetWithPrefix(
const std::string& active_tracker_key,
const std::string& key_prefix,
- const FileTracker& tracker,
- leveldb::WriteBatch* batch);
+ const FileTracker& tracker);
// Returns true if |tracker_id| is removed successfully. If no other entries
// are stored with |key_prefix|, the entry for |active_key| is also removed.
bool EraseInTrackerIDSetWithPrefix(
const std::string& active_tracker_key,
const std::string& key_prefix,
- int64 tracker_id,
- leveldb::WriteBatch* batch);
+ int64 tracker_id);
// Adds an entry for |active_key| on DB, if |tracker_id| has an entry with
// |key_prefix|.
void ActivateInTrackerIDSetWithPrefix(
const std::string& active_tracker_key,
const std::string& key_prefix,
- int64 tracker_id,
- leveldb::WriteBatch* batch);
+ int64 tracker_id);
// Removes an entry for |active_key| on DB, if the value of |active_key| key
// is |tracker_id|.
void DeactivateInTrackerIDSetWithPrefix(
const std::string& active_tracker_key,
const std::string& key_prefix,
- int64 tracker_id,
- leveldb::WriteBatch* batch);
+ int64 tracker_id);
// Checks if |db_| has an entry whose key is |key|.
bool DBHasKey(const std::string& key);
@@ -175,7 +147,7 @@ class MetadataDatabaseIndexOnDisk : public MetadataDatabaseIndexInterface {
// Entries for |ignored_id| are not counted in.
NumEntries CountWithPrefix(const std::string& prefix, int64 ignored_id);
- leveldb::DB* db_; // Not owned.
+ LevelDBWrapper* db_; // Not owned.
scoped_ptr<ServiceMetadata> service_metadata_;
DISALLOW_COPY_AND_ASSIGN(MetadataDatabaseIndexOnDisk);

Powered by Google App Engine
This is Rietveld 408576698