Chromium Code Reviews| 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_CURRENTLY_ON(content::BrowserThread::UI); | |
|
Marc Treib
2015/05/27 08:23:04
I don't think this DCHECK should be here. It's the
| |
| 41 | |
| 42 if (source->GetStatus().status() != net::URLRequestStatus::SUCCESS) { | 40 if (source->GetStatus().status() != net::URLRequestStatus::SUCCESS) { |
| 43 ReportFailure(); | 41 ReportFailure(); |
| 44 return; | 42 return; |
| 45 } | 43 } |
| 46 | 44 |
| 47 std::string image_data; | 45 std::string image_data; |
| 48 source->GetResponseAsString(&image_data); | 46 source->GetResponseAsString(&image_data); |
| 49 | 47 |
| 50 // Call start to begin decoding. The ImageDecoder will call OnImageDecoded | 48 // Call start to begin decoding. The ImageDecoder will call OnImageDecoded |
| 51 // with the data when it is done. | 49 // with the data when it is done. |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 67 | 65 |
| 68 void BitmapFetcher::OnDecodeImageFailed() { | 66 void BitmapFetcher::OnDecodeImageFailed() { |
| 69 ReportFailure(); | 67 ReportFailure(); |
| 70 } | 68 } |
| 71 | 69 |
| 72 void BitmapFetcher::ReportFailure() { | 70 void BitmapFetcher::ReportFailure() { |
| 73 delegate_->OnFetchComplete(url_, NULL); | 71 delegate_->OnFetchComplete(url_, NULL); |
| 74 } | 72 } |
| 75 | 73 |
| 76 } // namespace chrome | 74 } // namespace chrome |
| OLD | NEW |