OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 CHROME_BROWSER_CHROMEOS_GDATA_GDATA_LEVELDB_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_LEVELDB_H_ |
6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_LEVELDB_H_ | 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_LEVELDB_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <leveldb/db.h> | 9 #include <leveldb/db.h> |
10 #include <string> | 10 #include <string> |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 // GDataDB implementation. | 26 // GDataDB implementation. |
27 virtual Status Put(const GDataEntry& file) OVERRIDE; | 27 virtual Status Put(const GDataEntry& file) OVERRIDE; |
28 virtual Status DeleteByResourceId(const std::string& resource_id) OVERRIDE; | 28 virtual Status DeleteByResourceId(const std::string& resource_id) OVERRIDE; |
29 virtual Status DeleteByPath(const FilePath& path) OVERRIDE; | 29 virtual Status DeleteByPath(const FilePath& path) OVERRIDE; |
30 virtual Status GetByResourceId(const std::string& resource_id, | 30 virtual Status GetByResourceId(const std::string& resource_id, |
31 scoped_ptr<GDataEntry>* file) OVERRIDE; | 31 scoped_ptr<GDataEntry>* file) OVERRIDE; |
32 virtual Status GetByPath(const FilePath& path, | 32 virtual Status GetByPath(const FilePath& path, |
33 scoped_ptr<GDataEntry>* file) OVERRIDE; | 33 scoped_ptr<GDataEntry>* file) OVERRIDE; |
34 virtual scoped_ptr<GDataDBIter> CreateIterator(const FilePath& path) OVERRIDE; | 34 virtual scoped_ptr<GDataDBIter> CreateIterator(const FilePath& path) OVERRIDE; |
| 35 virtual Status PutRawForTesting( |
| 36 const std::string& resource_id, |
| 37 const google::protobuf::MessageLite& protobuf) OVERRIDE; |
35 | 38 |
36 // Returns |resource_id| for |path| by looking up path_db_. | 39 // Returns |resource_id| for |path| by looking up path_db_. |
37 Status ResourceIdForPath(const FilePath& path, std::string* resource_id); | 40 Status ResourceIdForPath(const FilePath& path, std::string* resource_id); |
38 | 41 |
39 scoped_ptr<leveldb::DB> level_db_; | 42 scoped_ptr<leveldb::DB> level_db_; |
40 }; | 43 }; |
41 | 44 |
42 class GDataLevelDBIter : public GDataDBIter { | 45 class GDataLevelDBIter : public GDataDBIter { |
43 public: | 46 public: |
44 GDataLevelDBIter(scoped_ptr<leveldb::Iterator> level_db_iter, | 47 GDataLevelDBIter(scoped_ptr<leveldb::Iterator> level_db_iter, |
45 GDataDB* db, const FilePath& path); | 48 GDataDB* db, const FilePath& path); |
46 private: | 49 private: |
47 virtual ~GDataLevelDBIter(); | 50 virtual ~GDataLevelDBIter(); |
48 | 51 |
49 // GDataDBIter implementation. | 52 // GDataDBIter implementation. |
50 virtual bool GetNext(std::string* path, | 53 virtual bool GetNext(std::string* path, |
51 scoped_ptr<GDataEntry>* entry) OVERRIDE; | 54 scoped_ptr<GDataEntry>* entry) OVERRIDE; |
52 | 55 |
53 scoped_ptr<leveldb::Iterator> level_db_iter_; | 56 scoped_ptr<leveldb::Iterator> level_db_iter_; |
54 GDataDB* db_; | 57 GDataDB* db_; |
55 const FilePath path_; | 58 const FilePath path_; |
56 }; | 59 }; |
57 | 60 |
58 } // namespace gdata | 61 } // namespace gdata |
59 | 62 |
60 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_LEVELDB_H_ | 63 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_LEVELDB_H_ |
OLD | NEW |