summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authortoyoshim@chromium.org <toyoshim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-21 23:25:16 +0000
committertoyoshim@chromium.org <toyoshim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-21 23:25:16 +0000
commit734e5d88bfa0d11f6d6042766e6c0ea4361d6102 (patch)
tree07bdd479b8a26bd3fef11e43379da6bde5525c17 /content
parenta9fbb096c17043dce4780bc5c77de24c78b5b596 (diff)
downloadchromium_src-734e5d88bfa0d11f6d6042766e6c0ea4361d6102.zip
chromium_src-734e5d88bfa0d11f6d6042766e6c0ea4361d6102.tar.gz
chromium_src-734e5d88bfa0d11f6d6042766e6c0ea4361d6102.tar.bz2
Use SSLManager to handle SSL error in SocketStreamDispatcherHost
- Provide render_process_id from RenderProcessHostImpl and WorkerProcessHost to SocketStreamDispatcherHost. - Provide render_view_id from SocketStreamHost to SocketStreamDispatcherHost. - Implement SSLErrorHandler::Delegate in SocketStreamDispatcherHost. - Then use SSLManager in SocketStreamDispatcherHost. BUG=53836 TEST=none Review URL: http://codereview.chromium.org/9704045 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@128093 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/renderer_host/render_process_host_impl.cc4
-rw-r--r--content/browser/renderer_host/socket_stream_dispatcher_host.cc41
-rw-r--r--content/browser/renderer_host/socket_stream_dispatcher_host.h16
-rw-r--r--content/browser/renderer_host/socket_stream_host.cc21
-rw-r--r--content/browser/renderer_host/socket_stream_host.h13
-rw-r--r--content/browser/worker_host/worker_process_host.cc2
6 files changed, 88 insertions, 9 deletions
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
index fcfdbf3..364ef4a 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -519,9 +519,9 @@ void RenderProcessHostImpl::CreateMessageFilters() {
#endif
SocketStreamDispatcherHost* socket_stream_dispatcher_host =
- new SocketStreamDispatcherHost(
+ new SocketStreamDispatcherHost(GetID(),
new RendererURLRequestContextSelector(browser_context, GetID()),
- resource_context);
+ resource_context);
channel_->AddFilter(socket_stream_dispatcher_host);
channel_->AddFilter(new WorkerMessageFilter(GetID(), resource_context,
diff --git a/content/browser/renderer_host/socket_stream_dispatcher_host.cc b/content/browser/renderer_host/socket_stream_dispatcher_host.cc
index a808f96..19087299 100644
--- a/content/browser/renderer_host/socket_stream_dispatcher_host.cc
+++ b/content/browser/renderer_host/socket_stream_dispatcher_host.cc
@@ -6,19 +6,23 @@
#include "base/logging.h"
#include "content/browser/renderer_host/socket_stream_host.h"
+#include "content/browser/ssl/ssl_manager.h"
#include "content/common/resource_messages.h"
#include "content/common/socket_stream.h"
#include "content/common/socket_stream_messages.h"
#include "content/public/browser/content_browser_client.h"
+#include "content/public/browser/global_request_id.h"
#include "net/cookies/cookie_monster.h"
#include "net/url_request/url_request_context_getter.h"
#include "net/websockets/websocket_job.h"
#include "net/websockets/websocket_throttle.h"
SocketStreamDispatcherHost::SocketStreamDispatcherHost(
+ int render_process_id,
ResourceMessageFilter::URLRequestContextSelector* selector,
content::ResourceContext* resource_context)
- : url_request_context_selector_(selector),
+ : render_process_id_(render_process_id),
+ url_request_context_selector_(selector),
resource_context_(resource_context) {
DCHECK(selector);
net::WebSocketJob::EnsureInit();
@@ -115,8 +119,12 @@ void SocketStreamDispatcherHost::OnSSLCertificateError(
LOG(ERROR) << "NoSocketId in OnSSLCertificateError";
return;
}
- // TODO(toyoshim): Use SSLManager to handle cert error.
- socket->ContinueDespiteCertError();
+ SocketStreamHost* socket_stream_host = hosts_.Lookup(socket_id);
+ DCHECK(socket_stream_host);
+ content::GlobalRequestID request_id(-1, socket_id);
+ SSLManager::OnSSLCertificateError(this, request_id,
+ ResourceType::SUB_RESOURCE, socket->url(), render_process_id_,
+ socket_stream_host->render_view_id(), ssl_info, fatal);
}
bool SocketStreamDispatcherHost::CanGetCookies(net::SocketStream* socket,
@@ -133,6 +141,33 @@ bool SocketStreamDispatcherHost::CanSetCookie(net::SocketStream* request,
url, url, cookie_line, resource_context_, 0, MSG_ROUTING_NONE, options);
}
+void SocketStreamDispatcherHost::CancelSSLRequest(
+ const content::GlobalRequestID& id,
+ int error,
+ const net::SSLInfo* ssl_info) {
+ int socket_id = id.request_id;
+ DVLOG(1) << "SocketStreamDispatcherHost::CancelSSLRequest socket_id="
+ << socket_id;
+ DCHECK_NE(content::kNoSocketId, socket_id);
+ SocketStreamHost* socket_stream_host = hosts_.Lookup(socket_id);
+ DCHECK(socket_stream_host);
+ if (ssl_info)
+ socket_stream_host->CancelWithSSLError(*ssl_info);
+ else
+ socket_stream_host->CancelWithError(error);
+}
+
+void SocketStreamDispatcherHost::ContinueSSLRequest(
+ const content::GlobalRequestID& id) {
+ int socket_id = id.request_id;
+ DVLOG(1) << "SocketStreamDispatcherHost::ContinueSSLRequest socket_id="
+ << socket_id;
+ DCHECK_NE(content::kNoSocketId, socket_id);
+ SocketStreamHost* socket_stream_host = hosts_.Lookup(socket_id);
+ DCHECK(socket_stream_host);
+ socket_stream_host->ContinueDespiteError();
+}
+
// Message handlers called by OnMessageReceived.
void SocketStreamDispatcherHost::OnConnect(int render_view_id,
const GURL& url,
diff --git a/content/browser/renderer_host/socket_stream_dispatcher_host.h b/content/browser/renderer_host/socket_stream_dispatcher_host.h
index 34d3d85..7dc4694 100644
--- a/content/browser/renderer_host/socket_stream_dispatcher_host.h
+++ b/content/browser/renderer_host/socket_stream_dispatcher_host.h
@@ -10,6 +10,7 @@
#include "base/id_map.h"
#include "content/browser/renderer_host/resource_message_filter.h"
+#include "content/browser/ssl/ssl_error_handler.h"
#include "content/public/browser/browser_message_filter.h"
#include "net/socket_stream/socket_stream.h"
@@ -28,21 +29,23 @@ class SSLInfo;
// It also acts as SocketStream::Delegate so that it sends
// ViewMsg_SocketStream_* messages back to renderer.
class SocketStreamDispatcherHost : public content::BrowserMessageFilter,
- public net::SocketStream::Delegate {
+ public net::SocketStream::Delegate,
+ public SSLErrorHandler::Delegate {
public:
SocketStreamDispatcherHost(
+ int render_process_id,
ResourceMessageFilter::URLRequestContextSelector* selector,
content::ResourceContext* resource_context);
virtual ~SocketStreamDispatcherHost();
- // content::BrowserMessageFilter methods.
+ // content::BrowserMessageFilter:
virtual bool OnMessageReceived(const IPC::Message& message,
bool* message_was_ok) OVERRIDE;
// The object died, so cancel and detach all requests associated with it.
void CancelRequestsForProcess(int host_id);
- // SocketStream::Delegate methods.
+ // SocketStream::Delegate:
virtual void OnConnected(net::SocketStream* socket,
int max_pending_send_allowed) OVERRIDE;
virtual void OnSentData(net::SocketStream* socket, int amount_sent) OVERRIDE;
@@ -59,6 +62,12 @@ class SocketStreamDispatcherHost : public content::BrowserMessageFilter,
const std::string& cookie_line,
net::CookieOptions* options) OVERRIDE;
+ // SSLErrorHandler::Delegate methods:
+ virtual void CancelSSLRequest(const content::GlobalRequestID& id,
+ int error,
+ const net::SSLInfo* ssl_info) OVERRIDE;
+ virtual void ContinueSSLRequest(const content::GlobalRequestID& id) OVERRIDE;
+
private:
// Message handlers called by OnMessageReceived.
void OnConnect(int render_view_id, const GURL& url, int socket_id);
@@ -70,6 +79,7 @@ class SocketStreamDispatcherHost : public content::BrowserMessageFilter,
net::URLRequestContext* GetURLRequestContext();
IDMap<SocketStreamHost> hosts_;
+ int render_process_id_;
const scoped_ptr<ResourceMessageFilter::URLRequestContextSelector>
url_request_context_selector_;
content::ResourceContext* resource_context_;
diff --git a/content/browser/renderer_host/socket_stream_host.cc b/content/browser/renderer_host/socket_stream_host.cc
index eea1323..540a38a 100644
--- a/content/browser/renderer_host/socket_stream_host.cc
+++ b/content/browser/renderer_host/socket_stream_host.cc
@@ -69,3 +69,24 @@ void SocketStreamHost::Close() {
return;
socket_->Close();
}
+
+void SocketStreamHost::CancelWithError(int error) {
+ VLOG(1) << "SocketStreamHost::CancelWithError: error=" << error;
+ if (!socket_)
+ return;
+ socket_->CancelWithError(error);
+}
+
+void SocketStreamHost::CancelWithSSLError(const net::SSLInfo& ssl_info) {
+ VLOG(1) << "SocketStreamHost::CancelWithSSLError";
+ if (!socket_)
+ return;
+ socket_->CancelWithSSLError(ssl_info);
+}
+
+void SocketStreamHost::ContinueDespiteError() {
+ VLOG(1) << "SocketStreamHost::ContinueDespiteError";
+ if (!socket_)
+ return;
+ socket_->ContinueDespiteError();
+}
diff --git a/content/browser/renderer_host/socket_stream_host.h b/content/browser/renderer_host/socket_stream_host.h
index 760c966..81bdccf 100644
--- a/content/browser/renderer_host/socket_stream_host.h
+++ b/content/browser/renderer_host/socket_stream_host.h
@@ -16,6 +16,7 @@ class GURL;
namespace net {
class SocketStreamJob;
class URLRequestContext;
+class SSLInfo;
} // namespace net
// Host of SocketStreamHandle.
@@ -52,6 +53,18 @@ class SocketStreamHost {
// Closes the socket stream.
void Close();
+ // Following CancelWithError, CancelWithSSLError, and ContinueDespiteError
+ // will be called by net::SocketStream::Delegate in OnSSLCertificateError.
+ // CancelWithError Cancels the connection because of an error.
+ // |error| is net::Error which represents the error.
+ void CancelWithError(int error);
+
+ // Cancels the connection because of receiving a certificate with an error.
+ void CancelWithSSLError(const net::SSLInfo& ssl_info);
+
+ // Continue to establish the connection in spite of an error.
+ void ContinueDespiteError();
+
private:
net::SocketStream::Delegate* delegate_;
int render_view_id_;
diff --git a/content/browser/worker_host/worker_process_host.cc b/content/browser/worker_host/worker_process_host.cc
index 6932785..dc38359 100644
--- a/content/browser/worker_host/worker_process_host.cc
+++ b/content/browser/worker_host/worker_process_host.cc
@@ -276,7 +276,7 @@ void WorkerProcessHost::CreateMessageFilters(int render_process_id) {
content::GetDatabaseTrackerForResourceContext(resource_context_)));
SocketStreamDispatcherHost* socket_stream_dispatcher_host =
- new SocketStreamDispatcherHost(
+ new SocketStreamDispatcherHost(render_process_id,
new URLRequestContextSelector(request_context), resource_context_);
process_->GetHost()->AddFilter(socket_stream_dispatcher_host);
process_->GetHost()->AddFilter(