OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_ENHANCED_BOOKMARKS_PERSISTENT_IMAGE_STORE_H_ | 5 #ifndef COMPONENTS_ENHANCED_BOOKMARKS_PERSISTENT_IMAGE_STORE_H_ |
6 #define COMPONENTS_ENHANCED_BOOKMARKS_PERSISTENT_IMAGE_STORE_H_ | 6 #define COMPONENTS_ENHANCED_BOOKMARKS_PERSISTENT_IMAGE_STORE_H_ |
7 | 7 |
8 #include "components/enhanced_bookmarks/image_store.h" | 8 #include "components/enhanced_bookmarks/image_store.h" |
9 | 9 |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "sql/connection.h" | 11 #include "sql/connection.h" |
12 #include "sql/init_status.h" | 12 #include "sql/init_status.h" |
13 #include "sql/meta_table.h" | 13 #include "sql/meta_table.h" |
14 | 14 |
15 // The PersistentImageStore is an implementation of ImageStore that persists its | 15 // The PersistentImageStore is an implementation of ImageStore that persists its |
16 // data on disk. | 16 // data on disk. |
17 class PersistentImageStore : public ImageStore { | 17 class PersistentImageStore : public ImageStore { |
18 public: | 18 public: |
19 // Creates a PersistentImageStore in the directory at the given path. | 19 // Creates a PersistentImageStore in the directory at the given path. |
20 explicit PersistentImageStore(const base::FilePath& path); | 20 explicit PersistentImageStore(const base::FilePath& path); |
21 bool HasKey(const GURL& page_url) override; | 21 bool HasKey(const GURL& page_url) override; |
22 void Insert(const GURL& page_url, | 22 void Insert(const GURL& page_url, |
23 const enhanced_bookmarks::ImageRecord& image) override; | 23 scoped_refptr<enhanced_bookmarks::ImageRecord> image) override; |
24 void Erase(const GURL& page_url) override; | 24 void Erase(const GURL& page_url) override; |
25 enhanced_bookmarks::ImageRecord Get(const GURL& page_url) override; | 25 scoped_refptr<enhanced_bookmarks::ImageRecord> Get( |
| 26 const GURL& page_url) override; |
26 gfx::Size GetSize(const GURL& page_url) override; | 27 gfx::Size GetSize(const GURL& page_url) override; |
27 void GetAllPageUrls(std::set<GURL>* urls) override; | 28 void GetAllPageUrls(std::set<GURL>* urls) override; |
28 void ClearAll() override; | 29 void ClearAll() override; |
29 int64 GetStoreSizeInBytes() override; | 30 int64 GetStoreSizeInBytes() override; |
30 | 31 |
31 protected: | 32 protected: |
32 ~PersistentImageStore() override; | 33 ~PersistentImageStore() override; |
33 | 34 |
34 private: | 35 private: |
35 sql::InitStatus OpenDatabase(); | 36 sql::InitStatus OpenDatabase(); |
36 | 37 |
37 const base::FilePath path_; | 38 const base::FilePath path_; |
38 sql::Connection db_; | 39 sql::Connection db_; |
39 sql::MetaTable meta_table_; | 40 sql::MetaTable meta_table_; |
40 | 41 |
41 DISALLOW_COPY_AND_ASSIGN(PersistentImageStore); | 42 DISALLOW_COPY_AND_ASSIGN(PersistentImageStore); |
42 }; | 43 }; |
43 | 44 |
44 #endif // COMPONENTS_ENHANCED_BOOKMARKS_PERSISTENT_IMAGE_STORE_H_ | 45 #endif // COMPONENTS_ENHANCED_BOOKMARKS_PERSISTENT_IMAGE_STORE_H_ |
OLD | NEW |