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" |
(...skipping 19 matching lines...) Expand all Loading... |
30 url_fetcher_->SetRequestContext(request_context); | 30 url_fetcher_->SetRequestContext(request_context); |
31 url_fetcher_->SetReferrer(referrer); | 31 url_fetcher_->SetReferrer(referrer); |
32 url_fetcher_->SetReferrerPolicy(referrer_policy); | 32 url_fetcher_->SetReferrerPolicy(referrer_policy); |
33 url_fetcher_->SetLoadFlags(load_flags); | 33 url_fetcher_->SetLoadFlags(load_flags); |
34 url_fetcher_->Start(); | 34 url_fetcher_->Start(); |
35 } | 35 } |
36 | 36 |
37 // Methods inherited from URLFetcherDelegate. | 37 // Methods inherited from URLFetcherDelegate. |
38 | 38 |
39 void BitmapFetcher::OnURLFetchComplete(const net::URLFetcher* source) { | 39 void BitmapFetcher::OnURLFetchComplete(const net::URLFetcher* source) { |
40 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 40 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
41 | 41 |
42 if (source->GetStatus().status() != net::URLRequestStatus::SUCCESS) { | 42 if (source->GetStatus().status() != net::URLRequestStatus::SUCCESS) { |
43 ReportFailure(); | 43 ReportFailure(); |
44 return; | 44 return; |
45 } | 45 } |
46 | 46 |
47 std::string image_data; | 47 std::string image_data; |
48 source->GetResponseAsString(&image_data); | 48 source->GetResponseAsString(&image_data); |
49 | 49 |
50 // Call start to begin decoding. The ImageDecoder will call OnImageDecoded | 50 // Call start to begin decoding. The ImageDecoder will call OnImageDecoded |
(...skipping 16 matching lines...) Expand all Loading... |
67 | 67 |
68 void BitmapFetcher::OnDecodeImageFailed() { | 68 void BitmapFetcher::OnDecodeImageFailed() { |
69 ReportFailure(); | 69 ReportFailure(); |
70 } | 70 } |
71 | 71 |
72 void BitmapFetcher::ReportFailure() { | 72 void BitmapFetcher::ReportFailure() { |
73 delegate_->OnFetchComplete(url_, NULL); | 73 delegate_->OnFetchComplete(url_, NULL); |
74 } | 74 } |
75 | 75 |
76 } // namespace chrome | 76 } // namespace chrome |
OLD | NEW |