OLD | NEW |
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 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h" | 5 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h" |
6 | 6 |
7 #include "content/public/browser/browser_thread.h" | 7 #include "content/public/browser/browser_thread.h" |
8 #include "net/url_request/url_fetcher.h" | 8 #include "net/url_request/url_fetcher.h" |
9 #include "net/url_request/url_request_context_getter.h" | 9 #include "net/url_request/url_request_context_getter.h" |
10 #include "net/url_request/url_request_status.h" | 10 #include "net/url_request/url_request_status.h" |
11 | 11 |
12 namespace chrome { | 12 namespace chrome { |
13 | 13 |
14 BitmapFetcher::BitmapFetcher(const GURL& url, BitmapFetcherDelegate* delegate) | 14 BitmapFetcher::BitmapFetcher( |
15 : url_(url), | 15 const GURL& url, |
16 delegate_(delegate) { | 16 BitmapFetcherDelegate* delegate, |
17 } | 17 const net::NetworkTrafficAnnotationTag& traffic_annotation) |
| 18 : url_(url), delegate_(delegate), traffic_annotation_(traffic_annotation) {} |
18 | 19 |
19 BitmapFetcher::~BitmapFetcher() { | 20 BitmapFetcher::~BitmapFetcher() { |
20 } | 21 } |
21 | 22 |
22 void BitmapFetcher::Init(net::URLRequestContextGetter* request_context, | 23 void BitmapFetcher::Init(net::URLRequestContextGetter* request_context, |
23 const std::string& referrer, | 24 const std::string& referrer, |
24 net::URLRequest::ReferrerPolicy referrer_policy, | 25 net::URLRequest::ReferrerPolicy referrer_policy, |
25 int load_flags) { | 26 int load_flags) { |
26 if (url_fetcher_ != NULL) | 27 if (url_fetcher_ != NULL) |
27 return; | 28 return; |
28 | 29 |
29 url_fetcher_ = net::URLFetcher::Create(url_, net::URLFetcher::GET, this); | 30 url_fetcher_ = net::URLFetcher::Create(url_, net::URLFetcher::GET, this, |
| 31 traffic_annotation_); |
30 url_fetcher_->SetRequestContext(request_context); | 32 url_fetcher_->SetRequestContext(request_context); |
31 url_fetcher_->SetReferrer(referrer); | 33 url_fetcher_->SetReferrer(referrer); |
32 url_fetcher_->SetReferrerPolicy(referrer_policy); | 34 url_fetcher_->SetReferrerPolicy(referrer_policy); |
33 url_fetcher_->SetLoadFlags(load_flags); | 35 url_fetcher_->SetLoadFlags(load_flags); |
34 } | 36 } |
35 | 37 |
36 void BitmapFetcher::Start() { | 38 void BitmapFetcher::Start() { |
37 if (url_fetcher_) | 39 if (url_fetcher_) |
38 url_fetcher_->Start(); | 40 url_fetcher_->Start(); |
39 } | 41 } |
(...skipping 23 matching lines...) Expand all Loading... |
63 | 65 |
64 void BitmapFetcher::OnDecodeImageFailed() { | 66 void BitmapFetcher::OnDecodeImageFailed() { |
65 ReportFailure(); | 67 ReportFailure(); |
66 } | 68 } |
67 | 69 |
68 void BitmapFetcher::ReportFailure() { | 70 void BitmapFetcher::ReportFailure() { |
69 delegate_->OnFetchComplete(url_, NULL); | 71 delegate_->OnFetchComplete(url_, NULL); |
70 } | 72 } |
71 | 73 |
72 } // namespace chrome | 74 } // namespace chrome |
OLD | NEW |