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

Side by Side Diff: net/url_request/url_request_job.cc

Issue 2447083003: Move fail on suspend logic from URLRequestJob to TcpClientSocket.
Patch Set: Fix connect error case Created 4 years, 1 month 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "net/url_request/url_request_job.h" 5 #include "net/url_request/url_request_job.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/metrics/histogram_macros.h" 12 #include "base/metrics/histogram_macros.h"
13 #include "base/power_monitor/power_monitor.h"
14 #include "base/profiler/scoped_tracker.h" 13 #include "base/profiler/scoped_tracker.h"
15 #include "base/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
16 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
17 #include "base/strings/string_split.h" 16 #include "base/strings/string_split.h"
18 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
19 #include "base/threading/thread_task_runner_handle.h" 18 #include "base/threading/thread_task_runner_handle.h"
20 #include "base/values.h" 19 #include "base/values.h"
21 #include "net/base/auth.h" 20 #include "net/base/auth.h"
22 #include "net/base/host_port_pair.h" 21 #include "net/base/host_port_pair.h"
23 #include "net/base/io_buffer.h" 22 #include "net/base/io_buffer.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 prefilter_bytes_read_(0), 123 prefilter_bytes_read_(0),
125 postfilter_bytes_read_(0), 124 postfilter_bytes_read_(0),
126 filter_needs_more_output_space_(false), 125 filter_needs_more_output_space_(false),
127 filtered_read_buffer_len_(0), 126 filtered_read_buffer_len_(0),
128 has_handled_response_(false), 127 has_handled_response_(false),
129 expected_content_size_(-1), 128 expected_content_size_(-1),
130 network_delegate_(network_delegate), 129 network_delegate_(network_delegate),
131 last_notified_total_received_bytes_(0), 130 last_notified_total_received_bytes_(0),
132 last_notified_total_sent_bytes_(0), 131 last_notified_total_sent_bytes_(0),
133 weak_factory_(this) { 132 weak_factory_(this) {
134 base::PowerMonitor* power_monitor = base::PowerMonitor::Get();
135 if (power_monitor)
136 power_monitor->AddObserver(this);
137 } 133 }
138 134
139 URLRequestJob::~URLRequestJob() { 135 URLRequestJob::~URLRequestJob() {
140 base::PowerMonitor* power_monitor = base::PowerMonitor::Get();
141 if (power_monitor)
142 power_monitor->RemoveObserver(this);
143 } 136 }
144 137
145 void URLRequestJob::SetUpload(UploadDataStream* upload) { 138 void URLRequestJob::SetUpload(UploadDataStream* upload) {
146 } 139 }
147 140
148 void URLRequestJob::SetExtraRequestHeaders(const HttpRequestHeaders& headers) { 141 void URLRequestJob::SetExtraRequestHeaders(const HttpRequestHeaders& headers) {
149 } 142 }
150 143
151 void URLRequestJob::SetPriority(RequestPriority priority) { 144 void URLRequestJob::SetPriority(RequestPriority priority) {
152 } 145 }
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 } 320 }
328 321
329 int URLRequestJob::GetResponseCode() const { 322 int URLRequestJob::GetResponseCode() const {
330 return -1; 323 return -1;
331 } 324 }
332 325
333 HostPortPair URLRequestJob::GetSocketAddress() const { 326 HostPortPair URLRequestJob::GetSocketAddress() const {
334 return HostPortPair(); 327 return HostPortPair();
335 } 328 }
336 329
337 void URLRequestJob::OnSuspend() {
338 // Most errors generated by the Job come as the result of the one current
339 // operation the job is waiting on returning an error. This event is unusual
340 // in that the Job may have another operation ongoing, or the Job may be idle
341 // and waiting on the next call.
342 //
343 // Need to cancel through the request to make sure everything is notified
344 // of the failure (Particularly that the NetworkDelegate, which the Job may be
345 // waiting on, is notified synchronously) and torn down correctly.
346 //
347 // TODO(mmenke): This should probably fail the request with
348 // NETWORK_IO_SUSPENDED instead.
349 request_->Cancel();
350 }
351
352 void URLRequestJob::NotifyURLRequestDestroyed() { 330 void URLRequestJob::NotifyURLRequestDestroyed() {
353 } 331 }
354 332
355 void URLRequestJob::GetConnectionAttempts(ConnectionAttempts* out) const { 333 void URLRequestJob::GetConnectionAttempts(ConnectionAttempts* out) const {
356 out->clear(); 334 out->clear();
357 } 335 }
358 336
359 // static 337 // static
360 GURL URLRequestJob::ComputeReferrerForRedirect( 338 GURL URLRequestJob::ComputeReferrerForRedirect(
361 URLRequest::ReferrerPolicy policy, 339 URLRequest::ReferrerPolicy policy,
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
976 int64_t total_sent_bytes = GetTotalSentBytes(); 954 int64_t total_sent_bytes = GetTotalSentBytes();
977 DCHECK_GE(total_sent_bytes, last_notified_total_sent_bytes_); 955 DCHECK_GE(total_sent_bytes, last_notified_total_sent_bytes_);
978 if (total_sent_bytes > last_notified_total_sent_bytes_) { 956 if (total_sent_bytes > last_notified_total_sent_bytes_) {
979 network_delegate_->NotifyNetworkBytesSent( 957 network_delegate_->NotifyNetworkBytesSent(
980 request_, total_sent_bytes - last_notified_total_sent_bytes_); 958 request_, total_sent_bytes - last_notified_total_sent_bytes_);
981 } 959 }
982 last_notified_total_sent_bytes_ = total_sent_bytes; 960 last_notified_total_sent_bytes_ = total_sent_bytes;
983 } 961 }
984 962
985 } // namespace net 963 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698