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_DB_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_DB_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <string> |
| 10 |
| 11 #include "base/memory/scoped_ptr.h" |
| 12 |
| 13 class FilePath; |
| 14 |
| 15 namespace gdata { |
| 16 |
| 17 class GDataEntry; |
| 18 class GDataDBIter; |
| 19 |
| 20 // GData Database interface class. |
| 21 class GDataDB { |
| 22 public: |
| 23 enum Status { |
| 24 DB_OK = 0, |
| 25 DB_KEY_NOT_FOUND, // Key not found. |
| 26 DB_CORRUPTION, // Database file corrupt. |
| 27 DB_IO_ERROR, // File I/O error. |
| 28 DB_INTERNAL_ERROR, |
| 29 }; |
| 30 |
| 31 virtual ~GDataDB() {} |
| 32 |
| 33 // Puts |entry| to the database. |
| 34 virtual Status Put(const GDataEntry& entry) = 0; |
| 35 |
| 36 // Deletes a database entry with key |resource_id| or |path| respectively. |
| 37 virtual Status DeleteByResourceId(const std::string& resource_id) = 0; |
| 38 virtual Status DeleteByPath(const FilePath& path) = 0; |
| 39 |
| 40 // Fetches a GDataEntry* by key |resource_id| or |path| respectively. |
| 41 virtual Status GetByResourceId(const std::string& resource_id, |
| 42 scoped_ptr<GDataEntry>* entry) = 0; |
| 43 virtual Status GetByPath(const FilePath& path, |
| 44 scoped_ptr<GDataEntry>* entry) = 0; |
| 45 |
| 46 // Creates an iterator to fetch all GDataEntry's under |path|. |
| 47 // Will not return NULL. |
| 48 virtual scoped_ptr<GDataDBIter> CreateIterator(const FilePath& path) = 0; |
| 49 |
| 50 protected: |
| 51 GDataDB() {} |
| 52 }; |
| 53 |
| 54 // GData Database Iterator interface class. |
| 55 class GDataDBIter { |
| 56 public: |
| 57 virtual ~GDataDBIter() {} |
| 58 |
| 59 // Fetches the next |entry| in the iteration sequence. Returns false when |
| 60 // there are no more entries. |
| 61 virtual bool GetNext(std::string* path, scoped_ptr<GDataEntry>* entry) = 0; |
| 62 |
| 63 protected: |
| 64 GDataDBIter() {} |
| 65 }; |
| 66 |
| 67 } // namespace gdata |
| 68 |
| 69 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_DB_H_ |
OLD | NEW |