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