Chromium Code Reviews| Index: components/translate/core/browser/translate_url_fetcher.cc |
| diff --git a/components/translate/core/browser/translate_url_fetcher.cc b/components/translate/core/browser/translate_url_fetcher.cc |
| index dbbff3176056f9c9c199a3e1e7c84e4503213316..296fa283c775b2d2f83db6a1f591413157a42670 100644 |
| --- a/components/translate/core/browser/translate_url_fetcher.cc |
| +++ b/components/translate/core/browser/translate_url_fetcher.cc |
| @@ -46,13 +46,22 @@ bool TranslateURLFetcher::Request( |
| url_ = url; |
| callback_ = callback; |
| + // If the TranslateDownloadManager's request context getter is nullptr then |
| + // shutdown is in progress. Abort the request, which can't proceed with a |
| + // null request_context_getter. |
| + net::URLRequestContextGetter* request_context_getter = |
| + TranslateDownloadManager::GetInstance()->request_context(); |
|
groby-ooo-7-16
2017/04/24 19:12:46
So, request_context is RefCountedThreadSafe. Shoul
Roger McFarlane (Chromium)
2017/04/24 20:31:34
I put the returned value in to a scoped_refptr.
I
|
| + if (request_context_getter == nullptr) |
| + return false; |
| + |
| + // Create and initialize the URL fetcher. |
| fetcher_ = net::URLFetcher::Create(id_, url_, net::URLFetcher::GET, this); |
| data_use_measurement::DataUseUserData::AttachToFetcher( |
| fetcher_.get(), data_use_measurement::DataUseUserData::TRANSLATE); |
| fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
| net::LOAD_DO_NOT_SAVE_COOKIES); |
| - fetcher_->SetRequestContext( |
| - TranslateDownloadManager::GetInstance()->request_context()); |
| + fetcher_->SetRequestContext(request_context_getter); |
| + |
| // Set retry parameter for HTTP status code 5xx. This doesn't work against |
| // 106 (net::ERR_INTERNET_DISCONNECTED) and so on. |
| // TranslateLanguageList handles network status, and implements retry. |