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

Unified Diff: components/suggestions/image_manager.h

Issue 1156003008: Decode ImageManager cached images on demand. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Include stddef to get size_t Created 5 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/suggestions/image_manager.h
diff --git a/components/suggestions/image_manager.h b/components/suggestions/image_manager.h
index 99ae55e1a34c54a43751a4c6a27f01dff1093417..bc06d5a2df3e7a3937a209aefe7f7e1d34f0e1d3 100644
--- a/components/suggestions/image_manager.h
+++ b/components/suggestions/image_manager.h
@@ -12,6 +12,7 @@
#include "base/basictypes.h"
#include "base/callback.h"
#include "base/containers/hash_tables.h"
+#include "base/memory/ref_counted_memory.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/threading/thread_checker.h"
@@ -66,7 +67,8 @@ class ImageManager : public ImageFetcherDelegate {
typedef std::vector<base::Callback<void(const GURL&, const SkBitmap*)> >
CallbackVector;
- typedef base::hash_map<std::string, SkBitmap> ImageMap;
+ typedef base::hash_map<std::string, scoped_refptr<base::RefCountedMemory> >
+ ImageMap;
// State related to an image fetch (associated website url, image_url,
// pending callbacks).
@@ -95,14 +97,14 @@ class ImageManager : public ImageFetcherDelegate {
const GURL& url, const GURL& image_url,
base::Callback<void(const GURL&, const SkBitmap*)> callback);
- // Will return false if no bitmap was found corresponding to |url|, else
- // return true and call |callback| with the found bitmap.
- bool ServeFromCache(
- const GURL& url,
- base::Callback<void(const GURL&, const SkBitmap*)> callback);
+ void OnCacheImageDecoded(
+ const GURL& url, const GURL& image_url,
+ base::Callback<void(const GURL&, const SkBitmap*)> callback,
+ scoped_ptr<SkBitmap> bitmap);
// Returns null if the |url| had no entry in the cache.
- SkBitmap* GetBitmapFromCache(const GURL& url);
+ scoped_refptr<base::RefCountedMemory> GetEncodedImageFromCache(
+ const GURL& url);
// Save the image bitmap in the cache and in the database.
void SaveImage(const GURL& url, const SkBitmap& bitmap);

Powered by Google App Engine
This is Rietveld 408576698