Chromium Code Reviews| 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_DB_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_DB_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_DB_H_ | 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_DB_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 | 12 |
| 13 class FilePath; | 13 class FilePath; |
| 14 | 14 |
| 15 namespace google { | |
| 16 namespace protobuf { | |
| 17 class MessageLite; | |
| 18 } // namespace protobuf | |
| 19 } // namespace google | |
| 20 | |
| 15 namespace gdata { | 21 namespace gdata { |
| 16 | 22 |
| 17 class GDataEntry; | 23 class GDataEntry; |
| 18 class GDataDBIter; | 24 class GDataDBIter; |
| 19 | 25 |
| 20 // GData Database interface class. | 26 // GData Database interface class. |
| 21 class GDataDB { | 27 class GDataDB { |
| 22 public: | 28 public: |
| 23 enum Status { | 29 enum Status { |
| 24 DB_OK = 0, | 30 DB_OK = 0, |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 40 // Fetches a GDataEntry* by key |resource_id| or |path| respectively. | 46 // Fetches a GDataEntry* by key |resource_id| or |path| respectively. |
| 41 virtual Status GetByResourceId(const std::string& resource_id, | 47 virtual Status GetByResourceId(const std::string& resource_id, |
| 42 scoped_ptr<GDataEntry>* entry) = 0; | 48 scoped_ptr<GDataEntry>* entry) = 0; |
| 43 virtual Status GetByPath(const FilePath& path, | 49 virtual Status GetByPath(const FilePath& path, |
| 44 scoped_ptr<GDataEntry>* entry) = 0; | 50 scoped_ptr<GDataEntry>* entry) = 0; |
| 45 | 51 |
| 46 // Creates an iterator to fetch all GDataEntry's under |path|. | 52 // Creates an iterator to fetch all GDataEntry's under |path|. |
| 47 // Will not return NULL. | 53 // Will not return NULL. |
| 48 virtual scoped_ptr<GDataDBIter> CreateIterator(const FilePath& path) = 0; | 54 virtual scoped_ptr<GDataDBIter> CreateIterator(const FilePath& path) = 0; |
| 49 | 55 |
| 56 // Puts raw |protobuf| keyed with |resource_id| to the database. | |
| 57 // Used for testing (ex. injecting incompatibe proto). | |
| 58 virtual Status PutRawForTesting( | |
| 59 const std::string& resource_id, | |
| 60 const google::protobuf::MessageLite& protobuf) = 0; | |
|
achuithb
2012/07/10 17:21:19
Any reason why we don't just pass in a string as t
satorux1
2012/07/10 17:28:35
Good idea. Done.
| |
| 61 | |
| 50 protected: | 62 protected: |
| 51 GDataDB() {} | 63 GDataDB() {} |
| 52 }; | 64 }; |
| 53 | 65 |
| 54 // GData Database Iterator interface class. | 66 // GData Database Iterator interface class. |
| 55 class GDataDBIter { | 67 class GDataDBIter { |
| 56 public: | 68 public: |
| 57 virtual ~GDataDBIter() {} | 69 virtual ~GDataDBIter() {} |
| 58 | 70 |
| 59 // Fetches the next |entry| in the iteration sequence. Returns false when | 71 // Fetches the next |entry| in the iteration sequence. Returns false when |
| 60 // there are no more entries. | 72 // there are no more entries. |
| 61 virtual bool GetNext(std::string* path, scoped_ptr<GDataEntry>* entry) = 0; | 73 virtual bool GetNext(std::string* path, scoped_ptr<GDataEntry>* entry) = 0; |
| 62 | 74 |
| 63 protected: | 75 protected: |
| 64 GDataDBIter() {} | 76 GDataDBIter() {} |
| 65 }; | 77 }; |
| 66 | 78 |
| 67 } // namespace gdata | 79 } // namespace gdata |
| 68 | 80 |
| 69 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_DB_H_ | 81 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_DB_H_ |
| OLD | NEW |