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

Side by Side Diff: net/http/http_cache_transaction.cc

Issue 122453002: Allows deferral of a URLRequest just before talking to the network, at (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Potential fix of a memory leak due to a reference cycle. Created 6 years, 11 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/http/http_cache_transaction.h" 5 #include "net/http/http_cache_transaction.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #if defined(OS_POSIX) 9 #if defined(OS_POSIX)
10 #include <unistd.h> 10 #include <unistd.h>
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 network_trans_->SetPriority(priority_); 537 network_trans_->SetPriority(priority_);
538 } 538 }
539 539
540 void HttpCache::Transaction::SetWebSocketHandshakeStreamCreateHelper( 540 void HttpCache::Transaction::SetWebSocketHandshakeStreamCreateHelper(
541 WebSocketHandshakeStreamBase::CreateHelper* create_helper) { 541 WebSocketHandshakeStreamBase::CreateHelper* create_helper) {
542 websocket_handshake_stream_base_create_helper_ = create_helper; 542 websocket_handshake_stream_base_create_helper_ = create_helper;
543 if (network_trans_) 543 if (network_trans_)
544 network_trans_->SetWebSocketHandshakeStreamCreateHelper(create_helper); 544 network_trans_->SetWebSocketHandshakeStreamCreateHelper(create_helper);
545 } 545 }
546 546
547 void HttpCache::Transaction::SetBeforeNetworkStartCallback(
548 const BeforeNetworkStartCallback& callback) {
549 DCHECK(!network_trans_);
550 before_network_start_callback_ = callback;
551 }
552
553 int HttpCache::Transaction::ResumeNetworkStart() {
554 if (network_trans_)
555 return network_trans_->ResumeNetworkStart();
556 return ERR_UNEXPECTED;
557 }
558
547 //----------------------------------------------------------------------------- 559 //-----------------------------------------------------------------------------
548 560
549 void HttpCache::Transaction::DoCallback(int rv) { 561 void HttpCache::Transaction::DoCallback(int rv) {
550 DCHECK(rv != ERR_IO_PENDING); 562 DCHECK(rv != ERR_IO_PENDING);
551 DCHECK(!callback_.is_null()); 563 DCHECK(!callback_.is_null());
552 564
553 read_buf_ = NULL; // Release the buffer before invoking the callback. 565 read_buf_ = NULL; // Release the buffer before invoking the callback.
554 566
555 // Since Run may result in Read being called, clear callback_ up front. 567 // Since Run may result in Read being called, clear callback_ up front.
556 CompletionCallback c = callback_; 568 CompletionCallback c = callback_;
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 DCHECK(mode_ & WRITE || mode_ == NONE); 870 DCHECK(mode_ & WRITE || mode_ == NONE);
859 DCHECK(!network_trans_.get()); 871 DCHECK(!network_trans_.get());
860 872
861 send_request_since_ = TimeTicks::Now(); 873 send_request_since_ = TimeTicks::Now();
862 874
863 // Create a network transaction. 875 // Create a network transaction.
864 int rv = cache_->network_layer_->CreateTransaction(priority_, 876 int rv = cache_->network_layer_->CreateTransaction(priority_,
865 &network_trans_); 877 &network_trans_);
866 if (rv != OK) 878 if (rv != OK)
867 return rv; 879 return rv;
880 network_trans_->SetBeforeNetworkStartCallback(before_network_start_callback_);
868 881
869 // Old load timing information, if any, is now obsolete. 882 // Old load timing information, if any, is now obsolete.
870 old_network_trans_load_timing_.reset(); 883 old_network_trans_load_timing_.reset();
871 884
872 if (websocket_handshake_stream_base_create_helper_) 885 if (websocket_handshake_stream_base_create_helper_)
873 network_trans_->SetWebSocketHandshakeStreamCreateHelper( 886 network_trans_->SetWebSocketHandshakeStreamCreateHelper(
874 websocket_handshake_stream_base_create_helper_); 887 websocket_handshake_stream_base_create_helper_);
875 888
876 next_state_ = STATE_SEND_REQUEST_COMPLETE; 889 next_state_ = STATE_SEND_REQUEST_COMPLETE;
877 rv = network_trans_->Start(request_, io_callback_, net_log_); 890 rv = network_trans_->Start(request_, io_callback_, net_log_);
(...skipping 1623 matching lines...) Expand 10 before | Expand all | Expand 10 after
2501 default: 2514 default:
2502 NOTREACHED(); 2515 NOTREACHED();
2503 } 2516 }
2504 } 2517 }
2505 2518
2506 void HttpCache::Transaction::OnIOComplete(int result) { 2519 void HttpCache::Transaction::OnIOComplete(int result) {
2507 DoLoop(result); 2520 DoLoop(result);
2508 } 2521 }
2509 2522
2510 } // namespace net 2523 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698