Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(594)

Unified Diff: content/browser/ssl/ssl_host_state.cc

Issue 9348109: Add extra data to BrowserContext so that content layer and other embedders can stash data with it t… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/ssl/ssl_host_state.cc
===================================================================
--- content/browser/ssl/ssl_host_state.cc (revision 121897)
+++ content/browser/ssl/ssl_host_state.cc (working copy)
@@ -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 @@
return cert_policy_for_host_[host].Check(cert);
}
-
-void SSLHostState::Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- delete this;
-}

Powered by Google App Engine
This is Rietveld 408576698