diff options
Diffstat (limited to 'content/browser')
7 files changed, 27 insertions, 38 deletions
diff --git a/content/browser/renderer_host/resource_dispatcher_host_request_info.cc b/content/browser/renderer_host/resource_dispatcher_host_request_info.cc index 74e1a54..60fc30c 100644 --- a/content/browser/renderer_host/resource_dispatcher_host_request_info.cc +++ b/content/browser/renderer_host/resource_dispatcher_host_request_info.cc @@ -7,6 +7,7 @@ #include "content/browser/renderer_host/resource_handler.h" #include "content/browser/ssl/ssl_client_auth_handler.h" #include "content/public/browser/resource_dispatcher_host_login_delegate.h" +#include "net/url_request/url_request.h" #include "webkit/blob/blob_data.h" ResourceDispatcherHostRequestInfo::ResourceDispatcherHostRequestInfo( diff --git a/content/browser/renderer_host/resource_dispatcher_host_request_info.h b/content/browser/renderer_host/resource_dispatcher_host_request_info.h index 2296640..c4a0cb1 100644 --- a/content/browser/renderer_host/resource_dispatcher_host_request_info.h +++ b/content/browser/renderer_host/resource_dispatcher_host_request_info.h @@ -9,13 +9,14 @@ #include <string> #include "base/basictypes.h" +#include "base/memory/ref_counted.h" +#include "base/supports_user_data.h" #include "base/time.h" #include "content/common/content_export.h" #include "content/public/common/page_transition_types.h" #include "content/public/common/process_type.h" #include "content/public/common/referrer.h" #include "net/base/load_states.h" -#include "net/url_request/url_request.h" #include "webkit/glue/resource_type.h" class ResourceDispatcherHost; @@ -28,13 +29,17 @@ class ResourceContext; class ResourceDispatcherHostLoginDelegate; } +namespace net { +class URLRequest; +} + namespace webkit_blob { class BlobData; } // Holds the data ResourceDispatcherHost associates with each request. // Retrieve this data by calling ResourceDispatcherHost::InfoForRequest. -class ResourceDispatcherHostRequestInfo : public net::URLRequest::UserData { +class ResourceDispatcherHostRequestInfo : public base::SupportsUserData::Data { public: // This will take a reference to the handler. CONTENT_EXPORT ResourceDispatcherHostRequestInfo( diff --git a/content/browser/renderer_host/resource_dispatcher_host_unittest.cc b/content/browser/renderer_host/resource_dispatcher_host_unittest.cc index 1a89561..5075014 100644 --- a/content/browser/renderer_host/resource_dispatcher_host_unittest.cc +++ b/content/browser/renderer_host/resource_dispatcher_host_unittest.cc @@ -270,7 +270,7 @@ URLRequestTestDelayedStartJob* URLRequestTestDelayedStartJob::list_head_ = NULL; // Associated with an URLRequest to determine if the URLRequest gets deleted. -class TestUserData : public net::URLRequest::UserData { +class TestUserData : public base::SupportsUserData::Data { public: explicit TestUserData(bool* was_deleted) : was_deleted_(was_deleted) { @@ -291,7 +291,7 @@ class TestResourceDispatcherHostDelegate : defer_start_(false) { } - void set_url_request_user_data(net::URLRequest::UserData* user_data) { + void set_url_request_user_data(base::SupportsUserData::Data* user_data) { user_data_.reset(user_data); } @@ -321,7 +321,7 @@ class TestResourceDispatcherHostDelegate private: bool defer_start_; - scoped_ptr<net::URLRequest::UserData> user_data_; + scoped_ptr<base::SupportsUserData::Data> user_data_; }; class ResourceDispatcherHostTest : public testing::Test, diff --git a/content/browser/renderer_host/resource_queue.cc b/content/browser/renderer_host/resource_queue.cc index ef0ebe3..50ea004 100644 --- a/content/browser/renderer_host/resource_queue.cc +++ b/content/browser/renderer_host/resource_queue.cc @@ -8,6 +8,7 @@ #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/global_request_id.h" +#include "net/url_request/url_request.h" using content::BrowserThread; using content::GlobalRequestID; diff --git a/content/browser/ssl/ssl_host_state.cc b/content/browser/ssl/ssl_host_state.cc index 67f3fd8..e0ceea4 100644 --- a/content/browser/ssl/ssl_host_state.cc +++ b/content/browser/ssl/ssl_host_state.cc @@ -6,25 +6,20 @@ #include "base/logging.h" #include "base/lazy_instance.h" -#include "content/public/browser/notification_details.h" -#include "content/public/browser/notification_source.h" -#include "content/public/browser/notification_types.h" +#include "content/public/browser/browser_context.h" -namespace { -typedef std::map<content::BrowserContext*, SSLHostState*> HostStateMap; -static base::LazyInstance<HostStateMap> g_host_state_map = - LAZY_INSTANCE_INITIALIZER; -} +static const char* kKeyName = "content_ssl_host_state"; -SSLHostState* SSLHostState::GetFor(content::BrowserContext* browser_context) { - if (!g_host_state_map.Get().count(browser_context)) - g_host_state_map.Get()[browser_context] = new SSLHostState(browser_context); - return g_host_state_map.Get()[browser_context]; +SSLHostState* SSLHostState::GetFor(content::BrowserContext* context) { + SSLHostState* rv = static_cast<SSLHostState*>(context->GetUserData(kKeyName)); + if (!rv) { + rv = new SSLHostState(); + context->SetUserData(kKeyName, rv); + } + return rv; } -SSLHostState::SSLHostState(content::BrowserContext* browser_context) { - registrar_.Add(this, content::NOTIFICATION_BROWSER_CONTEXT_DESTRUCTION, - content::Source<content::BrowserContext>(browser_context)); +SSLHostState::SSLHostState() { } SSLHostState::~SSLHostState() { @@ -61,9 +56,3 @@ net::CertPolicy::Judgment SSLHostState::QueryPolicy( return cert_policy_for_host_[host].Check(cert); } - -void SSLHostState::Observe(int type, - const content::NotificationSource& source, - const content::NotificationDetails& details) { - delete this; -} diff --git a/content/browser/ssl/ssl_host_state.h b/content/browser/ssl/ssl_host_state.h index 498046e..b051b05 100644 --- a/content/browser/ssl/ssl_host_state.h +++ b/content/browser/ssl/ssl_host_state.h @@ -12,10 +12,9 @@ #include "base/compiler_specific.h" #include "base/basictypes.h" +#include "base/supports_user_data.h" #include "base/threading/non_thread_safe.h" #include "content/common/content_export.h" -#include "content/public/browser/notification_observer.h" -#include "content/public/browser/notification_registrar.h" #include "googleurl/src/gurl.h" #include "net/base/x509_certificate.h" @@ -32,12 +31,12 @@ class BrowserContext; // controllers. class CONTENT_EXPORT SSLHostState - : public content::NotificationObserver, + : NON_EXPORTED_BASE(base::SupportsUserData::Data), NON_EXPORTED_BASE(public base::NonThreadSafe) { public: static SSLHostState* GetFor(content::BrowserContext* browser_context); - explicit SSLHostState(content::BrowserContext* browser_context); + SSLHostState(); virtual ~SSLHostState(); // Records that a host has run insecure content. @@ -57,10 +56,6 @@ class CONTENT_EXPORT SSLHostState net::X509Certificate* cert, const std::string& host); private: - virtual void Observe(int type, - const content::NotificationSource& source, - const content::NotificationDetails& details) OVERRIDE; - // A BrokenHostEntry is a pair of (host, process_id) that indicates the host // contains insecure content in that renderer process. typedef std::pair<std::string, int> BrokenHostEntry; @@ -73,8 +68,6 @@ class CONTENT_EXPORT SSLHostState // Certificate policies for each host. std::map<std::string, net::CertPolicy> cert_policy_for_host_; - content::NotificationRegistrar registrar_; - DISALLOW_COPY_AND_ASSIGN(SSLHostState); }; diff --git a/content/browser/ssl/ssl_host_state_unittest.cc b/content/browser/ssl/ssl_host_state_unittest.cc index e057262..08a589f 100644 --- a/content/browser/ssl/ssl_host_state_unittest.cc +++ b/content/browser/ssl/ssl_host_state_unittest.cc @@ -92,7 +92,7 @@ class SSLHostStateTest : public testing::Test { }; TEST_F(SSLHostStateTest, DidHostRunInsecureContent) { - SSLHostState state(NULL); + SSLHostState state; EXPECT_FALSE(state.DidHostRunInsecureContent("www.google.com", 42)); EXPECT_FALSE(state.DidHostRunInsecureContent("www.google.com", 191)); @@ -116,7 +116,7 @@ TEST_F(SSLHostStateTest, QueryPolicy) { net::X509Certificate::CreateFromBytes( reinterpret_cast<const char*>(google_der), sizeof(google_der))); - SSLHostState state(NULL); + SSLHostState state; EXPECT_EQ(state.QueryPolicy(google_cert.get(), "www.google.com"), net::CertPolicy::UNKNOWN); |