ozone: fix HDPMLegacy - do the PF after overlays, also clear old overlays
[chromium-blink-merge.git] / components / enhanced_bookmarks / image_store.h
blobf4c63fa7c7194f665557b28ebcf2de3e65f6cac8
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.
5 #ifndef COMPONENTS_ENHANCED_BOOKMARKS_IMAGE_STORE_H_
6 #define COMPONENTS_ENHANCED_BOOKMARKS_IMAGE_STORE_H_
8 #include <set>
10 #include "base/sequence_checker.h"
11 #include "components/enhanced_bookmarks/image_record.h"
12 #include "ui/gfx/geometry/size.h"
14 class GURL;
16 // The ImageStore keeps an image for each URL. This class is not thread safe,
17 // and will check the thread using base::ThreadChecker, except the constructor.
18 class ImageStore {
19 public:
20 ImageStore();
21 virtual ~ImageStore();
23 // Returns true if there is an image for this url.
24 virtual bool HasKey(const GURL& page_url) = 0;
26 // Inserts an ImageRecord in the store for the given page url. The image can
27 // be null indicating that the download of the image at this URL or
28 // encoding for insertion failed previously. On non-iOS platforms, |image|
29 // must have exactly one representation with a scale factor of 1.
30 virtual void Insert(const GURL& page_url,
31 const enhanced_bookmarks::ImageRecord& image_record) = 0;
33 // Removes an image from the store.
34 virtual void Erase(const GURL& page_url) = 0;
36 // Returns the image associated with this url. Returns an ImageRecord with an
37 // empty image if there is no image for this url. It also returns the
38 // image_url where the image was downloaded from or failed to be downloaded
39 // from. When the image is not empty, the dominant color of the image is also
40 // filled.
41 virtual enhanced_bookmarks::ImageRecord Get(const GURL& page_url) = 0;
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;
47 // Populates |urls| with all the urls that have an image in the store.
48 virtual void GetAllPageUrls(std::set<GURL>* urls) = 0;
50 // Removes all images.
51 virtual void ClearAll() = 0;
53 // Moves an image from one url to another.
54 void ChangeImageURL(const GURL& from, const GURL& to);
56 // Returns the saved images storage size in bytes. If the storage doesn't
57 // exist yet or failed to read, returns -1.
58 virtual int64 GetStoreSizeInBytes() = 0;
60 protected:
61 base::SequenceChecker sequence_checker_;
63 private:
64 DISALLOW_COPY_AND_ASSIGN(ImageStore);
67 #endif // COMPONENTS_ENHANCED_BOOKMARKS_IMAGE_STORE_H_