| 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..9e5f2afadd912cba7fa3b35ad3fe42941d3415ab
|
| --- /dev/null
|
| +++ b/content/renderer/image_downloader/single_image_downloader.h
|
| @@ -0,0 +1,58 @@
|
| +// 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/callback.h"
|
| +#include "base/memory/weak_ptr.h"
|
| +#include "content/public/renderer/render_frame_observer.h"
|
| +#include "content/renderer/image_downloader/image_downloader_core.h"
|
| +#include "third_party/skia/include/core/SkBitmap.h"
|
| +#include "url/gurl.h"
|
| +
|
| +namespace content {
|
| +
|
| +class ImageDownloaderCore;
|
| +class RenderFrame;
|
| +
|
| +// A one time image downloader that will be self-destructed when downloading
|
| +// finishes or the |render_frame| is destructed. When there are multiple frames,
|
| +// return the first one.
|
| +class SingleImageDownloader : public RenderFrameObserver {
|
| + public:
|
| + using DownloadImageCallback = base::Callback<void(const SkBitmap&)>;
|
| +
|
| + // Called to download the image in given |url|, and run |cb| when done.
|
| + // A new SingleImageDownloader will be created, and be self-destructed when
|
| + // downloading finishes or |render_frame| is destructed.
|
| + static void DownloadImage(const base::WeakPtr<RenderFrame>& render_frame,
|
| + const GURL& url,
|
| + const DownloadImageCallback& cb);
|
| +
|
| + ~SingleImageDownloader() override;
|
| +
|
| + private:
|
| + SingleImageDownloader(RenderFrame* render_frame,
|
| + const GURL& url,
|
| + bool is_favicon,
|
| + bool bypass_cache,
|
| + const DownloadImageCallback& callback);
|
| +
|
| + // RenderFrameObserver implementation.
|
| + void OnDestruct() override;
|
| +
|
| + // Called by |image_downloader_| when downloading finishes.
|
| + void DidDownloadImage(const DownloadImageCallback& callback,
|
| + int http_status_code,
|
| + const std::vector<SkBitmap>& images);
|
| +
|
| + ImageDownloaderCore image_downloader_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(SingleImageDownloader);
|
| +};
|
| +
|
| +} // namespace content
|
| +
|
| +#endif // CONTENT_RENDERER_IMAGE_DOWNLOADER_SINGLE_IMAGE_DOWNLOADER_H_
|
|
|