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

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

Issue 2676033002: Give URLRequestJob::GetResponseCode a better default implementation. (Closed)
Patch Set: Add headers Created 3 years, 10 months 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/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 RedirectInfo redirect_info = deferred_redirect_info_; 327 RedirectInfo redirect_info = deferred_redirect_info_;
328 deferred_redirect_info_ = RedirectInfo(); 328 deferred_redirect_info_ = RedirectInfo();
329 FollowRedirect(redirect_info); 329 FollowRedirect(redirect_info);
330 } 330 }
331 331
332 bool URLRequestJob::GetMimeType(std::string* mime_type) const { 332 bool URLRequestJob::GetMimeType(std::string* mime_type) const {
333 return false; 333 return false;
334 } 334 }
335 335
336 int URLRequestJob::GetResponseCode() const { 336 int URLRequestJob::GetResponseCode() const {
337 return -1; 337 HttpResponseHeaders* headers = request_->response_headers();
338 if (!headers)
339 return -1;
340 return headers->response_code();
338 } 341 }
339 342
340 HostPortPair URLRequestJob::GetSocketAddress() const { 343 HostPortPair URLRequestJob::GetSocketAddress() const {
341 return HostPortPair(); 344 return HostPortPair();
342 } 345 }
343 346
344 void URLRequestJob::OnSuspend() { 347 void URLRequestJob::OnSuspend() {
345 // Most errors generated by the Job come as the result of the one current 348 // Most errors generated by the Job come as the result of the one current
346 // operation the job is waiting on returning an error. This event is unusual 349 // operation the job is waiting on returning an error. This event is unusual
347 // in that the Job may have another operation ongoing, or the Job may be idle 350 // in that the Job may have another operation ongoing, or the Job may be idle
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 int64_t total_sent_bytes = GetTotalSentBytes(); 853 int64_t total_sent_bytes = GetTotalSentBytes();
851 DCHECK_GE(total_sent_bytes, last_notified_total_sent_bytes_); 854 DCHECK_GE(total_sent_bytes, last_notified_total_sent_bytes_);
852 if (total_sent_bytes > last_notified_total_sent_bytes_) { 855 if (total_sent_bytes > last_notified_total_sent_bytes_) {
853 network_delegate_->NotifyNetworkBytesSent( 856 network_delegate_->NotifyNetworkBytesSent(
854 request_, total_sent_bytes - last_notified_total_sent_bytes_); 857 request_, total_sent_bytes - last_notified_total_sent_bytes_);
855 } 858 }
856 last_notified_total_sent_bytes_ = total_sent_bytes; 859 last_notified_total_sent_bytes_ = total_sent_bytes;
857 } 860 }
858 861
859 } // namespace net 862 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/test_url_request_interceptor.cc ('k') | net/url_request/url_request_redirect_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698