From 877182bb87fbe188efdb2d9fc641931706c9a469 Mon Sep 17 00:00:00 2001 From: "toyoshim@chromium.org" Date: Thu, 17 May 2012 17:23:08 +0000 Subject: Use WeakPtr for passing SSLErrorHandler::Delegate to SSLManager. If user close the owner tab while SSLManager suspend a query, SocketStreamDispatcherHost will disappear because it is owned by a renderer host. Because WebSocket is a sub resource, its request will be suspended until other major type resources (e.g., main frame) issue the same query request. I Introduce WeakPtr to make sure that SSLCertErrorHandler can call delegate functions safely. BUG=122654 TEST=none Review URL: https://chromiumcodereview.appspot.com/10034017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137676 0039d316-1c4b-4281-b951-d872f2087c98 --- content/browser/ssl/ssl_error_handler.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'content/browser/ssl/ssl_error_handler.cc') diff --git a/content/browser/ssl/ssl_error_handler.cc b/content/browser/ssl/ssl_error_handler.cc index e193d0e..1a76172 100644 --- a/content/browser/ssl/ssl_error_handler.cc +++ b/content/browser/ssl/ssl_error_handler.cc @@ -19,7 +19,7 @@ using content::RenderViewHostImpl; using content::WebContents; using net::SSLInfo; -SSLErrorHandler::SSLErrorHandler(Delegate* delegate, +SSLErrorHandler::SSLErrorHandler(base::WeakPtr delegate, const content::GlobalRequestID& id, ResourceType::Type resource_type, const GURL& url, @@ -134,7 +134,8 @@ void SSLErrorHandler::CompleteCancelRequest(int error) { const SSLInfo* ssl_info = NULL; if (cert_error) ssl_info = &cert_error->ssl_info(); - delegate_->CancelSSLRequest(request_id_, error, ssl_info); + if (delegate_) + delegate_->CancelSSLRequest(request_id_, error, ssl_info); request_has_been_notified_ = true; // We're done with this object on the IO thread. @@ -151,7 +152,8 @@ void SSLErrorHandler::CompleteContinueRequest() { if (request_has_been_notified_) return; - delegate_->ContinueSSLRequest(request_id_); + if (delegate_) + delegate_->ContinueSSLRequest(request_id_); request_has_been_notified_ = true; // We're done with this object on the IO thread. -- cgit v1.1