Index: components/bookmarks/core/browser/enhanced/image_store.h |
diff --git a/components/bookmarks/core/browser/enhanced/image_store.h b/components/bookmarks/core/browser/enhanced/image_store.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..8a08b7baa4ddc2cae010eae74439db4ee588b336 |
--- /dev/null |
+++ b/components/bookmarks/core/browser/enhanced/image_store.h |
@@ -0,0 +1,71 @@ |
+// 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_CORE_BROWSER_ENHANCED_IMAGE_STORE_H_ |
+#define COMPONENTS_BOOKMARKS_CORE_BROWSER_ENHANCED_IMAGE_STORE_H_ |
+ |
+#include <map> |
+#include <vector> |
+ |
+#include "base/memory/ref_counted.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "base/threading/platform_thread.h" |
+#include "ui/gfx/image/image.h" |
+ |
+class GURL; |
+ |
+// The ImageStore keeps an image for each URL. |
+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; |
+ |
+ // 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. |
+ virtual void GetAllPageUrls(std::vector<GURL>* urls) = 0; |
+ |
+ // 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(); |
+ |
+#if defined(DCHECK_IS_ON) |
+ // At first call, it saves the current thread id to |running_thread_id_|. On |
+ // subsequent calls, check if the current thread id is identical to |
+ // |running_thread_id_|. Return false if calling thread id is different from |
+ // previous threads. |
+ bool IsRunningThreadConsistent(); |
noyau (Ping after 24h)
2014/05/04 17:27:12
Couldn't you use base::NonThreadSafe instead?
Kibeom Kim (inactive)
2014/05/05 17:35:47
Done. (didn't know NonThreadSafe, thanks!)
|
+ |
+ scoped_ptr<base::PlatformThreadId> running_thread_id_; |
+#endif |
+ |
+ private: |
+ friend class base::RefCounted<ImageStore>; |
+}; |
+ |
+#endif // COMPONENTS_BOOKMARKS_CORE_BROWSER_ENHANCED_IMAGE_STORE_H_ |