| 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/file_path.h" |
| 12 #include "base/memory/scoped_ptr.h" |
| 13 |
| 14 namespace gdata { |
| 15 |
| 16 class GDataEntry; |
| 17 class GDataDBIter; |
| 18 |
| 19 class GDataDB { |
| 20 public: |
| 21 enum Status { |
| 22 DB_OK = 0, |
| 23 DB_NOT_FOUND, |
| 24 DB_ERR, |
| 25 }; |
| 26 |
| 27 virtual ~GDataDB() {} |
| 28 |
| 29 // Factory method to create a GDataDB instance at |db_path| |
| 30 static scoped_ptr<GDataDB> Create(const FilePath& db_path); |
| 31 |
| 32 // Add |entry| to the database. |
| 33 virtual Status Put(const GDataEntry& entry) = 0; |
| 34 |
| 35 // Delete a database entry with key |resource_id| or |path| respectively. |
| 36 virtual Status DeleteByResourceId(const std::string& resource_id) = 0; |
| 37 virtual Status DeleteByPath(const std::string& path) = 0; |
| 38 |
| 39 // Fetch a GDataEntry* by key |resource_id| or |path| respectively. |
| 40 virtual Status GetByResourceId(const std::string& resource_id, |
| 41 scoped_ptr<GDataEntry>* entry) = 0; |
| 42 virtual Status GetByPath(const std::string& path, |
| 43 scoped_ptr<GDataEntry>* entry) = 0; |
| 44 |
| 45 // An iterator to fetch all GDataEntry's under |path| |
| 46 virtual scoped_ptr<GDataDBIter> NewIterator(const std::string& path) = 0; |
| 47 |
| 48 protected: |
| 49 GDataDB() {} |
| 50 |
| 51 DISALLOW_COPY_AND_ASSIGN(GDataDB); |
| 52 }; |
| 53 |
| 54 class GDataDBIter { |
| 55 public: |
| 56 virtual ~GDataDBIter() {} |
| 57 |
| 58 virtual GDataEntry* GetNext() = 0; |
| 59 |
| 60 protected: |
| 61 friend class GDataDB; |
| 62 }; |
| 63 |
| 64 } // namespace gdata |
| 65 |
| 66 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_DB_H_ |
| OLD | NEW |