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

Side by Side Diff: content/renderer/image_downloader/single_image_downloader.h

Issue 2538853002: Media Remoting: Draw remoting interstitial on poster image. (Closed)
Patch Set: Addressed comments. 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_RENDERER_IMAGE_DOWNLOADER_SINGLE_IMAGE_DOWNLOADER_H_
6 #define CONTENT_RENDERER_IMAGE_DOWNLOADER_SINGLE_IMAGE_DOWNLOADER_H_
7
8 #include "base/callback.h"
9 #include "base/memory/weak_ptr.h"
10 #include "content/public/renderer/render_frame_observer.h"
11 #include "content/renderer/image_downloader/image_downloader_core.h"
12 #include "third_party/skia/include/core/SkBitmap.h"
13 #include "url/gurl.h"
14
15 namespace content {
16
17 class ImageDownloaderCore;
18 class RenderFrame;
19
20 // A one time image downloader that will be self-destructed when downloading
21 // finishes or the |render_frame| is destructed. When there are multiple frames,
22 // return the first one.
23 class SingleImageDownloader : public RenderFrameObserver {
24 public:
25 using DownloadImageCallback = base::Callback<void(const SkBitmap&)>;
26
27 // Called to download the image in given |url|, and run |cb| when done.
28 // A new SingleImageDownloader will be created, and be self-destructed when
29 // downloading finishes or |render_frame| is destructed.
30 static void DownloadImage(const base::WeakPtr<RenderFrame>& render_frame,
31 const GURL& url,
32 const DownloadImageCallback& cb);
33
34 ~SingleImageDownloader() override;
35
36 private:
37 SingleImageDownloader(RenderFrame* render_frame,
38 const GURL& url,
39 bool is_favicon,
40 bool bypass_cache,
41 const DownloadImageCallback& callback);
42
43 // RenderFrameObserver implementation.
44 void OnDestruct() override;
45
46 // Called by |image_downloader_| when downloading finishes.
47 void DidDownloadImage(const DownloadImageCallback& callback,
48 int http_status_code,
49 const std::vector<SkBitmap>& images);
50
51 ImageDownloaderCore image_downloader_;
52
53 DISALLOW_COPY_AND_ASSIGN(SingleImageDownloader);
54 };
55
56 } // namespace content
57
58 #endif // CONTENT_RENDERER_IMAGE_DOWNLOADER_SINGLE_IMAGE_DOWNLOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698