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

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

Issue 8743019: base::Bind: Convert net::NetworkDelegate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fixes. Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « net/url_request/url_request_http_job.h ('k') | net/url_request/url_request_test_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_http_job.h" 5 #include "net/url_request/url_request_http_job.h"
6 6
7 #include "base/base_switches.h" 7 #include "base/base_switches.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h"
9 #include "base/build_time.h" 10 #include "base/build_time.h"
10 #include "base/command_line.h" 11 #include "base/command_line.h"
11 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
12 #include "base/file_util.h" 13 #include "base/file_util.h"
13 #include "base/file_version_info.h" 14 #include "base/file_version_info.h"
14 #include "base/message_loop.h" 15 #include "base/message_loop.h"
15 #include "base/metrics/field_trial.h" 16 #include "base/metrics/field_trial.h"
16 #include "base/metrics/histogram.h" 17 #include "base/metrics/histogram.h"
17 #include "base/rand_util.h" 18 #include "base/rand_util.h"
18 #include "base/string_util.h" 19 #include "base/string_util.h"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 : URLRequestJob(request), 203 : URLRequestJob(request),
203 response_info_(NULL), 204 response_info_(NULL),
204 response_cookies_save_index_(0), 205 response_cookies_save_index_(0),
205 proxy_auth_state_(AUTH_STATE_DONT_NEED_AUTH), 206 proxy_auth_state_(AUTH_STATE_DONT_NEED_AUTH),
206 server_auth_state_(AUTH_STATE_DONT_NEED_AUTH), 207 server_auth_state_(AUTH_STATE_DONT_NEED_AUTH),
207 ALLOW_THIS_IN_INITIALIZER_LIST(start_callback_( 208 ALLOW_THIS_IN_INITIALIZER_LIST(start_callback_(
208 this, &URLRequestHttpJob::OnStartCompleted)), 209 this, &URLRequestHttpJob::OnStartCompleted)),
209 ALLOW_THIS_IN_INITIALIZER_LIST(read_callback_( 210 ALLOW_THIS_IN_INITIALIZER_LIST(read_callback_(
210 this, &URLRequestHttpJob::OnReadCompleted)), 211 this, &URLRequestHttpJob::OnReadCompleted)),
211 ALLOW_THIS_IN_INITIALIZER_LIST(notify_before_headers_sent_callback_( 212 ALLOW_THIS_IN_INITIALIZER_LIST(notify_before_headers_sent_callback_(
212 this, &URLRequestHttpJob::NotifyBeforeSendHeadersCallback)), 213 base::Bind(&URLRequestHttpJob::NotifyBeforeSendHeadersCallback,
214 base::Unretained(this)))),
213 read_in_progress_(false), 215 read_in_progress_(false),
214 transaction_(NULL), 216 transaction_(NULL),
215 throttling_entry_(URLRequestThrottlerManager::GetInstance()-> 217 throttling_entry_(URLRequestThrottlerManager::GetInstance()->
216 RegisterRequestUrl(request->url())), 218 RegisterRequestUrl(request->url())),
217 sdch_dictionary_advertised_(false), 219 sdch_dictionary_advertised_(false),
218 sdch_test_activated_(false), 220 sdch_test_activated_(false),
219 sdch_test_control_(false), 221 sdch_test_control_(false),
220 is_cached_content_(false), 222 is_cached_content_(false),
221 request_creation_time_(), 223 request_creation_time_(),
222 packet_timing_enabled_(false), 224 packet_timing_enabled_(false),
223 done_(false), 225 done_(false),
224 bytes_observed_in_packets_(0), 226 bytes_observed_in_packets_(0),
225 request_time_snapshot_(), 227 request_time_snapshot_(),
226 final_packet_time_(), 228 final_packet_time_(),
227 ALLOW_THIS_IN_INITIALIZER_LIST( 229 ALLOW_THIS_IN_INITIALIZER_LIST(
228 filter_context_(new HttpFilterContext(this))), 230 filter_context_(new HttpFilterContext(this))),
229 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), 231 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)),
230 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 232 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
231 ALLOW_THIS_IN_INITIALIZER_LIST( 233 ALLOW_THIS_IN_INITIALIZER_LIST(on_headers_received_callback_(
232 on_headers_received_callback_( 234 base::Bind(&URLRequestHttpJob::OnHeadersReceivedCallback,
233 this, &URLRequestHttpJob::OnHeadersReceivedCallback)), 235 base::Unretained(this)))),
234 awaiting_callback_(false) { 236 awaiting_callback_(false) {
235 ResetTimer(); 237 ResetTimer();
236 } 238 }
237 239
238 void URLRequestHttpJob::NotifyHeadersComplete() { 240 void URLRequestHttpJob::NotifyHeadersComplete() {
239 DCHECK(!response_info_); 241 DCHECK(!response_info_);
240 242
241 response_info_ = transaction_->GetResponseInfo(); 243 response_info_ = transaction_->GetResponseInfo();
242 244
243 // Save boolean, as we'll need this info at destruction time, and filters may 245 // Save boolean, as we'll need this info at destruction time, and filters may
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 300
299 DoneWithRequest(ABORTED); 301 DoneWithRequest(ABORTED);
300 transaction_.reset(); 302 transaction_.reset();
301 response_info_ = NULL; 303 response_info_ = NULL;
302 context_ = NULL; 304 context_ = NULL;
303 } 305 }
304 306
305 void URLRequestHttpJob::StartTransaction() { 307 void URLRequestHttpJob::StartTransaction() {
306 if (request_->context() && request_->context()->network_delegate()) { 308 if (request_->context() && request_->context()->network_delegate()) {
307 int rv = request_->context()->network_delegate()->NotifyBeforeSendHeaders( 309 int rv = request_->context()->network_delegate()->NotifyBeforeSendHeaders(
308 request_, &notify_before_headers_sent_callback_, 310 request_, notify_before_headers_sent_callback_,
309 &request_info_.extra_headers); 311 &request_info_.extra_headers);
310 // If an extension blocks the request, we rely on the callback to 312 // If an extension blocks the request, we rely on the callback to
311 // StartTransactionInternal(). 313 // StartTransactionInternal().
312 if (rv == ERR_IO_PENDING) { 314 if (rv == ERR_IO_PENDING) {
313 SetBlockedOnDelegate(); 315 SetBlockedOnDelegate();
314 return; 316 return;
315 } 317 }
316 } 318 }
317 StartTransactionInternal(); 319 StartTransactionInternal();
318 } 320 }
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 } 709 }
708 #endif 710 #endif
709 711
710 if (result == OK) { 712 if (result == OK) {
711 scoped_refptr<HttpResponseHeaders> headers = GetResponseHeaders(); 713 scoped_refptr<HttpResponseHeaders> headers = GetResponseHeaders();
712 if (request_->context() && request_->context()->network_delegate()) { 714 if (request_->context() && request_->context()->network_delegate()) {
713 // Note that |this| may not be deleted until 715 // Note that |this| may not be deleted until
714 // |on_headers_received_callback_| or 716 // |on_headers_received_callback_| or
715 // |NetworkDelegate::URLRequestDestroyed()| has been called. 717 // |NetworkDelegate::URLRequestDestroyed()| has been called.
716 int error = request_->context()->network_delegate()-> 718 int error = request_->context()->network_delegate()->
717 NotifyHeadersReceived(request_, &on_headers_received_callback_, 719 NotifyHeadersReceived(request_, on_headers_received_callback_,
718 headers, &override_response_headers_); 720 headers, &override_response_headers_);
719 if (error != net::OK) { 721 if (error != net::OK) {
720 if (error == net::ERR_IO_PENDING) { 722 if (error == net::ERR_IO_PENDING) {
721 awaiting_callback_ = true; 723 awaiting_callback_ = true;
722 request_->net_log().BeginEvent( 724 request_->net_log().BeginEvent(
723 NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE, NULL); 725 NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE, NULL);
724 } else { 726 } else {
725 request_->net_log().AddEvent(NetLog::TYPE_CANCELLED, 727 request_->net_log().AddEvent(NetLog::TYPE_CANCELLED,
726 make_scoped_refptr( 728 make_scoped_refptr(
727 new NetLogStringParameter("source", "delegate"))); 729 new NetLogStringParameter("source", "delegate")));
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after
1410 return override_response_headers_.get() ? 1412 return override_response_headers_.get() ?
1411 override_response_headers_ : 1413 override_response_headers_ :
1412 transaction_->GetResponseInfo()->headers; 1414 transaction_->GetResponseInfo()->headers;
1413 } 1415 }
1414 1416
1415 void URLRequestHttpJob::NotifyURLRequestDestroyed() { 1417 void URLRequestHttpJob::NotifyURLRequestDestroyed() {
1416 awaiting_callback_ = false; 1418 awaiting_callback_ = false;
1417 } 1419 }
1418 1420
1419 } // namespace net 1421 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_request_http_job.h ('k') | net/url_request/url_request_test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698