blob: a688c00480a06305c293138439ccbe3f3eff7f08 [file] [log] [blame]
[email protected]26b9973962012-01-28 00:57:001// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]9b9ae9552010-07-01 22:20:502// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
[email protected]677c90572008-12-10 09:03:154
Lily Houghton582d4622018-01-22 22:43:405#include "net/proxy_resolution/pac_file_fetcher_impl.h"
[email protected]677c90572008-12-10 09:03:156
7#include "base/compiler_specific.h"
skyostil4891b25b2015-06-11 11:43:458#include "base/location.h"
[email protected]13a279e2009-04-13 17:32:379#include "base/logging.h"
asvitkine30330812016-08-30 04:01:0810#include "base/metrics/histogram_macros.h"
skyostil4891b25b2015-06-11 11:43:4511#include "base/single_thread_task_runner.h"
[email protected]fc9be5802013-06-11 10:56:5112#include "base/strings/string_util.h"
gabf767595f2016-05-11 18:50:3513#include "base/threading/thread_task_runner_handle.h"
[email protected]d9d71e082011-02-16 11:44:2814#include "net/base/data_url.h"
[email protected]9dea9e1f2009-01-29 00:30:4715#include "net/base/io_buffer.h"
[email protected]677c90572008-12-10 09:03:1516#include "net/base/load_flags.h"
[email protected]597cf6e2009-05-29 09:43:2617#include "net/base/net_errors.h"
[email protected]de362402014-05-10 18:32:4718#include "net/base/net_string_util.h"
[email protected]2ca01e52013-10-31 22:05:1919#include "net/base/request_priority.h"
[email protected]6e7845ae2013-03-29 21:48:1120#include "net/cert/cert_status_flags.h"
[email protected]e0ef2c22009-06-03 23:54:4421#include "net/http/http_response_headers.h"
Eric Romanab9fc652018-05-08 01:59:5322#include "net/url_request/redirect_info.h"
[email protected]86933612010-10-16 23:10:3323#include "net/url_request/url_request_context.h"
[email protected]677c90572008-12-10 09:03:1524
[email protected]f0a51fb52009-03-05 12:46:3825// TODO(eroman):
[email protected]33abb682011-03-29 03:58:4226// - Support auth-prompts (http://crbug.com/77366)
[email protected]677c90572008-12-10 09:03:1527
28namespace net {
29
30namespace {
31
32// The maximum size (in bytes) allowed for a PAC script. Responses exceeding
33// this will fail with ERR_FILE_TOO_BIG.
[email protected]86933612010-10-16 23:10:3334const int kDefaultMaxResponseBytes = 1048576; // 1 megabyte
[email protected]677c90572008-12-10 09:03:1535
36// The maximum duration (in milliseconds) allowed for fetching the PAC script.
37// Responses exceeding this will fail with ERR_TIMED_OUT.
Eric Romancdb1d1c2018-01-03 21:17:0838//
39// This timeout applies to both scripts fetched in the course of WPAD, as well
40// as explicitly configured ones.
41//
42// If the default timeout is too high, auto-detect can stall for a long time,
43// and if it is too low then slow loading scripts may be skipped.
44//
45// 30 seconds is a compromise between those competing goals. This value also
46// appears to match Microsoft Edge (based on testing).
47constexpr base::TimeDelta kDefaultMaxDuration =
48 base::TimeDelta::FromSeconds(30);
[email protected]677c90572008-12-10 09:03:1549
[email protected]13a279e2009-04-13 17:32:3750// Returns true if |mime_type| is one of the known PAC mime type.
51bool IsPacMimeType(const std::string& mime_type) {
Lily Houghton9844d322018-01-20 05:44:0152 static const char* const kSupportedPacMimeTypes[] = {
53 "application/x-ns-proxy-autoconfig", "application/x-javascript-config",
[email protected]13a279e2009-04-13 17:32:3754 };
55 for (size_t i = 0; i < arraysize(kSupportedPacMimeTypes); ++i) {
brettwbc17d2c82015-06-09 22:39:0856 if (base::LowerCaseEqualsASCII(mime_type, kSupportedPacMimeTypes[i]))
[email protected]13a279e2009-04-13 17:32:3757 return true;
58 }
59 return false;
60}
61
[email protected]9b9ae9552010-07-01 22:20:5062// Converts |bytes| (which is encoded by |charset|) to UTF16, saving the resul
63// to |*utf16|.
[email protected]8f3c96342009-09-22 03:06:5464// If |charset| is empty, then we don't know what it was and guess.
[email protected]9b9ae9552010-07-01 22:20:5065void ConvertResponseToUTF16(const std::string& charset,
66 const std::string& bytes,
[email protected]42cba2fb2013-03-29 19:58:5767 base::string16* utf16) {
[email protected]8f3c96342009-09-22 03:06:5468 const char* codepage;
69
70 if (charset.empty()) {
71 // Assume ISO-8859-1 if no charset was specified.
[email protected]de362402014-05-10 18:32:4772 codepage = kCharsetLatin1;
[email protected]8f3c96342009-09-22 03:06:5473 } else {
74 // Otherwise trust the charset that was provided.
75 codepage = charset.c_str();
76 }
77
[email protected]de362402014-05-10 18:32:4778 // Be generous in the conversion -- if any characters lie outside of |charset|
79 // (i.e. invalid), then substitute them with U+FFFD rather than failing.
80 ConvertToUTF16WithSubstitutions(bytes, codepage, utf16);
[email protected]8f3c96342009-09-22 03:06:5481}
82
[email protected]677c90572008-12-10 09:03:1583} // namespace
84
Eric Romanab9fc652018-05-08 01:59:5385std::unique_ptr<PacFileFetcherImpl> PacFileFetcherImpl::Create(
86 URLRequestContext* url_request_context) {
87 return base::WrapUnique(new PacFileFetcherImpl(url_request_context, false));
88}
89
90std::unique_ptr<PacFileFetcherImpl>
91PacFileFetcherImpl::CreateWithFileUrlSupport(
92 URLRequestContext* url_request_context) {
93 return base::WrapUnique(new PacFileFetcherImpl(url_request_context, true));
[email protected]677c90572008-12-10 09:03:1594}
95
Lily Houghton99597862018-03-07 16:40:4296PacFileFetcherImpl::~PacFileFetcherImpl() {
[email protected]da968bc2011-01-19 11:48:1997 // The URLRequest's destructor will cancel the outstanding request, and
[email protected]677c90572008-12-10 09:03:1598 // ensure that the delegate (this) is not called again.
99}
100
Lily Houghton99597862018-03-07 16:40:42101base::TimeDelta PacFileFetcherImpl::SetTimeoutConstraint(
[email protected]7aefb152011-01-21 23:46:49102 base::TimeDelta timeout) {
103 base::TimeDelta prev = max_duration_;
104 max_duration_ = timeout;
105 return prev;
106}
107
Lily Houghton99597862018-03-07 16:40:42108size_t PacFileFetcherImpl::SetSizeConstraint(size_t size_bytes) {
[email protected]7aefb152011-01-21 23:46:49109 size_t prev = max_response_bytes_;
110 max_response_bytes_ = size_bytes;
111 return prev;
112}
113
Lily Houghton99597862018-03-07 16:40:42114void PacFileFetcherImpl::OnResponseCompleted(URLRequest* request,
115 int net_error) {
[email protected]7aefb152011-01-21 23:46:49116 DCHECK_EQ(request, cur_request_.get());
117
118 // Use |result_code_| as the request's error if we have already set it to
119 // something specific.
maksim.sisovbf794e22016-09-13 09:20:34120 if (result_code_ == OK && net_error != OK)
121 result_code_ = net_error;
[email protected]7aefb152011-01-21 23:46:49122
123 FetchCompleted();
124}
125
Ramin Halavatibb8c4d82018-03-16 08:04:31126int PacFileFetcherImpl::Fetch(
127 const GURL& url,
128 base::string16* text,
Bence Békycc5b88a2018-05-25 20:24:17129 CompletionOnceCallback callback,
Ramin Halavatibb8c4d82018-03-16 08:04:31130 const NetworkTrafficAnnotationTag traffic_annotation) {
[email protected]677c90572008-12-10 09:03:15131 // It is invalid to call Fetch() while a request is already in progress.
132 DCHECK(!cur_request_.get());
[email protected]235786812011-12-20 02:15:31133 DCHECK(!callback.is_null());
[email protected]9b9ae9552010-07-01 22:20:50134 DCHECK(text);
[email protected]677c90572008-12-10 09:03:15135
mmenkeed8d7e432017-05-03 16:48:33136 if (!url_request_context_)
137 return ERR_CONTEXT_SHUT_DOWN;
138
Eric Romanab9fc652018-05-08 01:59:53139 if (!IsUrlSchemeAllowed(url))
140 return ERR_DISALLOWED_URL_SCHEME;
141
[email protected]d9d71e082011-02-16 11:44:28142 // Handle base-64 encoded data-urls that contain custom PAC scripts.
143 if (url.SchemeIs("data")) {
144 std::string mime_type;
145 std::string charset;
146 std::string data;
147 if (!DataURL::Parse(url, &mime_type, &charset, &data))
148 return ERR_FAILED;
149
150 ConvertResponseToUTF16(charset, data, text);
151 return OK;
152 }
153
cbentzel27d2e5e52015-07-10 17:39:56154 DCHECK(fetch_start_time_.is_null());
cbentzele45ccba2015-08-21 18:23:14155 fetch_start_time_ = base::TimeTicks::Now();
cbentzel27d2e5e52015-07-10 17:39:56156
mmenkeed8d7e432017-05-03 16:48:33157 // Use highest priority, so if socket pools are being used for other types of
158 // requests, PAC requests are aren't blocked on them.
rhalavatide8bf4e2017-05-16 06:09:11159 cur_request_ = url_request_context_->CreateRequest(url, MAXIMUM_PRIORITY,
160 this, traffic_annotation);
Matt Menke510ceaa12018-01-09 17:52:26161 cur_request_->set_is_pac_request(true);
[email protected]677c90572008-12-10 09:03:15162
163 // Make sure that the PAC script is downloaded using a direct connection,
164 // to avoid circular dependencies (fetching is a part of proxy resolution).
[email protected]e0ef2c22009-06-03 23:54:44165 // Also disable the use of the disk cache. The cache is disabled so that if
166 // the user switches networks we don't potentially use the cached response
167 // from old network when we should in fact be re-fetching on the new network.
[email protected]6fbac162011-06-20 00:29:04168 // If the PAC script is hosted on an HTTPS server we bypass revocation
169 // checking in order to avoid a circular dependency when attempting to fetch
170 // the OCSP response or CRL. We could make the revocation check go direct but
mmenkeed8d7e432017-05-03 16:48:33171 // the proxy might be the only way to the outside world. IGNORE_LIMITS is
172 // used to avoid blocking proxy resolution on other network requests.
[email protected]bb1c4662013-11-14 00:00:07173 cur_request_->SetLoadFlags(LOAD_BYPASS_PROXY | LOAD_DISABLE_CACHE |
Ryan Sleevi24fe2682018-08-16 21:33:46174 LOAD_DISABLE_CERT_NETWORK_FETCHES |
mmenkeed8d7e432017-05-03 16:48:33175 LOAD_IGNORE_LIMITS);
[email protected]677c90572008-12-10 09:03:15176
177 // Save the caller's info for notification on completion.
Bence Békycc5b88a2018-05-25 20:24:17178 callback_ = std::move(callback);
[email protected]9b9ae9552010-07-01 22:20:50179 result_text_ = text;
180
181 bytes_read_so_far_.clear();
[email protected]677c90572008-12-10 09:03:15182
183 // Post a task to timeout this request if it takes too long.
184 cur_request_id_ = ++next_id_;
eromane1867242015-04-23 23:07:44185
skyostil4891b25b2015-06-11 11:43:45186 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
Lily Houghton9844d322018-01-20 05:44:01187 FROM_HERE,
Lily Houghton99597862018-03-07 16:40:42188 base::Bind(&PacFileFetcherImpl::OnTimeout, weak_factory_.GetWeakPtr(),
Lily Houghton9844d322018-01-20 05:44:01189 cur_request_id_),
[email protected]26b9973962012-01-28 00:57:00190 max_duration_);
[email protected]677c90572008-12-10 09:03:15191
192 // Start the request.
193 cur_request_->Start();
[email protected]620f5712009-08-04 22:43:12194 return ERR_IO_PENDING;
[email protected]677c90572008-12-10 09:03:15195}
196
Lily Houghton99597862018-03-07 16:40:42197void PacFileFetcherImpl::Cancel() {
[email protected]da968bc2011-01-19 11:48:19198 // ResetCurRequestState will free the URLRequest, which will cause
[email protected]677c90572008-12-10 09:03:15199 // cancellation.
200 ResetCurRequestState();
201}
202
Lily Houghton99597862018-03-07 16:40:42203URLRequestContext* PacFileFetcherImpl::GetRequestContext() const {
[email protected]20d296ddc2009-11-18 23:07:08204 return url_request_context_;
205}
206
Lily Houghton99597862018-03-07 16:40:42207void PacFileFetcherImpl::OnShutdown() {
mmenkeed8d7e432017-05-03 16:48:33208 url_request_context_ = nullptr;
209
210 if (cur_request_) {
211 result_code_ = ERR_CONTEXT_SHUT_DOWN;
212 FetchCompleted();
213 }
214}
215
Eric Romanab9fc652018-05-08 01:59:53216void PacFileFetcherImpl::OnReceivedRedirect(URLRequest* request,
217 const RedirectInfo& redirect_info,
218 bool* defer_redirect) {
219 int error = OK;
220
221 // Redirection to file:// is never OK. Ordinarily this is handled lower in the
222 // stack (|FileProtocolHandler::IsSafeRedirectTarget|), but this is reachable
223 // when built without file:// suppport. Return the same error for consistency.
224 if (redirect_info.new_url.SchemeIsFile()) {
225 error = ERR_UNSAFE_REDIRECT;
226 } else if (!IsUrlSchemeAllowed(redirect_info.new_url)) {
227 error = ERR_DISALLOWED_URL_SCHEME;
228 }
229
230 if (error != OK) {
231 // Fail the redirect.
232 request->CancelWithError(error);
233 OnResponseCompleted(request, error);
234 }
235}
236
Lily Houghton99597862018-03-07 16:40:42237void PacFileFetcherImpl::OnAuthRequired(URLRequest* request,
238 AuthChallengeInfo* auth_info) {
[email protected]0967249162010-11-20 00:13:32239 DCHECK_EQ(request, cur_request_.get());
[email protected]33abb682011-03-29 03:58:42240 // TODO(eroman): http://crbug.com/77366
[email protected]13a279e2009-04-13 17:32:37241 LOG(WARNING) << "Auth required to fetch PAC script, aborting.";
[email protected]677c90572008-12-10 09:03:15242 result_code_ = ERR_NOT_IMPLEMENTED;
243 request->CancelAuth();
244}
245
Lily Houghton99597862018-03-07 16:40:42246void PacFileFetcherImpl::OnSSLCertificateError(URLRequest* request,
247 const SSLInfo& ssl_info,
248 bool fatal) {
[email protected]0967249162010-11-20 00:13:32249 DCHECK_EQ(request, cur_request_.get());
[email protected]5db5a73d2011-10-12 16:19:36250 // Revocation check failures are not fatal.
251 if (IsCertStatusMinorError(ssl_info.cert_status)) {
252 request->ContinueDespiteLastError();
253 return;
254 }
[email protected]13a279e2009-04-13 17:32:37255 LOG(WARNING) << "SSL certificate error when fetching PAC script, aborting.";
[email protected]677c90572008-12-10 09:03:15256 // Certificate errors are in same space as net errors.
[email protected]e5624f02011-09-27 19:43:53257 result_code_ = MapCertStatusToNetError(ssl_info.cert_status);
[email protected]677c90572008-12-10 09:03:15258 request->Cancel();
259}
260
Lily Houghton99597862018-03-07 16:40:42261void PacFileFetcherImpl::OnResponseStarted(URLRequest* request, int net_error) {
[email protected]0967249162010-11-20 00:13:32262 DCHECK_EQ(request, cur_request_.get());
maksim.sisovbf794e22016-09-13 09:20:34263 DCHECK_NE(ERR_IO_PENDING, net_error);
[email protected]677c90572008-12-10 09:03:15264
maksim.sisovbf794e22016-09-13 09:20:34265 if (net_error != OK) {
266 OnResponseCompleted(request, net_error);
[email protected]677c90572008-12-10 09:03:15267 return;
268 }
269
270 // Require HTTP responses to have a success status code.
[email protected]91f5689032013-08-22 01:43:33271 if (request->url().SchemeIsHTTPOrHTTPS()) {
[email protected]f0a51fb52009-03-05 12:46:38272 // NOTE about status codes: We are like Firefox 3 in this respect.
[email protected]677c90572008-12-10 09:03:15273 // {IE 7, Safari 3, Opera 9.5} do not care about the status code.
274 if (request->GetResponseCode() != 200) {
[email protected]b30a3f52010-10-16 01:05:46275 VLOG(1) << "Fetched PAC script had (bad) status line: "
276 << request->response_headers()->GetStatusLine();
[email protected]677c90572008-12-10 09:03:15277 result_code_ = ERR_PAC_STATUS_NOT_OK;
278 request->Cancel();
279 return;
280 }
[email protected]13a279e2009-04-13 17:32:37281
282 // NOTE about mime types: We do not enforce mime types on PAC files.
283 // This is for compatibility with {IE 7, Firefox 3, Opera 9.5}. We will
284 // however log mismatches to help with debugging.
[email protected]e0ef2c22009-06-03 23:54:44285 std::string mime_type;
286 cur_request_->GetMimeType(&mime_type);
287 if (!IsPacMimeType(mime_type)) {
[email protected]b30a3f52010-10-16 01:05:46288 VLOG(1) << "Fetched PAC script does not have a proper mime type: "
289 << mime_type;
[email protected]13a279e2009-04-13 17:32:37290 }
[email protected]677c90572008-12-10 09:03:15291 }
292
293 ReadBody(request);
294}
295
Lily Houghton99597862018-03-07 16:40:42296void PacFileFetcherImpl::OnReadCompleted(URLRequest* request, int num_bytes) {
maksim.sisovbf794e22016-09-13 09:20:34297 DCHECK_NE(ERR_IO_PENDING, num_bytes);
298
[email protected]0967249162010-11-20 00:13:32299 DCHECK_EQ(request, cur_request_.get());
300 if (ConsumeBytesRead(request, num_bytes)) {
301 // Keep reading.
[email protected]677c90572008-12-10 09:03:15302 ReadBody(request);
[email protected]677c90572008-12-10 09:03:15303 }
304}
305
Eric Romanab9fc652018-05-08 01:59:53306PacFileFetcherImpl::PacFileFetcherImpl(URLRequestContext* url_request_context,
307 bool allow_file_url)
308 : url_request_context_(url_request_context),
309 buf_(new IOBuffer(kBufSize)),
310 next_id_(0),
311 cur_request_id_(0),
312 result_code_(OK),
313 result_text_(NULL),
314 max_response_bytes_(kDefaultMaxResponseBytes),
315 max_duration_(kDefaultMaxDuration),
316 allow_file_url_(allow_file_url),
317 weak_factory_(this) {
318 DCHECK(url_request_context);
319}
320
321bool PacFileFetcherImpl::IsUrlSchemeAllowed(const GURL& url) const {
322 // Always allow http://, https://, data:, and ftp://.
323 if (url.SchemeIsHTTPOrHTTPS() || url.SchemeIs("ftp") || url.SchemeIs("data"))
324 return true;
325
326 // Only permit file:// if |allow_file_url_| was set. file:// should not be
327 // allowed for URLs that were auto-detected, or as the result of a server-side
328 // redirect.
329 if (url.SchemeIsFile())
330 return allow_file_url_;
331
332 // Disallow any other URL scheme.
333 return false;
334}
335
Lily Houghton99597862018-03-07 16:40:42336void PacFileFetcherImpl::ReadBody(URLRequest* request) {
[email protected]0967249162010-11-20 00:13:32337 // Read as many bytes as are available synchronously.
338 while (true) {
maksim.sisovbf794e22016-09-13 09:20:34339 int num_bytes = request->Read(buf_.get(), kBufSize);
340 if (num_bytes == ERR_IO_PENDING)
341 return;
342
343 if (num_bytes < 0) {
344 OnResponseCompleted(request, num_bytes);
[email protected]0967249162010-11-20 00:13:32345 return;
346 }
maksim.sisovbf794e22016-09-13 09:20:34347
[email protected]0967249162010-11-20 00:13:32348 if (!ConsumeBytesRead(request, num_bytes))
349 return;
[email protected]677c90572008-12-10 09:03:15350 }
351}
352
Lily Houghton99597862018-03-07 16:40:42353bool PacFileFetcherImpl::ConsumeBytesRead(URLRequest* request, int num_bytes) {
Eric Romanf4174852018-02-16 22:47:13354 if (fetch_time_to_first_byte_.is_null())
355 fetch_time_to_first_byte_ = base::TimeTicks::Now();
356
[email protected]0967249162010-11-20 00:13:32357 if (num_bytes <= 0) {
358 // Error while reading, or EOF.
maksim.sisovbf794e22016-09-13 09:20:34359 OnResponseCompleted(request, num_bytes);
[email protected]0967249162010-11-20 00:13:32360 return false;
361 }
362
363 // Enforce maximum size bound.
364 if (num_bytes + bytes_read_so_far_.size() >
365 static_cast<size_t>(max_response_bytes_)) {
366 result_code_ = ERR_FILE_TOO_BIG;
367 request->Cancel();
368 return false;
369 }
370
[email protected]0967249162010-11-20 00:13:32371 bytes_read_so_far_.append(buf_->data(), num_bytes);
372 return true;
373}
374
Lily Houghton99597862018-03-07 16:40:42375void PacFileFetcherImpl::FetchCompleted() {
[email protected]8f3c96342009-09-22 03:06:54376 if (result_code_ == OK) {
Lily Houghton99597862018-03-07 16:40:42377 // Calculate duration of time for PAC file fetch to complete.
cbentzel27d2e5e52015-07-10 17:39:56378 DCHECK(!fetch_start_time_.is_null());
cbentzele45ccba2015-08-21 18:23:14379 DCHECK(!fetch_time_to_first_byte_.is_null());
380 UMA_HISTOGRAM_MEDIUM_TIMES("Net.ProxyScriptFetcher.SuccessDuration",
381 base::TimeTicks::Now() - fetch_start_time_);
382 UMA_HISTOGRAM_MEDIUM_TIMES("Net.ProxyScriptFetcher.FirstByteDuration",
383 fetch_time_to_first_byte_ - fetch_start_time_);
cbentzel27d2e5e52015-07-10 17:39:56384
[email protected]9b9ae9552010-07-01 22:20:50385 // The caller expects the response to be encoded as UTF16.
[email protected]8f3c96342009-09-22 03:06:54386 std::string charset;
387 cur_request_->GetCharset(&charset);
[email protected]9b9ae9552010-07-01 22:20:50388 ConvertResponseToUTF16(charset, bytes_read_so_far_, result_text_);
[email protected]8f3c96342009-09-22 03:06:54389 } else {
390 // On error, the caller expects empty string for bytes.
[email protected]9b9ae9552010-07-01 22:20:50391 result_text_->clear();
[email protected]8f3c96342009-09-22 03:06:54392 }
[email protected]677c90572008-12-10 09:03:15393
394 int result_code = result_code_;
Bence Békycc5b88a2018-05-25 20:24:17395 CompletionOnceCallback callback = std::move(callback_);
[email protected]677c90572008-12-10 09:03:15396
397 ResetCurRequestState();
398
Bence Békycc5b88a2018-05-25 20:24:17399 std::move(callback).Run(result_code);
[email protected]677c90572008-12-10 09:03:15400}
401
Lily Houghton99597862018-03-07 16:40:42402void PacFileFetcherImpl::ResetCurRequestState() {
[email protected]677c90572008-12-10 09:03:15403 cur_request_.reset();
404 cur_request_id_ = 0;
[email protected]235786812011-12-20 02:15:31405 callback_.Reset();
[email protected]677c90572008-12-10 09:03:15406 result_code_ = OK;
[email protected]9b9ae9552010-07-01 22:20:50407 result_text_ = NULL;
cbentzele45ccba2015-08-21 18:23:14408 fetch_start_time_ = base::TimeTicks();
409 fetch_time_to_first_byte_ = base::TimeTicks();
[email protected]677c90572008-12-10 09:03:15410}
411
Lily Houghton99597862018-03-07 16:40:42412void PacFileFetcherImpl::OnTimeout(int id) {
[email protected]da968bc2011-01-19 11:48:19413 // Timeout tasks may outlive the URLRequest they reference. Make sure it
[email protected]677c90572008-12-10 09:03:15414 // is still applicable.
415 if (cur_request_id_ != id)
416 return;
417
418 DCHECK(cur_request_.get());
419 result_code_ = ERR_TIMED_OUT;
mmenkeed8d7e432017-05-03 16:48:33420 FetchCompleted();
[email protected]677c90572008-12-10 09:03:15421}
422
[email protected]677c90572008-12-10 09:03:15423} // namespace net