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 | |
8 #include <leveldb/db.h> | |
9 #include <string> | |
10 | |
11 #include "base/file_path.h" | |
12 #include "chrome/browser/chromeos/gdata/gdata_db.h" | |
13 | |
14 namespace gdata { | |
15 | |
16 class GDataLevelDB : public GDataDB { | |
17 public: | |
18 GDataLevelDB(); | |
19 | |
20 void Init(const FilePath& db_path); | |
21 | |
22 private: | |
23 virtual ~GDataLevelDB(); | |
24 | |
25 // GDataDB implementation. | |
26 virtual Status Put(const GDataEntry& file) OVERRIDE; | |
27 virtual Status DeleteByResourceId(const std::string& resource_id) OVERRIDE; | |
28 virtual Status DeleteByPath(const FilePath& path) OVERRIDE; | |
29 virtual Status GetByResourceId(const std::string& resource_id, | |
30 scoped_ptr<GDataEntry>* file) OVERRIDE; | |
31 virtual Status GetByPath(const FilePath& path, | |
32 scoped_ptr<GDataEntry>* file) OVERRIDE; | |
33 virtual scoped_ptr<GDataDBIter> CreateIterator(const FilePath& path) OVERRIDE; | |
34 virtual Status PutRawForTesting(const std::string& resource_id, | |
35 const std::string& raw_value) OVERRIDE; | |
36 | |
37 // Returns |resource_id| for |path| by looking up path_db_. | |
38 Status ResourceIdForPath(const FilePath& path, std::string* resource_id); | |
39 | |
40 scoped_ptr<leveldb::DB> level_db_; | |
41 }; | |
42 | |
43 class GDataLevelDBIter : public GDataDBIter { | |
44 public: | |
45 GDataLevelDBIter(scoped_ptr<leveldb::Iterator> level_db_iter, | |
46 GDataDB* db, const FilePath& path); | |
47 private: | |
48 virtual ~GDataLevelDBIter(); | |
49 | |
50 // GDataDBIter implementation. | |
51 virtual bool GetNext(std::string* path, | |
52 scoped_ptr<GDataEntry>* entry) OVERRIDE; | |
53 | |
54 scoped_ptr<leveldb::Iterator> level_db_iter_; | |
55 GDataDB* db_; | |
56 const FilePath path_; | |
57 }; | |
58 | |
59 } // namespace gdata | |
60 | |
61 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_LEVELDB_H_ | |
OLD | NEW |