diff options
Diffstat (limited to 'chrome')
6 files changed, 20 insertions, 37 deletions
diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc index fa0c54c..2061e25 100644 --- a/chrome/browser/renderer_host/browser_render_process_host.cc +++ b/chrome/browser/renderer_host/browser_render_process_host.cc @@ -133,9 +133,8 @@ BrowserRenderProcessHost::BrowserRenderProcessHost(Profile* profile) this, &BrowserRenderProcessHost::ClearTransportDIBCache)) { widget_helper_ = new RenderWidgetHelper(); - NotificationService::current()->AddObserver(this, - NotificationType::USER_SCRIPTS_LOADED, - NotificationService::AllSources()); + registrar_.Add(this, NotificationType::USER_SCRIPTS_LOADED, + NotificationService::AllSources()); if (run_renderer_in_process()) { // We need a "renderer pid", but we don't have one when there's no renderer @@ -170,9 +169,6 @@ BrowserRenderProcessHost::~BrowserRenderProcessHost() { ProcessWatcher::EnsureProcessTerminated(process_.handle()); } - NotificationService::current()->RemoveObserver(this, - NotificationType::USER_SCRIPTS_LOADED, NotificationService::AllSources()); - ClearTransportDIBCache(); } diff --git a/chrome/browser/renderer_host/browser_render_process_host.h b/chrome/browser/renderer_host/browser_render_process_host.h index f92f097..b380211 100644 --- a/chrome/browser/renderer_host/browser_render_process_host.h +++ b/chrome/browser/renderer_host/browser_render_process_host.h @@ -18,7 +18,7 @@ #include "chrome/common/transport_dib.h" #include "chrome/browser/renderer_host/audio_renderer_host.h" #include "chrome/browser/renderer_host/render_process_host.h" -#include "chrome/common/notification_observer.h" +#include "chrome/common/notification_registrar.h" #include "webkit/api/public/WebCache.h" class CommandLine; @@ -120,6 +120,8 @@ class BrowserRenderProcessHost : public RenderProcessHost, // Returns true if the priority is backgrounded; false otherwise. void SetBackgrounded(bool boost); + NotificationRegistrar registrar_; + // The count of currently visible widgets. Since the host can be a container // for multiple widgets, it uses this count to determine when it should be // backgrounded. diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc index 5d26559..8631742 100644 --- a/chrome/browser/renderer_host/resource_message_filter.cc +++ b/chrome/browser/renderer_host/resource_message_filter.cc @@ -140,6 +140,10 @@ ResourceMessageFilter::ResourceMessageFilter( } ResourceMessageFilter::~ResourceMessageFilter() { + // This function should be called on the IO thread. + DCHECK(MessageLoop::current() == + ChromeThread::GetMessageLoop(ChromeThread::IO)); + // Let interested observers know we are being deleted. NotificationService::current()->Notify( NotificationType::RESOURCE_MESSAGE_FILTER_SHUTDOWN, @@ -148,14 +152,6 @@ ResourceMessageFilter::~ResourceMessageFilter() { if (handle()) base::CloseProcessHandle(handle()); - - // This function should be called on the IO thread. - DCHECK(MessageLoop::current() == - ChromeThread::GetMessageLoop(ChromeThread::IO)); - NotificationService::current()->RemoveObserver( - this, - NotificationType::SPELLCHECKER_REINITIALIZED, - Source<Profile>(static_cast<Profile*>(profile_))); } void ResourceMessageFilter::Init(int render_process_id) { @@ -169,10 +165,8 @@ void ResourceMessageFilter::OnFilterAdded(IPC::Channel* channel) { channel_ = channel; // Add the observers to intercept. - NotificationService::current()->AddObserver( - this, - NotificationType::SPELLCHECKER_REINITIALIZED, - Source<Profile>(static_cast<Profile*>(profile_))); + registrar_.Add(this, NotificationType::SPELLCHECKER_REINITIALIZED, + Source<Profile>(static_cast<Profile*>(profile_))); } // Called on the IPC thread: diff --git a/chrome/browser/renderer_host/resource_message_filter.h b/chrome/browser/renderer_host/resource_message_filter.h index 2f6629d..e9bd7a9 100644 --- a/chrome/browser/renderer_host/resource_message_filter.h +++ b/chrome/browser/renderer_host/resource_message_filter.h @@ -21,7 +21,7 @@ #include "chrome/browser/renderer_host/resource_dispatcher_host.h" #include "chrome/common/ipc_channel_proxy.h" #include "chrome/common/modal_dialog_event.h" -#include "chrome/common/notification_observer.h" +#include "chrome/common/notification_registrar.h" #include "chrome/common/transport_dib.h" #include "webkit/api/public/WebCache.h" @@ -225,6 +225,8 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter, // thread. static Clipboard* GetClipboard(); + NotificationRegistrar registrar_; + // The channel associated with the renderer connection. This pointer is not // owned by this class. IPC::Channel* channel_; diff --git a/chrome/browser/renderer_host/safe_browsing_resource_handler.cc b/chrome/browser/renderer_host/safe_browsing_resource_handler.cc index aabaf4a..b94fe49 100644 --- a/chrome/browser/renderer_host/safe_browsing_resource_handler.cc +++ b/chrome/browser/renderer_host/safe_browsing_resource_handler.cc @@ -29,8 +29,7 @@ SafeBrowsingResourceHandler::SafeBrowsingResourceHandler( safe_browsing_(safe_browsing), queued_error_request_id_(-1), rdh_(resource_dispatcher_host), - resource_type_(resource_type), - receiver_(receiver) { + resource_type_(resource_type) { if (safe_browsing_->CheckUrl(url, this)) { safe_browsing_result_ = SafeBrowsingService::URL_SAFE; safe_browsing_->LogPauseDelay(base::TimeDelta()); // No delay. @@ -40,22 +39,12 @@ SafeBrowsingResourceHandler::SafeBrowsingResourceHandler( // Can't pause now because it's too early, so we'll do it in OnWillRead. } - NotificationService::current()->AddObserver( - this, - NotificationType::RESOURCE_MESSAGE_FILTER_SHUTDOWN, - Source<ResourceMessageFilter>( - static_cast<ResourceMessageFilter*>(receiver_))); + registrar_.Add(this, NotificationType::RESOURCE_MESSAGE_FILTER_SHUTDOWN, + Source<ResourceMessageFilter>( + static_cast<ResourceMessageFilter*>(receiver))); } SafeBrowsingResourceHandler::~SafeBrowsingResourceHandler() { - NotificationService* notification_service = NotificationService::current(); - if (notification_service) { - notification_service->RemoveObserver( - this, - NotificationType::RESOURCE_MESSAGE_FILTER_SHUTDOWN, - Source<ResourceMessageFilter>( - static_cast<ResourceMessageFilter*>(receiver_))); - } } bool SafeBrowsingResourceHandler::OnUploadProgress(int request_id, diff --git a/chrome/browser/renderer_host/safe_browsing_resource_handler.h b/chrome/browser/renderer_host/safe_browsing_resource_handler.h index 19339a7..44018b1 100644 --- a/chrome/browser/renderer_host/safe_browsing_resource_handler.h +++ b/chrome/browser/renderer_host/safe_browsing_resource_handler.h @@ -11,7 +11,7 @@ #include "chrome/browser/renderer_host/resource_dispatcher_host.h" #include "chrome/browser/renderer_host/resource_handler.h" #include "chrome/browser/safe_browsing/safe_browsing_service.h" -#include "chrome/common/notification_observer.h" +#include "chrome/common/notification_registrar.h" // Checks that a url is safe. class SafeBrowsingResourceHandler : public ResourceHandler, @@ -55,6 +55,7 @@ class SafeBrowsingResourceHandler : public ResourceHandler, const NotificationDetails& details); private: + NotificationRegistrar registrar_; scoped_refptr<ResourceHandler> next_handler_; int render_process_host_id_; int render_view_id_; @@ -69,7 +70,6 @@ class SafeBrowsingResourceHandler : public ResourceHandler, ResourceDispatcherHost* rdh_; base::Time pause_time_; ResourceType::Type resource_type_; - ResourceDispatcherHost::Receiver* receiver_; DISALLOW_COPY_AND_ASSIGN(SafeBrowsingResourceHandler); }; |