Index: content/renderer/image_downloader/single_image_downloader.h |
diff --git a/content/renderer/image_downloader/single_image_downloader.h b/content/renderer/image_downloader/single_image_downloader.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1b8820681cadb0c40679e8a6d61f6781c311114f |
--- /dev/null |
+++ b/content/renderer/image_downloader/single_image_downloader.h |
@@ -0,0 +1,41 @@ |
+// Copyright 2016 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 CONTENT_RENDERER_IMAGE_DOWNLOADER_SINGLE_IMAGE_DOWNLOADER_H_ |
+#define CONTENT_RENDERER_IMAGE_DOWNLOADER_SINGLE_IMAGE_DOWNLOADER_H_ |
+ |
+#include "base/memory/weak_ptr.h" |
+#include "content/renderer/image_downloader/image_downloader_base.h" |
+ |
+namespace content { |
+ |
+// A one time image downloader that will download a single image. When there are |
+// multiple frames, return the first one. Return an empty bitmap if downloading |
nasko
2017/01/04 17:45:33
nit: Returns
May be worthwhile mentioning that thi
xjz
2017/01/04 18:37:58
Done.
|
+// fails. |
+class SingleImageDownloader { |
+ public: |
+ using DownloadImageCallback = base::Callback<void(const SkBitmap&)>; |
+ |
+ // Called to download the image in given |url|, and run |cb| when done. |
+ // A new ImageDownloaderBase will be created and used to download the image, |
+ // and will be destructed when downloading finishes or |render_frame| is |
+ // destructed. |
+ static void DownloadImage(base::WeakPtr<RenderFrame> render_frame, |
+ const GURL& url, |
+ const DownloadImageCallback& cb); |
+ |
+ private: |
+ // Callback when downloading finishes. |
+ static void DidDownloadImage( |
+ std::unique_ptr<ImageDownloaderBase> image_downloader, |
+ const DownloadImageCallback& callback, |
+ int http_status_code, |
+ const std::vector<SkBitmap>& images); |
+ |
+ DISALLOW_COPY_AND_ASSIGN(SingleImageDownloader); |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_RENDERER_IMAGE_DOWNLOADER_SINGLE_IMAGE_DOWNLOADER_H_ |