summaryrefslogtreecommitdiffstats
path: root/chrome_frame
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-24 20:42:51 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-24 20:42:51 +0000
commit0d282c2e73b39d58ed920177dd53211238dbd211 (patch)
tree82ae5fc3f6a5e8a5a1ff8b34c58a815bc617f787 /chrome_frame
parent56235c632f18380a4455b6ea113cd6e2a2df0d69 (diff)
downloadchromium_src-0d282c2e73b39d58ed920177dd53211238dbd211.zip
chromium_src-0d282c2e73b39d58ed920177dd53211238dbd211.tar.gz
chromium_src-0d282c2e73b39d58ed920177dd53211238dbd211.tar.bz2
Fix for the HTTPSGetTest and GetTest net test failures with ChromeFrame. These failures occurred
because of new expectations in these tests which match the server ip address and port being connected to. We need to return that information from ChromeFrame. Fix is to send over the corresponding HostPortPair structure in the AutomationMsg_RequestStarted IPC message. A major part of this CL is basically the groundwork to pass this information over via automation. BUG=none TEST=chrome frame net tests should pass. Review URL: http://codereview.chromium.org/6575027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75942 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
-rw-r--r--chrome_frame/chrome_frame_automation.cc5
-rw-r--r--chrome_frame/chrome_frame_automation.h3
-rw-r--r--chrome_frame/npapi_url_request.cc20
-rw-r--r--chrome_frame/npapi_url_request.h3
-rw-r--r--chrome_frame/plugin_url_request.h6
-rw-r--r--chrome_frame/test/automation_client_mock.h2
-rw-r--r--chrome_frame/test/url_request_test.cc20
-rw-r--r--chrome_frame/urlmon_url_request.cc18
-rw-r--r--chrome_frame/urlmon_url_request.h3
9 files changed, 55 insertions, 25 deletions
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);