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

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

Issue 1085783002: Replace image_messages.h with Mojo service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase to master@{#333882} Created 5 years, 6 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 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_IMAGE_DOWNLOADER_IMPL_H_
6 #define CONTENT_IMAGE_DOWNLOADER_IMPL_H_
7
8 #include <vector>
9
10 #include "base/memory/scoped_vector.h"
11 #include "content/common/image_downloader/image_downloader.mojom.h"
12 #include "content/public/renderer/render_frame_observer.h"
13 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h"
14 #include "url/gurl.h"
15
16 class SkBitmap;
17
18 namespace gfx {
19 class Size;
20 }
21
22 namespace content {
23
24 class MultiResolutionImageResourceFetcher;
25 class RenderFrame;
26
27 class ImageDownloaderImpl : public image_downloader::ImageDownloader,
28 public RenderFrameObserver {
29 public:
30 static void CreateMojoService(
31 RenderFrame* render_frame,
32 mojo::InterfaceRequest<image_downloader::ImageDownloader> request);
33
34 private:
35 explicit ImageDownloaderImpl(
36 RenderFrame* render_frame,
37 mojo::InterfaceRequest<image_downloader::ImageDownloader> request);
38 ~ImageDownloaderImpl() override;
39
40 // ImageDownloader methods:
41 void DownloadImage(image_downloader::DownloadRequestPtr req,
42 const DownloadImageCallback& callback) override;
43
44 // Requests to fetch an image. When done, the ImageDownloaderImpl
45 // is notified by way of DidFetchImage. Returns true if the
46 // request was successfully started, false otherwise.
47 // If the image is a favicon, cookies will not be
48 // sent nor accepted during download. If the image has multiple frames, all
49 // the frames whose size <= |max_image_size| are returned. If all of the
50 // frames are larger than |max_image_size|, the smallest frame is resized to
51 // |max_image_size| and is the only result. |max_image_size| == 0 is
52 // interpreted as no max image size.
53 bool FetchImage(const GURL& image_url,
54 bool is_favicon,
55 uint32_t max_image_size,
56 bool bypass_cache,
57 const DownloadImageCallback& callback);
58
59 // This callback is triggered when FetchImage completes, either
60 // succesfully or with a failure. See FetchImage for more
61 // details.
62 void DidFetchImage(uint32_t max_image_size,
63 const DownloadImageCallback& callback,
64 MultiResolutionImageResourceFetcher* fetcher,
65 const std::vector<SkBitmap>& images);
66
67 // Decodes a data: URL image or returns an empty image in case of failure.
68 SkBitmap ImageFromDataUrl(const GURL&) const;
69
70 // Reply download result
71 void ReplyDownloadResult(
72 int32_t http_status_code,
73 const std::vector<SkBitmap>& result_images,
74 const std::vector<gfx::Size>& result_original_image_sizes,
75 const DownloadImageCallback& callback);
76
77 // We use StrongBinding to ensure deletion of "this" when connection closed
78 mojo::StrongBinding<ImageDownloader> binding_;
79
80 typedef ScopedVector<MultiResolutionImageResourceFetcher>
81 ImageResourceFetcherList;
82
83 // ImageResourceFetchers schedule via FetchImage.
84 ImageResourceFetcherList image_fetchers_;
85
86 DISALLOW_COPY_AND_ASSIGN(ImageDownloaderImpl);
87 };
88
89 } // namespace content
90
91 #endif // CONTENT_IMAGE_DOWNLOADER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698