Chromium Code Reviews| 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_ENHANCED_BOOKMARKS_IMAGE_STORE_H_ | |
| 6 #define COMPONENTS_ENHANCED_BOOKMARKS_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 empty image and url if | |
| 39 // there are no image for this url. It also returns the image_url where the | |
| 40 // image was 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 // Removes all images. | |
| 51 virtual void ClearAll() = 0; | |
| 52 | |
| 53 // Moves an image from one url to another. | |
| 54 void ChangeImageURL(const GURL& from, const GURL& to); | |
| 55 | |
| 56 protected: | |
| 57 virtual ~ImageStore(); | |
| 58 | |
| 59 base::ThreadChecker thread_checker_; | |
| 60 | |
| 61 private: | |
| 62 friend class base::RefCounted<ImageStore>; | |
| 63 }; | |
|
jar (doing other things)
2014/05/10 00:07:08
nit: DISALLOW_COPY_AND_ASSIGN (...or is there a
Kibeom Kim (inactive)
2014/05/10 00:14:52
Done.
| |
| 64 | |
| 65 #endif // COMPONENTS_ENHANCED_BOOKMARKS_IMAGE_STORE_H_ | |
| OLD | NEW |