diff options
author | battre@chromium.org <battre@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-20 16:28:16 +0000 |
---|---|---|
committer | battre@chromium.org <battre@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-20 16:28:16 +0000 |
commit | 82b42300d2c9e02161d92dab3aea5cb3dc7dd236 (patch) | |
tree | 8d7404ccbbd1ea1013d0b99bf0be6a2f99180f1e /net | |
parent | bb3be70c22f021a052c5ced2f4ce229ddf66f705 (diff) | |
download | chromium_src-82b42300d2c9e02161d92dab3aea5cb3dc7dd236.zip chromium_src-82b42300d2c9e02161d92dab3aea5cb3dc7dd236.tar.gz chromium_src-82b42300d2c9e02161d92dab3aea5cb3dc7dd236.tar.bz2 |
Implementation of chrome.experimental.webRequest.onRequestSent
BUG=60101
TEST=browser_tests --gtest_filter='ExtensionWebRequestApiTest.WebRequestEvents'
Review URL: http://codereview.chromium.org/6853014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@82308 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/base/network_delegate.cc | 7 | ||||
-rw-r--r-- | net/base/network_delegate.h | 7 | ||||
-rw-r--r-- | net/http/http_network_transaction.cc | 5 | ||||
-rw-r--r-- | net/url_request/url_request_test_util.cc | 6 | ||||
-rw-r--r-- | net/url_request/url_request_test_util.h | 6 |
5 files changed, 31 insertions, 0 deletions
diff --git a/net/base/network_delegate.cc b/net/base/network_delegate.cc index d707c44..9d1b35f 100644 --- a/net/base/network_delegate.cc +++ b/net/base/network_delegate.cc @@ -26,6 +26,13 @@ int NetworkDelegate::NotifyBeforeSendHeaders(uint64 request_id, return OnBeforeSendHeaders(request_id, callback, headers); } +void NetworkDelegate::NotifyRequestSent( + uint64 request_id, + const HostPortPair& socket_address) { + DCHECK(CalledOnValidThread()); + OnRequestSent(request_id, socket_address); +} + void NetworkDelegate::NotifyResponseStarted(URLRequest* request) { DCHECK(CalledOnValidThread()); DCHECK(request); diff --git a/net/base/network_delegate.h b/net/base/network_delegate.h index eafb212..2816248 100644 --- a/net/base/network_delegate.h +++ b/net/base/network_delegate.h @@ -23,6 +23,7 @@ namespace net { // NOTE: It is not okay to add any compile-time dependencies on symbols outside // of net/base here, because we have a net_base library. Forward declarations // are ok. +class HostPortPair; class HttpRequestHeaders; class URLRequest; class URLRequestJob; @@ -41,6 +42,7 @@ class NetworkDelegate : public base::NonThreadSafe { int NotifyBeforeSendHeaders(uint64 request_id, CompletionCallback* callback, HttpRequestHeaders* headers); + void NotifyRequestSent(uint64 request_id, const HostPortPair& socket_address); void NotifyResponseStarted(URLRequest* request); void NotifyReadCompleted(URLRequest* request, int bytes_read); void NotifyURLRequestDestroyed(URLRequest* request); @@ -75,6 +77,11 @@ class NetworkDelegate : public base::NonThreadSafe { CompletionCallback* callback, HttpRequestHeaders* headers) = 0; + // Called right after the HTTP headers have been sent and notifies where + // the request has actually been sent to. + virtual void OnRequestSent(uint64 request_id, + const HostPortPair& socket_address) = 0; + // This corresponds to URLRequestDelegate::OnResponseStarted. virtual void OnResponseStarted(URLRequest* request) = 0; diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc index 5651a41..3df89df 100644 --- a/net/http/http_network_transaction.cc +++ b/net/http/http_network_transaction.cc @@ -793,6 +793,11 @@ int HttpNetworkTransaction::DoSendRequest() { } int HttpNetworkTransaction::DoSendRequestComplete(int result) { + if (session_->network_delegate()) { + session_->network_delegate()->NotifyRequestSent( + request_->request_id, response_.socket_address); + } + if (result < 0) return HandleIOError(result); next_state_ = STATE_READ_HEADERS; diff --git a/net/url_request/url_request_test_util.cc b/net/url_request/url_request_test_util.cc index a91460a..c414f73 100644 --- a/net/url_request/url_request_test_util.cc +++ b/net/url_request/url_request_test_util.cc @@ -8,6 +8,7 @@ #include "base/logging.h" #include "base/message_loop.h" #include "base/threading/thread.h" +#include "net/base/host_port_pair.h" #include "net/http/http_network_session.h" TestCookiePolicy::TestCookiePolicy(int options_bit_mask) @@ -270,6 +271,11 @@ int TestNetworkDelegate::OnBeforeSendHeaders( return net::OK; } +void TestNetworkDelegate::OnRequestSent( + uint64 request_id, + const net::HostPortPair& socket_address) { +} + void TestNetworkDelegate::OnResponseStarted(net::URLRequest* request) { if (request->status().status() == net::URLRequestStatus::FAILED) { error_count_++; diff --git a/net/url_request/url_request_test_util.h b/net/url_request/url_request_test_util.h index cef5449..3ec44d1 100644 --- a/net/url_request/url_request_test_util.h +++ b/net/url_request/url_request_test_util.h @@ -40,6 +40,10 @@ using base::TimeDelta; +namespace net { +class HostPortPair; +} + //----------------------------------------------------------------------------- class TestCookiePolicy : public net::CookiePolicy { @@ -201,6 +205,8 @@ class TestNetworkDelegate : public net::NetworkDelegate { virtual int OnBeforeSendHeaders(uint64 request_id, net::CompletionCallback* callback, net::HttpRequestHeaders* headers); + virtual void OnRequestSent(uint64 request_id, + const net::HostPortPair& socket_address); virtual void OnResponseStarted(net::URLRequest* request); virtual void OnReadCompleted(net::URLRequest* request, int bytes_read); virtual void OnURLRequestDestroyed(net::URLRequest* request); |