Chromium Code Reviews| Index: chrome/browser/safe_image_fetcher.h |
| diff --git a/chrome/browser/safe_image_fetcher.h b/chrome/browser/safe_image_fetcher.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..03d094c75a82908a887ff44848692edc03a9a827 |
| --- /dev/null |
| +++ b/chrome/browser/safe_image_fetcher.h |
| @@ -0,0 +1,43 @@ |
| +// 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. |
| + |
| +#ifndef CHROME_BROWSER_SAFE_IMAGE_FETCHER_H_ |
| +#define CHROME_BROWSER_SAFE_IMAGE_FETCHER_H_ |
| + |
| +#include "base/callback_forward.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "chrome/browser/image_decoder.h" |
| +#include "net/url_request/url_fetcher_delegate.h" |
| +#include "url/gurl.h" |
| + |
| +class SkBitmap; |
| + |
| +namespace net { |
| +class URLFetcher; |
| +class URLRequestContextGetter; |
| +} |
| + |
| +class SafeImageFetcher : public ImageDecoder::ImageRequest, |
|
asargent_no_longer_on_chrome
2015/03/26 18:12:51
nit:
"Every class definition should have an acco
Marc Treib
2015/03/27 11:52:12
Done.
|
| + public net::URLFetcherDelegate { |
| + public: |
| + using GetImageCallback = base::Callback<void(const SkBitmap&)>; |
| + |
| + SafeImageFetcher(const GURL& url, |
| + net::URLRequestContextGetter* context_getter, |
| + const GetImageCallback& callback); |
| + ~SafeImageFetcher() override; |
| + |
| + private: |
| + // net::URLFetcherDelegate implementation. |
| + void OnURLFetchComplete(const net::URLFetcher* source) override; |
| + |
| + // ImageDecoder::ImageRequest implementation. |
| + void OnImageDecoded(const SkBitmap& decoded_image) override; |
| + void OnDecodeImageFailed() override; |
| + |
| + scoped_ptr<net::URLFetcher> url_fetcher_; |
| + GetImageCallback callback_; |
| +}; |
| + |
| +#endif // CHROME_BROWSER_SAFE_IMAGE_FETCHER_H_ |