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

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

Issue 2538853002: Media Remoting: Draw remoting interstitial on poster image. (Closed)
Patch Set: Use base::<Optional> to tell that the background is unchanged. Created 4 years 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.cc
diff --git a/content/renderer/image_downloader/single_image_downloader.cc b/content/renderer/image_downloader/single_image_downloader.cc
new file mode 100644
index 0000000000000000000000000000000000000000..760b214872016bccb51775085c30bb3375dc9027
--- /dev/null
+++ b/content/renderer/image_downloader/single_image_downloader.cc
@@ -0,0 +1,41 @@
+// 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.
+
+#include "content/renderer/image_downloader/single_image_downloader.h"
+
+#include "base/bind.h"
+#include "base/logging.h"
+
+namespace content {
+
+// Static
+void SingleImageDownloader::DownloadImage(
+ base::WeakPtr<RenderFrame> render_frame,
+ const GURL& url,
+ const DownloadImageCallback& cb) {
+ DCHECK(!cb.is_null());
+ if (!render_frame) {
+ cb.Run(SkBitmap());
+ return;
+ }
+
+ std::unique_ptr<ImageDownloaderBase> image_downloader(
+ new ImageDownloaderBase(render_frame.get()));
+ ImageDownloaderBase* image_downloader_ptr = image_downloader.get();
+ image_downloader_ptr->DownloadImage(
+ url, false, false, base::Bind(&SingleImageDownloader::DidDownloadImage,
+ base::Passed(&image_downloader), cb));
+}
+
+// Static
+void SingleImageDownloader::DidDownloadImage(
+ std::unique_ptr<ImageDownloaderBase> image_downloader,
nasko 2017/01/04 17:45:33 nit: Maybe put a comment as to why image_download
xjz 2017/01/04 18:37:58 Done. Yes, this is to keep it alive while download
+ const DownloadImageCallback& callback,
+ int http_status_code,
+ const std::vector<SkBitmap>& images) {
+ DCHECK(!callback.is_null());
+ callback.Run(images.empty() ? SkBitmap() : images[0]);
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698