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

Side by Side Diff: chrome/browser/bitmap_fetcher/bitmap_fetcher.h

Issue 2682263002: Network traffic annotation added to chrome::BitmapFetcher. (Closed)
Patch Set: Android compatibility. Created 3 years, 10 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_BITMAP_FETCHER_BITMAP_FETCHER_H_ 5 #ifndef CHROME_BROWSER_BITMAP_FETCHER_BITMAP_FETCHER_H_
6 #define CHROME_BROWSER_BITMAP_FETCHER_BITMAP_FETCHER_H_ 6 #define CHROME_BROWSER_BITMAP_FETCHER_BITMAP_FETCHER_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher_delegate.h" 11 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher_delegate.h"
12 #include "chrome/browser/image_decoder.h" 12 #include "chrome/browser/image_decoder.h"
13 #include "net/traffic_annotation/network_traffic_annotation.h"
13 #include "net/url_request/url_fetcher_delegate.h" 14 #include "net/url_request/url_fetcher_delegate.h"
14 #include "net/url_request/url_request.h" 15 #include "net/url_request/url_request.h"
15 #include "url/gurl.h" 16 #include "url/gurl.h"
16 17
17 class SkBitmap; 18 class SkBitmap;
18 19
19 namespace net { 20 namespace net {
20 class URLFetcher; 21 class URLFetcher;
21 class URLRequestContextGetter; 22 class URLRequestContextGetter;
22 } // namespace net 23 } // namespace net
23 24
24 namespace chrome { 25 namespace chrome {
25 26
26 // Asynchrounously fetches an image from the given URL and returns the 27 // Asynchrounously fetches an image from the given URL and returns the
27 // decoded Bitmap to the provided BitmapFetcherDelegate. 28 // decoded Bitmap to the provided BitmapFetcherDelegate.
28 class BitmapFetcher : public net::URLFetcherDelegate, 29 class BitmapFetcher : public net::URLFetcherDelegate,
29 public ImageDecoder::ImageRequest { 30 public ImageDecoder::ImageRequest {
30 public: 31 public:
31 BitmapFetcher(const GURL& url, BitmapFetcherDelegate* delegate); 32 BitmapFetcher(const GURL& url,
33 BitmapFetcherDelegate* delegate,
34 const net::NetworkTrafficAnnotationTag& traffic_annotation);
32 ~BitmapFetcher() override; 35 ~BitmapFetcher() override;
33 36
34 const GURL& url() const { return url_; } 37 const GURL& url() const { return url_; }
35 net::URLFetcher* url_fetcher() { return url_fetcher_.get(); } 38 net::URLFetcher* url_fetcher() { return url_fetcher_.get(); }
36 39
37 // Initializes internal fetcher. After this function returns url_fetcher() 40 // Initializes internal fetcher. After this function returns url_fetcher()
38 // can be accessed to configure it further (eg. add user data to request). 41 // can be accessed to configure it further (eg. add user data to request).
39 // All configuration must be done before Start() is called. 42 // All configuration must be done before Start() is called.
40 // Values for |load_flags| are defined in net/base/load_flags.h. In general, 43 // Values for |load_flags| are defined in net/base/load_flags.h. In general,
41 // |net::LOAD_NORMAL| is appropriate. Init may be called more than once in 44 // |net::LOAD_NORMAL| is appropriate. Init may be called more than once in
(...skipping 25 matching lines...) Expand all
67 // Called when decoding image failed. 70 // Called when decoding image failed.
68 void OnDecodeImageFailed() override; 71 void OnDecodeImageFailed() override;
69 72
70 private: 73 private:
71 // Alerts the delegate that a failure occurred. 74 // Alerts the delegate that a failure occurred.
72 void ReportFailure(); 75 void ReportFailure();
73 76
74 std::unique_ptr<net::URLFetcher> url_fetcher_; 77 std::unique_ptr<net::URLFetcher> url_fetcher_;
75 const GURL url_; 78 const GURL url_;
76 BitmapFetcherDelegate* const delegate_; 79 BitmapFetcherDelegate* const delegate_;
80 const net::NetworkTrafficAnnotationTag traffic_annotation_;
77 81
78 DISALLOW_COPY_AND_ASSIGN(BitmapFetcher); 82 DISALLOW_COPY_AND_ASSIGN(BitmapFetcher);
79 }; 83 };
80 84
81 } // namespace chrome 85 } // namespace chrome
82 86
83 #endif // CHROME_BROWSER_BITMAP_FETCHER_BITMAP_FETCHER_H_ 87 #endif // CHROME_BROWSER_BITMAP_FETCHER_BITMAP_FETCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698