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

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

Issue 2682263002: Network traffic annotation added to chrome::BitmapFetcher. (Closed)
Patch Set: Unittests added. 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 #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 const GURL& url, BitmapFetcherDelegate* delegate,
16 const net::NetworkTrafficAnnotationTag& traffic_annotation)
15 : url_(url), 17 : url_(url),
16 delegate_(delegate) { 18 delegate_(delegate),
19 traffic_annotation_(traffic_annotation) {
17 } 20 }
18 21
19 BitmapFetcher::~BitmapFetcher() { 22 BitmapFetcher::~BitmapFetcher() {
20 } 23 }
21 24
22 void BitmapFetcher::Init(net::URLRequestContextGetter* request_context, 25 void BitmapFetcher::Init(net::URLRequestContextGetter* request_context,
23 const std::string& referrer, 26 const std::string& referrer,
24 net::URLRequest::ReferrerPolicy referrer_policy, 27 net::URLRequest::ReferrerPolicy referrer_policy,
25 int load_flags) { 28 int load_flags) {
26 if (url_fetcher_ != NULL) 29 if (url_fetcher_ != NULL)
27 return; 30 return;
28 31
29 url_fetcher_ = net::URLFetcher::Create(url_, net::URLFetcher::GET, this); 32 url_fetcher_ = net::URLFetcher::Create(
33 url_, net::URLFetcher::GET, this, traffic_annotation_);
30 url_fetcher_->SetRequestContext(request_context); 34 url_fetcher_->SetRequestContext(request_context);
31 url_fetcher_->SetReferrer(referrer); 35 url_fetcher_->SetReferrer(referrer);
32 url_fetcher_->SetReferrerPolicy(referrer_policy); 36 url_fetcher_->SetReferrerPolicy(referrer_policy);
33 url_fetcher_->SetLoadFlags(load_flags); 37 url_fetcher_->SetLoadFlags(load_flags);
34 } 38 }
35 39
36 void BitmapFetcher::Start() { 40 void BitmapFetcher::Start() {
37 if (url_fetcher_) 41 if (url_fetcher_)
38 url_fetcher_->Start(); 42 url_fetcher_->Start();
39 } 43 }
(...skipping 23 matching lines...) Expand all
63 67
64 void BitmapFetcher::OnDecodeImageFailed() { 68 void BitmapFetcher::OnDecodeImageFailed() {
65 ReportFailure(); 69 ReportFailure();
66 } 70 }
67 71
68 void BitmapFetcher::ReportFailure() { 72 void BitmapFetcher::ReportFailure() {
69 delegate_->OnFetchComplete(url_, NULL); 73 delegate_->OnFetchComplete(url_, NULL);
70 } 74 }
71 75
72 } // namespace chrome 76 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698