Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(397)

Unified Diff: components/bookmarks_enhanced/image_store.h

Issue 259863007: Local salient image storage for enhanced bookmark experiment. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changed from NonThreadSafe to ThreadChecker Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/bookmarks_enhanced/image_store.h
diff --git a/components/bookmarks_enhanced/image_store.h b/components/bookmarks_enhanced/image_store.h
new file mode 100644
index 0000000000000000000000000000000000000000..2b77699e4785c4286899ef034ef412b51125143b
--- /dev/null
+++ b/components/bookmarks_enhanced/image_store.h
@@ -0,0 +1,63 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_BOOKMARKS_ENHANCED_IMAGE_STORE_H_
+#define COMPONENTS_BOOKMARKS_ENHANCED_IMAGE_STORE_H_
+
+#include <map>
+#include <vector>
+
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/threading/thread_checker.h"
+#include "ui/gfx/image/image.h"
+
+class GURL;
+
+// 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.
+class ImageStore : public base::RefCounted<ImageStore> {
+ public:
+ ImageStore();
+
+ // Returns true if there is an image for this url.
+ virtual bool HasKey(const GURL& page_url) = 0;
+
+ // Inserts an image and its url in the store for the the given page url. The
+ // image can be null indicating that the download of the image at this URL
+ // failed previously.
+ virtual void Insert(const GURL& page_url,
+ const GURL& image_url,
+ const gfx::Image& image) = 0;
+
+ // Removes an image from the store.
+ virtual void Erase(const GURL& page_url) = 0;
+
+ // Returns the image associated with this url. Returns nil if there are no
+ // image for this url. It also returns the image_url where the image was
+ // downloaded from or failed to be downloaded from.
+ 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.
+
+ // Returns the size of the image stored for this URL or empty size if no
+ // images are present.
+ virtual gfx::Size GetSize(const GURL& page_url) = 0;
+
+ // 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.
+ 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.
+
+ // Moves an image from one url to another.
+ virtual void ChangeImageURL(const GURL& from, const GURL& to);
+
+ // Removes all images.
+ void ClearAll();
+
+ protected:
+ virtual ~ImageStore();
+
+ base::ThreadChecker thread_checker_;
+
+ private:
+ friend class base::RefCounted<ImageStore>;
+};
+
+#endif // COMPONENTS_BOOKMARKS_ENHANCED_IMAGE_STORE_H_

Powered by Google App Engine
This is Rietveld 408576698