OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef COMPONENTS_BOOKMARKS_ENHANCED_IMAGE_STORE_H_ | |
6 #define COMPONENTS_BOOKMARKS_ENHANCED_IMAGE_STORE_H_ | |
7 | |
8 #include <map> | |
9 #include <set> | |
10 | |
11 #include "base/memory/ref_counted.h" | |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "base/threading/thread_checker.h" | |
14 #include "ui/gfx/image/image.h" | |
15 | |
16 class GURL; | |
17 | |
18 // The ImageStore keeps an image for each URL. This class is not thread safe, | |
19 // and will check the thread using base::ThreadChecker, except the constructor. | |
20 class ImageStore : public base::RefCounted<ImageStore> { | |
21 public: | |
22 ImageStore(); | |
23 | |
24 // Returns true if there is an image for this url. | |
25 virtual bool HasKey(const GURL& page_url) = 0; | |
26 | |
27 // Inserts an image and its url in the store for the the given page url. The | |
28 // image can be null indicating that the download of the image at this URL or | |
29 // encoding for insertion failed previously. On non-ios platforms, |image| | |
30 // must have exactly one representation with a scale factor of 1. | |
31 virtual void Insert(const GURL& page_url, | |
32 const GURL& image_url, | |
33 const gfx::Image& image) = 0; | |
34 | |
35 // Removes an image from the store. | |
36 virtual void Erase(const GURL& page_url) = 0; | |
37 | |
38 // Returns the image associated with this url. Returns nil if there are no | |
sky
2014/05/08 15:33:08
nil->empty image? empty url?
Kibeom Kim (inactive)
2014/05/08 17:56:33
Done.
| |
39 // image for this url. It also returns the image_url where the image was | |
40 // downloaded from or failed to be downloaded from. | |
41 virtual std::pair<gfx::Image, GURL> Get(const GURL& page_url) = 0; | |
42 | |
43 // Returns the size of the image stored for this URL or empty size if no | |
44 // images are present. | |
45 virtual gfx::Size GetSize(const GURL& page_url) = 0; | |
46 | |
47 // Populates |urls| with all the urls that have an image in the store. | |
48 virtual void GetAllPageUrls(std::set<GURL>* urls) = 0; | |
49 | |
50 // Moves an image from one url to another. | |
51 void ChangeImageURL(const GURL& from, const GURL& to); | |
52 | |
53 // Removes all images. | |
54 void ClearAll(); | |
sky
2014/05/08 15:33:08
I think this should remain pure virtual. In partic
Kibeom Kim (inactive)
2014/05/08 17:56:33
Done. (Also added ClearAll unittest)
| |
55 | |
56 protected: | |
57 virtual ~ImageStore(); | |
58 | |
59 base::ThreadChecker thread_checker_; | |
60 | |
61 private: | |
62 friend class base::RefCounted<ImageStore>; | |
63 }; | |
64 | |
65 #endif // COMPONENTS_BOOKMARKS_ENHANCED_IMAGE_STORE_H_ | |
OLD | NEW |