diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-22 01:53:18 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-22 01:53:18 +0000 |
commit | f235af60b9764f7e9a2211e60c3242757816eddd (patch) | |
tree | d94c0925a2f733f794a40119ea468a1c79c6a1f7 | |
parent | f987e3dacf6a2aa203f0f7b9d6e9b01c2e782fcc (diff) | |
download | chromium_src-f235af60b9764f7e9a2211e60c3242757816eddd.zip chromium_src-f235af60b9764f7e9a2211e60c3242757816eddd.tar.gz chromium_src-f235af60b9764f7e9a2211e60c3242757816eddd.tar.bz2 |
Use a NotificationRegistrar to listen for notifications.
BUG=2381
Review URL: http://codereview.chromium.org/115676
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16704 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/chrome_plugin_browsing_context.cc | 7 | ||||
-rw-r--r-- | chrome/browser/chrome_plugin_browsing_context.h | 4 | ||||
-rw-r--r-- | chrome/common/chrome_plugin_util.cc | 8 | ||||
-rw-r--r-- | chrome/common/chrome_plugin_util.h | 4 |
4 files changed, 10 insertions, 13 deletions
diff --git a/chrome/browser/chrome_plugin_browsing_context.cc b/chrome/browser/chrome_plugin_browsing_context.cc index 8845c36..71dc80d 100644 --- a/chrome/browser/chrome_plugin_browsing_context.cc +++ b/chrome/browser/chrome_plugin_browsing_context.cc @@ -21,14 +21,11 @@ CPBrowsingContextManager* CPBrowsingContextManager::Instance() { } CPBrowsingContextManager::CPBrowsingContextManager() { - NotificationService::current()->AddObserver( - this, NotificationType::URL_REQUEST_CONTEXT_RELEASED, - NotificationService::AllSources()); + registrar_.Add(this, NotificationType::URL_REQUEST_CONTEXT_RELEASED, + NotificationService::AllSources()); } CPBrowsingContextManager::~CPBrowsingContextManager() { - // We don't remove ourselves as an observer because we are a Singleton object, - // and NotifcationService is likely gone by this point. } CPBrowsingContext CPBrowsingContextManager::Allocate( diff --git a/chrome/browser/chrome_plugin_browsing_context.h b/chrome/browser/chrome_plugin_browsing_context.h index 71e938b..16499e8 100644 --- a/chrome/browser/chrome_plugin_browsing_context.h +++ b/chrome/browser/chrome_plugin_browsing_context.h @@ -9,7 +9,7 @@ #include "base/id_map.h" #include "chrome/common/chrome_plugin_api.h" -#include "chrome/common/notification_observer.h" +#include "chrome/common/notification_registrar.h" class URLRequestContext; @@ -51,6 +51,8 @@ class CPBrowsingContextManager : public NotificationObserver { typedef IDMap<URLRequestContext> Map; typedef std::map<URLRequestContext*, CPBrowsingContext> ReverseMap; + NotificationRegistrar registrar_; + Map map_; // map of CPBrowsingContext -> URLRequestContext ReverseMap reverse_map_; // map of URLRequestContext -> CPBrowsingContext }; diff --git a/chrome/common/chrome_plugin_util.cc b/chrome/common/chrome_plugin_util.cc index d96d84e..377dc8e 100644 --- a/chrome/common/chrome_plugin_util.cc +++ b/chrome/common/chrome_plugin_util.cc @@ -53,16 +53,12 @@ void PluginHelper::DestroyAllHelpersForPlugin(ChromePluginLib* plugin) { PluginHelper::PluginHelper(ChromePluginLib* plugin) : plugin_(plugin) { DCHECK(CalledOnValidThread()); - NotificationService::current()->AddObserver( - this, NotificationType::CHROME_PLUGIN_UNLOADED, - Source<ChromePluginLib>(plugin_)); + registrar_.Add(this, NotificationType::CHROME_PLUGIN_UNLOADED, + Source<ChromePluginLib>(plugin_)); } PluginHelper::~PluginHelper() { DCHECK(CalledOnValidThread()); - NotificationService::current()->RemoveObserver( - this, NotificationType::CHROME_PLUGIN_UNLOADED, - Source<ChromePluginLib>(plugin_)); } void PluginHelper::Observe(NotificationType type, diff --git a/chrome/common/chrome_plugin_util.h b/chrome/common/chrome_plugin_util.h index d587ef1..2f24243 100644 --- a/chrome/common/chrome_plugin_util.h +++ b/chrome/common/chrome_plugin_util.h @@ -11,7 +11,7 @@ #include "base/non_thread_safe.h" #include "base/ref_counted.h" #include "chrome/common/chrome_plugin_api.h" -#include "chrome/common/notification_observer.h" +#include "chrome/common/notification_registrar.h" class ChromePluginLib; class MessageLoop; @@ -51,6 +51,8 @@ class PluginHelper : public NotificationObserver, public NonThreadSafe { const NotificationDetails& details); protected: + NotificationRegistrar registrar_; + scoped_refptr<ChromePluginLib> plugin_; DISALLOW_COPY_AND_ASSIGN(PluginHelper); |