diff options
-rw-r--r-- | chrome/browser/automation/url_request_automation_job.cc | 6 | ||||
-rw-r--r-- | chrome/browser/automation/url_request_automation_job.h | 5 | ||||
-rw-r--r-- | chrome/common/automation_messages.cc | 21 | ||||
-rw-r--r-- | chrome/common/automation_messages.h | 5 | ||||
-rw-r--r-- | chrome/test/automation/automation_proxy_uitest.cc | 7 | ||||
-rw-r--r-- | chrome_frame/chrome_frame_automation.cc | 5 | ||||
-rw-r--r-- | chrome_frame/chrome_frame_automation.h | 3 | ||||
-rw-r--r-- | chrome_frame/npapi_url_request.cc | 20 | ||||
-rw-r--r-- | chrome_frame/npapi_url_request.h | 3 | ||||
-rw-r--r-- | chrome_frame/plugin_url_request.h | 6 | ||||
-rw-r--r-- | chrome_frame/test/automation_client_mock.h | 2 | ||||
-rw-r--r-- | chrome_frame/test/url_request_test.cc | 20 | ||||
-rw-r--r-- | chrome_frame/urlmon_url_request.cc | 18 | ||||
-rw-r--r-- | chrome_frame/urlmon_url_request.h | 3 |
14 files changed, 87 insertions, 37 deletions
diff --git a/chrome/browser/automation/url_request_automation_job.cc b/chrome/browser/automation/url_request_automation_job.cc index 0d06a0e..20430df 100644 --- a/chrome/browser/automation/url_request_automation_job.cc +++ b/chrome/browser/automation/url_request_automation_job.cc @@ -14,6 +14,7 @@ #include "chrome/browser/renderer_host/resource_dispatcher_host_request_info.h" #include "chrome/common/automation_messages.h" #include "net/base/cookie_monster.h" +#include "net/base/host_port_pair.h" #include "net/base/io_buffer.h" #include "net/base/net_errors.h" #include "net/http/http_response_headers.h" @@ -248,6 +249,10 @@ uint64 URLRequestAutomationJob::GetUploadProgress() const { return 0; } +net::HostPortPair URLRequestAutomationJob::GetSocketAddress() const { + return socket_address_; +} + bool URLRequestAutomationJob::MayFilterMessage(const IPC::Message& message, int* request_id) { switch (message.type()) { @@ -296,6 +301,7 @@ void URLRequestAutomationJob::OnRequestStarted( net::HttpUtil::AssembleRawHeaders(response.headers.data(), response.headers.size())); } + socket_address_ = response.socket_address; NotifyHeadersComplete(); } diff --git a/chrome/browser/automation/url_request_automation_job.h b/chrome/browser/automation/url_request_automation_job.h index 9dab13a..e9dd127 100644 --- a/chrome/browser/automation/url_request_automation_job.h +++ b/chrome/browser/automation/url_request_automation_job.h @@ -18,6 +18,7 @@ struct AutomationURLResponse; namespace net { class HttpResponseHeaders; class HttpResponseInfo; +class HostPortPair; } namespace IPC { @@ -46,6 +47,7 @@ class URLRequestAutomationJob : public net::URLRequestJob { virtual int GetResponseCode() const; virtual bool IsRedirectResponse(GURL* location, int* http_status_code); virtual uint64 GetUploadProgress() const; + virtual net::HostPortPair GetSocketAddress() const; // Peek and process automation messages for URL requests. static bool MayFilterMessage(const IPC::Message& message, int* request_id); @@ -123,6 +125,9 @@ class URLRequestAutomationJob : public net::URLRequestJob { // stack when we receive a Read request for a completed job. net::URLRequestStatus request_status_; + // Contains the ip address and port of the destination host. + net::HostPortPair socket_address_; + ScopedRunnableMethodFactory<URLRequestAutomationJob> method_factory_; DISALLOW_COPY_AND_ASSIGN(URLRequestAutomationJob); diff --git a/chrome/common/automation_messages.cc b/chrome/common/automation_messages.cc index 8dcac0e..f5f1ccc 100644 --- a/chrome/common/automation_messages.cc +++ b/chrome/common/automation_messages.cc @@ -5,7 +5,6 @@ #define IPC_MESSAGE_IMPL #include "chrome/common/automation_messages.h" - AutomationURLRequest::AutomationURLRequest() : resource_type(0), load_flags(0) { @@ -35,18 +34,18 @@ AutomationURLResponse::AutomationURLResponse() redirect_status(0) { } -AutomationURLResponse::AutomationURLResponse(const std::string& in_mime_type, - const std::string& in_headers, - int64 in_content_length, - const base::Time& in_last_modified, - const std::string& in_redirect_url, - int in_redirect_status) +AutomationURLResponse::AutomationURLResponse( + const std::string& in_mime_type, const std::string& in_headers, + int64 in_content_length, const base::Time& in_last_modified, + const std::string& in_redirect_url, int in_redirect_status, + const net::HostPortPair& host_socket_address) : mime_type(in_mime_type), headers(in_headers), content_length(in_content_length), last_modified(in_last_modified), redirect_url(in_redirect_url), - redirect_status(in_redirect_status) { + redirect_status(in_redirect_status), + socket_address(host_socket_address) { } @@ -445,6 +444,7 @@ void ParamTraits<AutomationURLResponse>::Write(Message* m, WriteParam(m, p.last_modified); WriteParam(m, p.redirect_url); WriteParam(m, p.redirect_status); + WriteParam(m, p.socket_address); } // static @@ -456,7 +456,8 @@ bool ParamTraits<AutomationURLResponse>::Read(const Message* m, ReadParam(m, iter, &p->content_length) && ReadParam(m, iter, &p->last_modified) && ReadParam(m, iter, &p->redirect_url) && - ReadParam(m, iter, &p->redirect_status); + ReadParam(m, iter, &p->redirect_status) && + ReadParam(m, iter, &p->socket_address); } // static @@ -474,6 +475,8 @@ void ParamTraits<AutomationURLResponse>::Log(const param_type& p, LogParam(p.redirect_url, l); l->append(", "); LogParam(p.redirect_status, l); + l->append(", "); + LogParam(p.socket_address, l); l->append(")"); } diff --git a/chrome/common/automation_messages.h b/chrome/common/automation_messages.h index 8bc8153..14ede2a 100644 --- a/chrome/common/automation_messages.h +++ b/chrome/common/automation_messages.h @@ -14,6 +14,7 @@ #include "chrome/common/page_type.h" #include "chrome/common/security_style.h" #include "chrome/common/common_param_traits.h" +#include "net/base/host_port_pair.h" #include "net/base/upload_data.h" #include "ui/gfx/rect.h" @@ -41,7 +42,8 @@ struct AutomationURLResponse { int64 content_length, const base::Time& last_modified, const std::string& redirect_url, - int redirect_status); + int redirect_status, + const net::HostPortPair& host_socket_address); ~AutomationURLResponse(); std::string mime_type; @@ -50,6 +52,7 @@ struct AutomationURLResponse { base::Time last_modified; std::string redirect_url; int redirect_status; + net::HostPortPair socket_address; }; struct ExternalTabSettings { diff --git a/chrome/test/automation/automation_proxy_uitest.cc b/chrome/test/automation/automation_proxy_uitest.cc index cd34c8f..06e082d 100644 --- a/chrome/test/automation/automation_proxy_uitest.cc +++ b/chrome/test/automation/automation_proxy_uitest.cc @@ -34,6 +34,7 @@ #include "chrome/test/automation/window_proxy.h" #include "chrome/test/ui_test_utils.h" #include "chrome/test/ui/ui_test.h" +#include "net/base/host_port_pair.h" #include "net/base/net_util.h" #include "net/test/test_server.h" #define GMOCK_MUTANT_INCLUDE_LATE_OBJECT_BINDING @@ -701,7 +702,8 @@ void ExternalTabUITestMockClient::ReplyEnd(const net::URLRequestStatus& status, void ExternalTabUITestMockClient::Reply404(int tab_handle, int request_id) { const AutomationURLResponse notfound("", "HTTP/1.1 404\r\n\r\n", 0, - base::Time(), "", 0); + base::Time(), "", 0, + net::HostPortPair()); ReplyStarted(¬found, tab_handle, request_id); ReplyEOF(tab_handle, request_id); } @@ -766,7 +768,8 @@ const AutomationURLResponse ExternalTabUITestMockClient::http_200( 0, base::Time(), "", - 0); + 0, + net::HostPortPair()); bool ExternalTabUITestMockClient::OnMessageReceived(const IPC::Message& msg) { bool handled = true; diff --git a/chrome_frame/chrome_frame_automation.cc b/chrome_frame/chrome_frame_automation.cc index 81eecee..9b397d9 100644 --- a/chrome_frame/chrome_frame_automation.cc +++ b/chrome_frame/chrome_frame_automation.cc @@ -1439,14 +1439,15 @@ void ChromeFrameAutomationClient::OnUnload(bool* should_unload) { void ChromeFrameAutomationClient::OnResponseStarted(int request_id, const char* mime_type, const char* headers, int size, base::Time last_modified, const std::string& redirect_url, - int redirect_status) { + int redirect_status, const net::HostPortPair& socket_address) { const AutomationURLResponse response( mime_type, headers ? headers : "", size, last_modified, redirect_url, - redirect_status); + redirect_status, + socket_address); automation_server_->Send(new AutomationMsg_RequestStarted( tab_->handle(), request_id, response)); diff --git a/chrome_frame/chrome_frame_automation.h b/chrome_frame/chrome_frame_automation.h index 81d0967..738b7c3 100644 --- a/chrome_frame/chrome_frame_automation.h +++ b/chrome_frame/chrome_frame_automation.h @@ -498,7 +498,8 @@ class ChromeFrameAutomationClient // as parameter and forwards to Chrome via IPC. virtual void OnResponseStarted(int request_id, const char* mime_type, const char* headers, int size, base::Time last_modified, - const std::string& redirect_url, int redirect_status); + const std::string& redirect_url, int redirect_status, + const net::HostPortPair& socket_address); virtual void OnReadComplete(int request_id, const std::string& data); virtual void OnResponseEnd(int request_id, const net::URLRequestStatus& status); diff --git a/chrome_frame/npapi_url_request.cc b/chrome_frame/npapi_url_request.cc index 8771ca2..ac091df 100644 --- a/chrome_frame/npapi_url_request.cc +++ b/chrome_frame/npapi_url_request.cc @@ -70,6 +70,9 @@ NPAPIUrlRequest::~NPAPIUrlRequest() { bool NPAPIUrlRequest::Start() { NPError result = NPERR_GENERIC_ERROR; DVLOG(1) << "Starting URL request: " << url(); + // Initialize the net::HostPortPair structure from the url + socket_address_ = net::HostPortPair::FromURL(GURL(url())); + if (LowerCaseEqualsASCII(method(), "get")) { // TODO(joshia): if we have extra headers for HTTP GET, then implement // it using XHR @@ -145,7 +148,8 @@ NPError NPAPIUrlRequest::OnStreamCreated(const char* mime_type, // Add support for passing persistent cookies and information about any URL // redirects to Chrome. delegate_->OnResponseStarted(id(), mime_type, stream->headers, stream->end, - base::Time::FromTimeT(stream->lastmodified), std::string(), 0); + base::Time::FromTimeT(stream->lastmodified), std::string(), 0, + socket_address_); return NPERR_NO_ERROR; } @@ -326,9 +330,9 @@ void NPAPIUrlRequestManager::GetCookiesForUrl(const GURL& url, int cookie_id) { void NPAPIUrlRequestManager::OnResponseStarted(int request_id, const char* mime_type, const char* headers, int size, base::Time last_modified, const std::string& redirect_url, - int redirect_status) { + int redirect_status, const net::HostPortPair& socket_address) { delegate_->OnResponseStarted(request_id, mime_type, headers, size, - last_modified, redirect_url, redirect_status); + last_modified, redirect_url, redirect_status, socket_address); } void NPAPIUrlRequestManager::OnReadComplete(int request_id, @@ -385,8 +389,9 @@ NPError NPAPIUrlRequestManager::NewStream(NPMIMEType type, << request->url() << " was redirected to:" << stream->url; - delegate_->OnResponseStarted(request->id(), "", "", 0, base::Time(), - stream->url, 302); + delegate_->OnResponseStarted( + request->id(), "", "", 0, base::Time(), stream->url, 302, + net::HostPortPair(net::HostPortPair::FromURL(GURL(stream->url)))); return NPERR_GENERIC_ERROR; } } @@ -443,8 +448,9 @@ void NPAPIUrlRequestManager::UrlRedirectNotify(const char* url, int status, void* notify_data) { NPAPIUrlRequest* request = RequestFromNotifyData(notify_data); if (request) { - delegate_->OnResponseStarted(request->id(), "", "", 0, base::Time(), - url, status); + delegate_->OnResponseStarted( + request->id(), "", "", 0, base::Time(), url, status, + net::HostPortPair(net::HostPortPair::FromURL(GURL(url)))); } else { NOTREACHED() << "Received unexpected redirect notification for url:" << url; diff --git a/chrome_frame/npapi_url_request.h b/chrome_frame/npapi_url_request.h index dfafbe9..f4466434 100644 --- a/chrome_frame/npapi_url_request.h +++ b/chrome_frame/npapi_url_request.h @@ -55,7 +55,8 @@ class NPAPIUrlRequestManager : public PluginUrlRequestManager, // PluginUrlRequestDelegate implementation. Forwards back to delegate. virtual void OnResponseStarted(int request_id, const char* mime_type, const char* headers, int size, base::Time last_modified, - const std::string& redirect_url, int redirect_status); + const std::string& redirect_url, int redirect_status, + const net::HostPortPair& socket_address); virtual void OnReadComplete(int request_id, const std::string& data); virtual void OnResponseEnd(int request_id, const net::URLRequestStatus& status); diff --git a/chrome_frame/plugin_url_request.h b/chrome_frame/plugin_url_request.h index 83325c9..57a30c6 100644 --- a/chrome_frame/plugin_url_request.h +++ b/chrome_frame/plugin_url_request.h @@ -14,6 +14,7 @@ #include "chrome_frame/chrome_frame_delegate.h" #include "chrome_frame/urlmon_upload_data_stream.h" #include "ipc/ipc_message.h" +#include "net/base/host_port_pair.h" #include "net/base/upload_data.h" #include "net/url_request/url_request_status.h" #include "webkit/glue/resource_type.h" @@ -26,7 +27,8 @@ class DECLSPEC_NOVTABLE PluginUrlRequestDelegate { // NOLINT public: virtual void OnResponseStarted(int request_id, const char* mime_type, const char* headers, int size, base::Time last_modified, - const std::string& redirect_url, int redirect_status) = 0; + const std::string& redirect_url, int redirect_status, + const net::HostPortPair& socket_address) = 0; virtual void OnReadComplete(int request_id, const std::string& data) = 0; virtual void OnResponseEnd(int request_id, const net::URLRequestStatus& status) = 0; @@ -186,6 +188,8 @@ class PluginUrlRequest { int load_flags_; ScopedComPtr<IStream> upload_data_; bool is_chunked_upload_; + // Contains the ip address and port of the destination host. + net::HostPortPair socket_address_; }; #endif // CHROME_FRAME_PLUGIN_URL_REQUEST_H_ diff --git a/chrome_frame/test/automation_client_mock.h b/chrome_frame/test/automation_client_mock.h index 39d2f32..52a1ce63 100644 --- a/chrome_frame/test/automation_client_mock.h +++ b/chrome_frame/test/automation_client_mock.h @@ -65,7 +65,7 @@ struct MockCFDelegate : public ChromeFrameDelegateImpl { void ReplyStarted(int request_id, const char* headers) { request_delegate_->OnResponseStarted(request_id, "text/html", headers, - 0, base::Time::Now(), EmptyString(), 0); + 0, base::Time::Now(), EmptyString(), 0, net::HostPortPair()); } void ReplyData(int request_id, const std::string* data) { diff --git a/chrome_frame/test/url_request_test.cc b/chrome_frame/test/url_request_test.cc index a7edb8c..a4a32cd 100644 --- a/chrome_frame/test/url_request_test.cc +++ b/chrome_frame/test/url_request_test.cc @@ -37,9 +37,10 @@ static void AppendToStream(IStream* s, void* buffer, ULONG cb) { class MockUrlDelegate : public PluginUrlRequestDelegate { public: - MOCK_METHOD7(OnResponseStarted, void(int request_id, const char* mime_type, + MOCK_METHOD8(OnResponseStarted, void(int request_id, const char* mime_type, const char* headers, int size, base::Time last_modified, - const std::string& redirect_url, int redirect_status)); + const std::string& redirect_url, int redirect_status, + const net::HostPortPair& socket_address)); MOCK_METHOD2(OnReadComplete, void(int request_id, const std::string& data)); MOCK_METHOD2(OnResponseEnd, void(int request_id, const net::URLRequestStatus& status)); @@ -89,7 +90,8 @@ TEST(UrlmonUrlRequestTest, Simple1) { testing::InSequence s; EXPECT_CALL(mock, OnResponseStarted(1, testing::_, testing::_, testing::_, - testing::_, testing::_, testing::_)) + testing::_, testing::_, testing::_, + testing::_)) .Times(1) .WillOnce(testing::IgnoreResult(testing::InvokeWithoutArgs(CreateFunctor( &request, &UrlmonUrlRequest::Read, 512)))); @@ -137,7 +139,8 @@ TEST(UrlmonUrlRequestTest, Head) { testing::InSequence s; EXPECT_CALL(mock, OnResponseStarted(1, testing::_, testing::_, testing::_, - testing::_, testing::_, testing::_)) + testing::_, testing::_, testing::_, + testing::_)) .Times(1) .WillOnce(testing::IgnoreResult(testing::InvokeWithoutArgs(CreateFunctor( &request, &UrlmonUrlRequest::Read, 512)))); @@ -181,7 +184,7 @@ TEST(UrlmonUrlRequestTest, UnreachableUrl) { EXPECT_CALL(mock, OnResponseStarted(1, testing::_, testing::StartsWith("HTTP/1.1 404"), testing::_, testing::_, testing::_, - testing::_)) + testing::_, testing::_)) .Times(1) .WillOnce(QUIT_LOOP_SOON(loop, 2)); @@ -218,7 +221,8 @@ TEST(UrlmonUrlRequestTest, ZeroLengthResponse) { // Expect headers EXPECT_CALL(mock, OnResponseStarted(1, testing::_, testing::_, testing::_, - testing::_, testing::_, testing::_)) + testing::_, testing::_, testing::_, + testing::_)) .Times(1) .WillOnce(QUIT_LOOP(loop)); @@ -265,7 +269,7 @@ TEST(UrlmonUrlRequestManagerTest, Simple1) { "get", "", "", NULL, 0, 0); EXPECT_CALL(mock, OnResponseStarted(1, testing::_, testing::_, testing::_, - testing::_, testing::_, testing::_)) + testing::_, testing::_, testing::_, testing::_)) .Times(1) .WillOnce(ManagerRead(&loop, mgr.get(), 1, 512)); @@ -298,7 +302,7 @@ TEST(UrlmonUrlRequestManagerTest, Abort1) { "get", "", "", NULL, 0, 0); EXPECT_CALL(mock, OnResponseStarted(1, testing::_, testing::_, testing::_, - testing::_, testing::_, testing::_)) + testing::_, testing::_, testing::_, testing::_)) .Times(1) .WillOnce(testing::DoAll( ManagerEndRequest(&loop, mgr.get(), 1), diff --git a/chrome_frame/urlmon_url_request.cc b/chrome_frame/urlmon_url_request.cc index c803263..92ee33c 100644 --- a/chrome_frame/urlmon_url_request.cc +++ b/chrome_frame/urlmon_url_request.cc @@ -52,6 +52,10 @@ bool UrlmonUrlRequest::Start() { DCHECK(thread_ == 0 || thread_ == base::PlatformThread::CurrentId()); thread_ = base::PlatformThread::CurrentId(); status_.Start(); + // Initialize the net::HostPortPair structure from the url initially. We may + // not receive the ip address of the host if the request is satisfied from + // the cache. + socket_address_ = net::HostPortPair::FromURL(GURL(url())); // The UrlmonUrlRequest instance can get destroyed in the context of // StartAsyncDownload if BindToStorage finishes synchronously with an error. // Grab a reference to protect against this. @@ -282,6 +286,13 @@ STDMETHODIMP UrlmonUrlRequest::OnProgress(ULONG progress, ULONG max_progress, } switch (status_code) { + case BINDSTATUS_CONNECTING: { + if (status_text) { + socket_address_.set_host(WideToUTF8(status_text)); + } + break; + } + case BINDSTATUS_REDIRECTING: { // If we receive a redirect for the initial pending request initiated // when our document loads we should stash it away and inform Chrome @@ -666,7 +677,8 @@ STDMETHODIMP UrlmonUrlRequest::OnResponse(DWORD dwResponseCode, 0, // size base::Time(), // last_modified status_.get_redirection().utf8_url, - status_.get_redirection().http_code); + status_.get_redirection().http_code, + socket_address_); return S_OK; } @@ -1158,13 +1170,13 @@ void UrlmonUrlRequestManager::StopAll() { void UrlmonUrlRequestManager::OnResponseStarted(int request_id, const char* mime_type, const char* headers, int size, base::Time last_modified, const std::string& redirect_url, - int redirect_status) { + int redirect_status, const net::HostPortPair& socket_address) { DCHECK_NE(request_id, -1); DVLOG(1) << __FUNCTION__; DCHECK(LookupRequest(request_id) != NULL); ++calling_delegate_; delegate_->OnResponseStarted(request_id, mime_type, headers, size, - last_modified, redirect_url, redirect_status); + last_modified, redirect_url, redirect_status, socket_address); --calling_delegate_; } diff --git a/chrome_frame/urlmon_url_request.h b/chrome_frame/urlmon_url_request.h index c16ce24..b5b47e6 100644 --- a/chrome_frame/urlmon_url_request.h +++ b/chrome_frame/urlmon_url_request.h @@ -94,7 +94,8 @@ class UrlmonUrlRequestManager const char* headers, int size, base::Time last_modified, const std::string& redirect_url, - int redirect_status); + int redirect_status, + const net::HostPortPair& socket_address); virtual void OnReadComplete(int request_id, const std::string& data); virtual void OnResponseEnd(int request_id, const net::URLRequestStatus& status); |