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

Side by Side Diff: components/image_fetcher/image_data_fetcher.h

Issue 2064793004: Reland: Split the code for fetching images and for decoding images into two separate classes. This w (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Only start image requests once (Fixes a bug). Created 4 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
« no previous file with comments | « components/image_fetcher/DEPS ('k') | components/image_fetcher/image_data_fetcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 COMPONENTS_IMAGE_FETCHER_IMAGE_DATA_FETCHER_H_
6 #define COMPONENTS_IMAGE_FETCHER_IMAGE_DATA_FETCHER_H_
7
8 #include <map>
9 #include <memory>
10 #include <string>
11
12 #include "base/callback.h"
13 #include "base/macros.h"
14 #include "base/memory/ref_counted.h"
15 #include "url/gurl.h"
16
17 namespace net {
18 class URLRequestContextGetter;
19 } // namespace net
20
21 namespace image_fetcher {
22
23 class ImageDataFetcher {
24 public:
25 using ImageDataFetcherCallback =
26 base::Callback<void(const std::string& image_data)>;
27
28 explicit ImageDataFetcher(
29 net::URLRequestContextGetter* url_request_context_getter);
30 ~ImageDataFetcher();
31
32 // Fetches the raw image bytes from the given |image_url| and calls the given
33 // |callback|. The callback is run even if fetching the URL fails. In case
34 // of an error an empty string is passed to the callback.
35 void FetchImageData(const GURL& image_url,
36 const ImageDataFetcherCallback& callback);
37
38 private:
39 class ImageDataFetcherRequest;
40
41 // Removes the ImageDataFetcherRequest for the given |image_url| from the
42 // internal request queue.
43 void RemoveImageDataFetcherRequest(const GURL& image_url);
44
45 // All active image url requests.
46 std::map<const GURL, std::unique_ptr<ImageDataFetcherRequest>>
47 pending_requests_;
48
49 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
50
51 DISALLOW_COPY_AND_ASSIGN(ImageDataFetcher);
52 };
53
54 } // namespace image_fetcher
55
56 #endif // COMPONENTS_IMAGE_FETCHER_IMAGE_DATA_FETCHER_H_
OLDNEW
« no previous file with comments | « components/image_fetcher/DEPS ('k') | components/image_fetcher/image_data_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698