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

Unified Diff: chrome/browser/bitmap_fetcher/bitmap_batch_fetcher.h

Issue 931993002: Make image_decoder a Leaky LazyInstance (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix a couple more build issues Created 5 years, 10 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: chrome/browser/bitmap_fetcher/bitmap_batch_fetcher.h
diff --git a/chrome/browser/bitmap_fetcher/bitmap_batch_fetcher.h b/chrome/browser/bitmap_fetcher/bitmap_batch_fetcher.h
new file mode 100644
index 0000000000000000000000000000000000000000..351d6d4ce56c3bcfd806b3bdf9910821a246bced
--- /dev/null
+++ b/chrome/browser/bitmap_fetcher/bitmap_batch_fetcher.h
@@ -0,0 +1,87 @@
+// Copyright 2015 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 CHROME_BROWSER_BITMAP_FETCHER_BITMAP_BATCH_FETCHER_H_
+#define CHROME_BROWSER_BITMAP_FETCHER_BITMAP_BATCH_FETCHER_H_
+
+#include "base/memory/scoped_ptr.h"
+#include "chrome/browser/bitmap_fetcher/bitmap_fetcher_delegate.h"
+#include "chrome/browser/image_batch_decoder.h"
+#include "content/public/browser/browser_thread.h"
+#include "net/url_request/url_fetcher_delegate.h"
+#include "net/url_request/url_request.h"
+#include "third_party/skia/include/core/SkBitmap.h"
+#include "url/gurl.h"
+
+namespace net {
+class URLFetcher;
+class URLRequestContextGetter;
+} // namespace net
+
+namespace chrome {
+
+// Asynchrounously fetches images from the URLs provided in calls to ::Start
+// and returns the decoded Bitmaps to the provided BitmapFetcherDelegate.
+class BitmapBatchFetcher : public net::URLFetcherDelegate {
+ public:
+ BitmapBatchFetcher();
+
+ ~BitmapBatchFetcher() override;
+
+ // Start fetching the URL. The delegate is notified asynchronously when done.
+ // Arguments are used to configure the internal fetcher.
+ // Values for |load_flags| are defined in net/base/load_flags.h. In general,
+ // |net::LOAD_NORMAL| is appropriate.
+ void Start(net::URLRequestContextGetter* request_context,
+ const std::string& referrer,
+ net::URLRequest::ReferrerPolicy referrer_policy,
+ int load_flags,
+ const GURL& url,
+ BitmapFetcherDelegate* delegate);
+
+ // Methods inherited from URLFetcherDelegate
+
+ // This will be called when the URL has been fetched, successfully or not.
+ // Use accessor methods on |source| to get the results.
+ void OnURLFetchComplete(const net::URLFetcher* source) override;
+
+ // This will be called when some part of the response is read. |current|
+ // denotes the number of bytes received up to the call, and |total| is the
+ // expected total size of the response (or -1 if not determined).
+ void OnURLFetchDownloadProgress(const net::URLFetcher* source,
+ int64 current,
+ int64 total) override;
+
+ private:
+ scoped_refptr<ImageBatchDecoder> image_batch_decoder_;
+ std::map<const net::URLFetcher*, std::pair<GURL, BitmapFetcherDelegate*>>
+ url_fetcher_map_;
+
+ class Delegate : public ImageBatchDecoder::Delegate {
+ public:
+ Delegate(const GURL& url, BitmapFetcherDelegate* delegate)
+ : url_(url), delegate_(delegate) {}
+
+ // Methods inherited from ImageBatchDecoder::Delegate
+
+ // Called when image is decoded. |decoder| is used to identify the image in
+ // case of decoding several images simultaneously. This will not be called
+ // on the UI thread.
+ void OnImageDecoded(const ImageBatchDecoder* decoder,
+ const SkBitmap& decoded_image) override;
+
+ // Called when decoding image failed.
+ void OnDecodeImageFailed(const ImageBatchDecoder* decoder) override;
+
+ private:
+ const GURL url_;
+ BitmapFetcherDelegate* delegate_;
+ };
+
+ DISALLOW_COPY_AND_ASSIGN(BitmapBatchFetcher);
+};
+
+} // namespace chrome
+
+#endif // CHROME_BROWSER_BITMAP_FETCHER_BITMAP_BATCH_FETCHER_H_
« no previous file with comments | « no previous file | chrome/browser/bitmap_fetcher/bitmap_batch_fetcher.cc » ('j') | chrome/browser/bitmap_fetcher/bitmap_fetcher.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698