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

Unified Diff: content/renderer/image_downloader/single_image_downloader.h

Issue 2538853002: Media Remoting: Draw remoting interstitial on poster image. (Closed)
Patch Set: Addressed nasko's comments. Created 3 years, 11 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: 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..bc28c9129ce37c0e57739acc2151ffb9f02e28c9
--- /dev/null
+++ b/content/renderer/image_downloader/single_image_downloader.h
@@ -0,0 +1,43 @@
+// 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, returns the first one. Returns an empty bitmap if
+// downloading fails. This class does not impose size limitation on the image.
+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. |image_downloader| is passed in as a
+ // unique_ptr to keep it alive while downloading and destroy it after this
+ // callback is called.
+ 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_

Powered by Google App Engine
This is Rietveld 408576698