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

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

Issue 263563003: Add referrer & load flag support to BitmapFetcher class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use new start function only Created 6 years, 7 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.h" 5 #include "chrome/browser/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, 14 BitmapFetcher::BitmapFetcher(const GURL& url,
15 BitmapFetcherDelegate* delegate) 15 BitmapFetcherDelegate* delegate)
16 : url_(url), 16 : url_(url),
17 delegate_(delegate) { 17 delegate_(delegate) {
18 } 18 }
19 19
20 BitmapFetcher::~BitmapFetcher() {} 20 BitmapFetcher::~BitmapFetcher() {}
21 21
22 void BitmapFetcher::Start(net::URLRequestContextGetter* request_context) { 22 void BitmapFetcher::Start(net::URLRequestContextGetter* request_context,
23 const std::string& referrer,
24 net::URLRequest::ReferrerPolicy referrer_policy,
25 int load_flags) {
23 if (url_fetcher_ != NULL) 26 if (url_fetcher_ != NULL)
24 return; 27 return;
25 28
26 url_fetcher_.reset(net::URLFetcher::Create(url_, net::URLFetcher::GET, this)); 29 url_fetcher_.reset(net::URLFetcher::Create(url_, net::URLFetcher::GET, this));
27 url_fetcher_->SetRequestContext(request_context); 30 url_fetcher_->SetRequestContext(request_context);
31 url_fetcher_->SetReferrer(referrer);
32 url_fetcher_->SetReferrerPolicy(referrer_policy);
33 url_fetcher_->SetLoadFlags(load_flags);
28 url_fetcher_->Start(); 34 url_fetcher_->Start();
29 } 35 }
30 36
31 // Methods inherited from URLFetcherDelegate. 37 // Methods inherited from URLFetcherDelegate.
32 38
33 void BitmapFetcher::OnURLFetchComplete(const net::URLFetcher* source) { 39 void BitmapFetcher::OnURLFetchComplete(const net::URLFetcher* source) {
34 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 40 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
35 41
36 if (source->GetStatus().status() != net::URLRequestStatus::SUCCESS) { 42 if (source->GetStatus().status() != net::URLRequestStatus::SUCCESS) {
37 ReportFailure(); 43 ReportFailure();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 77
72 void BitmapFetcher::OnDecodeImageFailed(const ImageDecoder* decoder) { 78 void BitmapFetcher::OnDecodeImageFailed(const ImageDecoder* decoder) {
73 ReportFailure(); 79 ReportFailure();
74 } 80 }
75 81
76 void BitmapFetcher::ReportFailure() { 82 void BitmapFetcher::ReportFailure() {
77 delegate_->OnFetchComplete(url_, NULL); 83 delegate_->OnFetchComplete(url_, NULL);
78 } 84 }
79 85
80 } // namespace chrome 86 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698