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_BOOKMARKS_ENHANCED_IMAGE_STORE_H_ | |
| 6 #define COMPONENTS_BOOKMARKS_ENHANCED_IMAGE_STORE_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 #include <vector> | |
| 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. | |
|
sky
2014/05/06 16:14:20
Document thread expectations.
Kibeom Kim (inactive)
2014/05/07 00:09:46
Done.
| |
| 19 class ImageStore : public base::RefCounted<ImageStore> { | |
| 20 public: | |
| 21 ImageStore(); | |
| 22 | |
| 23 // Returns true if there is an image for this url. | |
| 24 virtual bool HasKey(const GURL& page_url) = 0; | |
| 25 | |
| 26 // Inserts an image and its url in the store for the the given page url. The | |
| 27 // image can be null indicating that the download of the image at this URL | |
| 28 // failed previously. | |
| 29 virtual void Insert(const GURL& page_url, | |
| 30 const GURL& image_url, | |
| 31 const gfx::Image& image) = 0; | |
| 32 | |
| 33 // Removes an image from the store. | |
| 34 virtual void Erase(const GURL& page_url) = 0; | |
| 35 | |
| 36 // Returns the image associated with this url. Returns nil if there are no | |
| 37 // image for this url. It also returns the image_url where the image was | |
| 38 // downloaded from or failed to be downloaded from. | |
| 39 virtual gfx::Image Get(const GURL& page_url, GURL* image_url) = 0; | |
|
sky
2014/05/06 16:14:20
Wouldn't it be easier to make this return a std::P
Kibeom Kim (inactive)
2014/05/07 00:09:46
Done.
| |
| 40 | |
| 41 // Returns the size of the image stored for this URL or empty size if no | |
| 42 // images are present. | |
| 43 virtual gfx::Size GetSize(const GURL& page_url) = 0; | |
| 44 | |
| 45 // Populates |url| with all the urls that have an image in the store. | |
|
sky
2014/05/06 16:14:20
nit: |url|->|urls| and you've got two spaces after
Kibeom Kim (inactive)
2014/05/07 00:09:46
Done.
| |
| 46 virtual void GetAllPageUrls(std::vector<GURL>* urls) = 0; | |
|
sky
2014/05/06 16:14:20
vector->set
Kibeom Kim (inactive)
2014/05/07 00:09:46
Done.
| |
| 47 | |
| 48 // Moves an image from one url to another. | |
| 49 virtual void ChangeImageURL(const GURL& from, const GURL& to); | |
| 50 | |
| 51 // Removes all images. | |
| 52 void ClearAll(); | |
| 53 | |
| 54 protected: | |
| 55 virtual ~ImageStore(); | |
| 56 | |
| 57 base::ThreadChecker thread_checker_; | |
| 58 | |
| 59 private: | |
| 60 friend class base::RefCounted<ImageStore>; | |
| 61 }; | |
| 62 | |
| 63 #endif // COMPONENTS_BOOKMARKS_ENHANCED_IMAGE_STORE_H_ | |
| OLD | NEW |