OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_LEVELDB_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_LEVELDB_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <leveldb/db.h> |
| 10 #include <string> |
| 11 |
| 12 #include "base/file_path.h" |
| 13 #include "chrome/browser/chromeos/gdata/gdata_db.h" |
| 14 |
| 15 namespace gdata { |
| 16 |
| 17 class GDataLevelDB : public GDataDB { |
| 18 public: |
| 19 GDataLevelDB(); |
| 20 |
| 21 void Init(const FilePath& db_path); |
| 22 |
| 23 private: |
| 24 virtual ~GDataLevelDB(); |
| 25 |
| 26 // GDataDB implementation. |
| 27 virtual Status Put(const GDataEntry& file) OVERRIDE; |
| 28 virtual Status DeleteByResourceId(const std::string& resource_id) OVERRIDE; |
| 29 virtual Status DeleteByPath(const FilePath& path) OVERRIDE; |
| 30 virtual Status GetByResourceId(const std::string& resource_id, |
| 31 scoped_ptr<GDataEntry>* file) OVERRIDE; |
| 32 virtual Status GetByPath(const FilePath& path, |
| 33 scoped_ptr<GDataEntry>* file) OVERRIDE; |
| 34 virtual scoped_ptr<GDataDBIter> CreateIterator(const FilePath& path) OVERRIDE; |
| 35 |
| 36 // Returns |resource_id| for |path| by looking up path_db_. |
| 37 Status ResourceIdForPath(const FilePath& path, std::string* resource_id); |
| 38 |
| 39 scoped_ptr<leveldb::DB> level_db_; |
| 40 }; |
| 41 |
| 42 class GDataLevelDBIter : public GDataDBIter { |
| 43 public: |
| 44 GDataLevelDBIter(scoped_ptr<leveldb::Iterator> level_db_iter, |
| 45 GDataDB* db, const FilePath& path); |
| 46 private: |
| 47 virtual ~GDataLevelDBIter(); |
| 48 |
| 49 // GDataDBIter implementation. |
| 50 virtual bool GetNext(std::string* path, |
| 51 scoped_ptr<GDataEntry>* entry) OVERRIDE; |
| 52 |
| 53 scoped_ptr<leveldb::Iterator> level_db_iter_; |
| 54 GDataDB* db_; |
| 55 const FilePath path_; |
| 56 }; |
| 57 |
| 58 } // namespace gdata |
| 59 |
| 60 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_LEVELDB_H_ |
OLD | NEW |