summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ssl
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-03 02:27:01 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-03 02:27:01 +0000
commit0d3dc8e2804b0adc4f572944db027929e2b5af5a (patch)
treeefe4a3ecde226002698017cceba2952b8979a66f /chrome/browser/ssl
parent8dc291a4dbeed088fbdc36115b250c5f83d3edde (diff)
downloadchromium_src-0d3dc8e2804b0adc4f572944db027929e2b5af5a.zip
chromium_src-0d3dc8e2804b0adc4f572944db027929e2b5af5a.tar.gz
chromium_src-0d3dc8e2804b0adc4f572944db027929e2b5af5a.tar.bz2
Fifth patch in getting rid of caching MessageLoop pointers.
BUG=25354 Review URL: http://codereview.chromium.org/345037 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30790 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ssl')
-rw-r--r--chrome/browser/ssl/ssl_cert_error_handler.cc5
-rw-r--r--chrome/browser/ssl/ssl_cert_error_handler.h3
-rw-r--r--chrome/browser/ssl/ssl_client_auth_handler.cc21
-rw-r--r--chrome/browser/ssl/ssl_client_auth_handler.h8
-rw-r--r--chrome/browser/ssl/ssl_error_handler.cc62
-rw-r--r--chrome/browser/ssl/ssl_error_handler.h9
-rw-r--r--chrome/browser/ssl/ssl_manager.cc11
-rw-r--r--chrome/browser/ssl/ssl_manager.h4
8 files changed, 54 insertions, 69 deletions
diff --git a/chrome/browser/ssl/ssl_cert_error_handler.cc b/chrome/browser/ssl/ssl_cert_error_handler.cc
index d050a64..1bb0c4d 100644
--- a/chrome/browser/ssl/ssl_cert_error_handler.cc
+++ b/chrome/browser/ssl/ssl_cert_error_handler.cc
@@ -14,10 +14,9 @@ SSLCertErrorHandler::SSLCertErrorHandler(
const std::string& frame_origin,
const std::string& main_frame_origin,
int cert_error,
- net::X509Certificate* cert,
- MessageLoop* ui_loop)
+ net::X509Certificate* cert)
: SSLErrorHandler(rdh, request, resource_type, frame_origin,
- main_frame_origin, ui_loop),
+ main_frame_origin),
cert_error_(cert_error) {
DCHECK(request == resource_dispatcher_host_->GetURLRequest(request_id_));
diff --git a/chrome/browser/ssl/ssl_cert_error_handler.h b/chrome/browser/ssl/ssl_cert_error_handler.h
index c58b2cf..7956317 100644
--- a/chrome/browser/ssl/ssl_cert_error_handler.h
+++ b/chrome/browser/ssl/ssl_cert_error_handler.h
@@ -23,8 +23,7 @@ class SSLCertErrorHandler : public SSLErrorHandler {
const std::string& frame_origin,
const std::string& main_frame_origin,
int cert_error,
- net::X509Certificate* cert,
- MessageLoop* ui_loop);
+ net::X509Certificate* cert);
virtual SSLCertErrorHandler* AsSSLCertErrorHandler() { return this; }
diff --git a/chrome/browser/ssl/ssl_client_auth_handler.cc b/chrome/browser/ssl/ssl_client_auth_handler.cc
index c986885..7acb1b5 100644
--- a/chrome/browser/ssl/ssl_client_auth_handler.cc
+++ b/chrome/browser/ssl/ssl_client_auth_handler.cc
@@ -10,23 +10,19 @@
#endif
#include "app/l10n_util.h"
-#include "base/message_loop.h"
#include "base/string_util.h"
#include "chrome/browser/browser_list.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/browser_window.h"
+#include "chrome/browser/chrome_thread.h"
#include "grit/generated_resources.h"
#include "net/url_request/url_request.h"
SSLClientAuthHandler::SSLClientAuthHandler(
URLRequest* request,
- net::SSLCertRequestInfo* cert_request_info,
- MessageLoop* io_loop,
- MessageLoop* ui_loop)
+ net::SSLCertRequestInfo* cert_request_info)
: request_(request),
- cert_request_info_(cert_request_info),
- io_loop_(io_loop),
- ui_loop_(ui_loop) {
+ cert_request_info_(cert_request_info) {
// Keep us alive until a cert is selected.
AddRef();
}
@@ -40,8 +36,9 @@ void SSLClientAuthHandler::OnRequestCancelled() {
void SSLClientAuthHandler::SelectCertificate() {
// Let's move the request to the UI thread.
- ui_loop_->PostTask(FROM_HERE, NewRunnableMethod(this,
- &SSLClientAuthHandler::DoSelectCertificate));
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(this, &SSLClientAuthHandler::DoSelectCertificate));
}
void SSLClientAuthHandler::DoSelectCertificate() {
@@ -85,8 +82,10 @@ void SSLClientAuthHandler::DoSelectCertificate() {
#endif
// Notify the IO thread that we have selected a cert.
- io_loop_->PostTask(FROM_HERE, NewRunnableMethod(this,
- &SSLClientAuthHandler::CertificateSelected, cert));
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(
+ this, &SSLClientAuthHandler::CertificateSelected, cert));
}
void SSLClientAuthHandler::CertificateSelected(net::X509Certificate* cert) {
diff --git a/chrome/browser/ssl/ssl_client_auth_handler.h b/chrome/browser/ssl/ssl_client_auth_handler.h
index 9c3b6db..b3146b2 100644
--- a/chrome/browser/ssl/ssl_client_auth_handler.h
+++ b/chrome/browser/ssl/ssl_client_auth_handler.h
@@ -12,7 +12,6 @@
namespace net {
class X509Certificate;
}
-class MessageLoop;
class URLRequest;
// This class handles the approval and selection of a certificate for SSL client
@@ -23,9 +22,7 @@ class SSLClientAuthHandler :
public base::RefCountedThreadSafe<SSLClientAuthHandler> {
public:
SSLClientAuthHandler(URLRequest* request,
- net::SSLCertRequestInfo* cert_request_info,
- MessageLoop* io_loop,
- MessageLoop* ui_loop);
+ net::SSLCertRequestInfo* cert_request_info);
~SSLClientAuthHandler();
// Asks the user to select a certificate and resumes the URL request with that
@@ -52,9 +49,6 @@ class SSLClientAuthHandler :
// The certs to choose from.
scoped_refptr<net::SSLCertRequestInfo> cert_request_info_;
- MessageLoop* io_loop_;
- MessageLoop* ui_loop_;
-
DISALLOW_COPY_AND_ASSIGN(SSLClientAuthHandler);
};
diff --git a/chrome/browser/ssl/ssl_error_handler.cc b/chrome/browser/ssl/ssl_error_handler.cc
index 13fce6c..09594ac 100644
--- a/chrome/browser/ssl/ssl_error_handler.cc
+++ b/chrome/browser/ssl/ssl_error_handler.cc
@@ -4,7 +4,7 @@
#include "chrome/browser/ssl/ssl_error_handler.h"
-#include "base/message_loop.h"
+#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
#include "chrome/browser/renderer_host/resource_dispatcher_host_request_info.h"
#include "chrome/browser/ssl/ssl_cert_error_handler.h"
@@ -17,11 +17,8 @@ SSLErrorHandler::SSLErrorHandler(ResourceDispatcherHost* rdh,
URLRequest* request,
ResourceType::Type resource_type,
const std::string& frame_origin,
- const std::string& main_frame_origin,
- MessageLoop* ui_loop)
- : ui_loop_(ui_loop),
- io_loop_(MessageLoop::current()),
- manager_(NULL),
+ const std::string& main_frame_origin)
+ : manager_(NULL),
request_id_(0, 0),
resource_dispatcher_host_(rdh),
request_url_(request->url()),
@@ -29,7 +26,7 @@ SSLErrorHandler::SSLErrorHandler(ResourceDispatcherHost* rdh,
frame_origin_(frame_origin),
main_frame_origin_(main_frame_origin),
request_has_been_notified_(false) {
- DCHECK(MessageLoop::current() != ui_loop);
+ DCHECK(!ChromeThread::CurrentlyOn(ChromeThread::UI));
ResourceDispatcherHostRequestInfo* info =
ResourceDispatcherHost::InfoForRequest(request);
@@ -50,7 +47,7 @@ SSLErrorHandler::SSLErrorHandler(ResourceDispatcherHost* rdh,
}
void SSLErrorHandler::Dispatch() {
- DCHECK(MessageLoop::current() == ui_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
TabContents* tab_contents = GetTabContents();
if (!tab_contents) {
@@ -71,49 +68,56 @@ TabContents* SSLErrorHandler::GetTabContents() {
}
void SSLErrorHandler::CancelRequest() {
- DCHECK(MessageLoop::current() == ui_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
// We need to complete this task on the IO thread.
- io_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &SSLErrorHandler::CompleteCancelRequest,
- net::ERR_ABORTED));
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(
+ this, &SSLErrorHandler::CompleteCancelRequest, net::ERR_ABORTED));
}
void SSLErrorHandler::DenyRequest() {
- DCHECK(MessageLoop::current() == ui_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
// We need to complete this task on the IO thread.
- io_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &SSLErrorHandler::CompleteCancelRequest,
- net::ERR_INSECURE_RESPONSE));
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(
+ this, &SSLErrorHandler::CompleteCancelRequest,
+ net::ERR_INSECURE_RESPONSE));
}
void SSLErrorHandler::ContinueRequest() {
- DCHECK(MessageLoop::current() == ui_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
// We need to complete this task on the IO thread.
- io_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &SSLErrorHandler::CompleteContinueRequest));
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(this, &SSLErrorHandler::CompleteContinueRequest));
}
void SSLErrorHandler::StartRequest(FilterPolicy::Type filter_policy) {
- DCHECK(MessageLoop::current() == ui_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
// We need to complete this task on the IO thread.
- io_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &SSLErrorHandler::CompleteStartRequest, filter_policy));
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(
+ this, &SSLErrorHandler::CompleteStartRequest, filter_policy));
}
void SSLErrorHandler::TakeNoAction() {
- DCHECK(MessageLoop::current() == ui_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
// We need to complete this task on the IO thread.
- io_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &SSLErrorHandler::CompleteTakeNoAction));
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(this, &SSLErrorHandler::CompleteTakeNoAction));
}
void SSLErrorHandler::CompleteCancelRequest(int error) {
- DCHECK(MessageLoop::current() == io_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
// It is important that we notify the URLRequest only once. If we try to
// notify the request twice, it may no longer exist and |this| might have
@@ -140,7 +144,7 @@ void SSLErrorHandler::CompleteCancelRequest(int error) {
}
void SSLErrorHandler::CompleteContinueRequest() {
- DCHECK(MessageLoop::current() == io_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
// It is important that we notify the URLRequest only once. If we try to
// notify the request twice, it may no longer exist and |this| might have
@@ -163,7 +167,7 @@ void SSLErrorHandler::CompleteContinueRequest() {
}
void SSLErrorHandler::CompleteStartRequest(FilterPolicy::Type filter_policy) {
- DCHECK(MessageLoop::current() == io_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
// It is important that we notify the URLRequest only once. If we try to
// notify the request twice, it may no longer exist and |this| might have
@@ -191,7 +195,7 @@ void SSLErrorHandler::CompleteStartRequest(FilterPolicy::Type filter_policy) {
}
void SSLErrorHandler::CompleteTakeNoAction() {
- DCHECK(MessageLoop::current() == io_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
// It is important that we notify the URLRequest only once. If we try to
// notify the request twice, it may no longer exist and |this| might have
diff --git a/chrome/browser/ssl/ssl_error_handler.h b/chrome/browser/ssl/ssl_error_handler.h
index 06b524a..d31f4cc 100644
--- a/chrome/browser/ssl/ssl_error_handler.h
+++ b/chrome/browser/ssl/ssl_error_handler.h
@@ -15,7 +15,6 @@
#include "googleurl/src/gurl.h"
#include "webkit/glue/resource_type.h"
-class MessageLoop;
class SSLCertErrorHandler;
class TabContents;
class URLRequest;
@@ -99,8 +98,7 @@ class SSLErrorHandler : public base::RefCountedThreadSafe<SSLErrorHandler> {
URLRequest* request,
ResourceType::Type resource_type,
const std::string& frame_origin,
- const std::string& main_frame_origin,
- MessageLoop* ui_loop);
+ const std::string& main_frame_origin);
// The following 2 methods are the methods subclasses should implement.
virtual void OnDispatchFailed() { TakeNoAction(); }
@@ -108,11 +106,6 @@ class SSLErrorHandler : public base::RefCountedThreadSafe<SSLErrorHandler> {
// Can use the manager_ member.
virtual void OnDispatched() { TakeNoAction(); }
- // We cache the message loops to be able to proxy events across the thread
- // boundaries.
- MessageLoop* ui_loop_;
- MessageLoop* io_loop_;
-
// Should only be accessed on the UI thread.
SSLManager* manager_; // Our manager.
diff --git a/chrome/browser/ssl/ssl_manager.cc b/chrome/browser/ssl/ssl_manager.cc
index bb17023..f19b9ea 100644
--- a/chrome/browser/ssl/ssl_manager.cc
+++ b/chrome/browser/ssl/ssl_manager.cc
@@ -5,7 +5,7 @@
#include "chrome/browser/ssl/ssl_manager.h"
#include "app/l10n_util.h"
-#include "base/message_loop.h"
+#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/load_from_memory_cache_details.h"
#include "chrome/browser/net/url_request_tracking.h"
#include "chrome/browser/renderer_host/resource_request_details.h"
@@ -63,8 +63,7 @@ bool SSLManager::ProcessedSSLErrorFromRequest() const {
void SSLManager::OnSSLCertificateError(ResourceDispatcherHost* rdh,
URLRequest* request,
int cert_error,
- net::X509Certificate* cert,
- MessageLoop* ui_loop) {
+ net::X509Certificate* cert) {
DLOG(INFO) << "OnSSLCertificateError() cert_error: " << cert_error <<
" url: " << request->url().spec();
@@ -74,15 +73,15 @@ void SSLManager::OnSSLCertificateError(ResourceDispatcherHost* rdh,
// A certificate error occurred. Construct a SSLCertErrorHandler object and
// hand it over to the UI thread for processing.
- ui_loop->PostTask(FROM_HERE,
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
NewRunnableMethod(new SSLCertErrorHandler(rdh,
request,
info->resource_type(),
info->frame_origin(),
info->main_frame_origin(),
cert_error,
- cert,
- ui_loop),
+ cert),
&SSLCertErrorHandler::Dispatch));
}
diff --git a/chrome/browser/ssl/ssl_manager.h b/chrome/browser/ssl/ssl_manager.h
index 371248f..7298e93 100644
--- a/chrome/browser/ssl/ssl_manager.h
+++ b/chrome/browser/ssl/ssl_manager.h
@@ -16,7 +16,6 @@
#include "net/base/net_errors.h"
class LoadFromMemoryCacheDetails;
-class MessageLoop;
class NavigationController;
class NavigationEntry;
class PrefService;
@@ -62,8 +61,7 @@ class SSLManager : public NotificationObserver {
static void OnSSLCertificateError(ResourceDispatcherHost* resource_dispatcher,
URLRequest* request,
int cert_error,
- net::X509Certificate* cert,
- MessageLoop* ui_loop);
+ net::X509Certificate* cert);
// Mixed content entry points.
void DidDisplayInsecureContent();