summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-19 23:17:07 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-19 23:17:07 +0000
commitad50def5e1165d0cc74b98f988bbd5962587d9f4 (patch)
tree3a751abaed2cc056ca60b8b1e3ff54532a6f4d3f /content
parent75c920505ddfb2d49c194c76bde64edd6b3f91f2 (diff)
downloadchromium_src-ad50def5e1165d0cc74b98f988bbd5962587d9f4.zip
chromium_src-ad50def5e1165d0cc74b98f988bbd5962587d9f4.tar.gz
chromium_src-ad50def5e1165d0cc74b98f988bbd5962587d9f4.tar.bz2
Make NotificationService an interface in the content namespace, and switch callers to use it. Move the implementation to content/browser. Stop creating it in all child processes since it's only used in the browser.
BUG=98716 Review URL: http://codereview.chromium.org/8342048 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106403 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/appcache/chrome_appcache_service.cc4
-rw-r--r--content/browser/browser_child_process_host.cc6
-rw-r--r--content/browser/browser_main.cc4
-rw-r--r--content/browser/browser_process_sub_thread.cc4
-rw-r--r--content/browser/browser_process_sub_thread.h4
-rw-r--r--content/browser/cert_store.cc6
-rw-r--r--content/browser/debugger/render_view_devtools_agent_host.cc4
-rw-r--r--content/browser/debugger/worker_devtools_manager.cc4
-rw-r--r--content/browser/download/download_manager.cc4
-rw-r--r--content/browser/download/mhtml_generation_manager.cc4
-rw-r--r--content/browser/host_zoom_map.cc8
-rw-r--r--content/browser/mach_broker_mac.cc10
-rw-r--r--content/browser/notification_service_impl.cc (renamed from content/common/notification_service.cc)30
-rw-r--r--content/browser/notification_service_impl.h (renamed from content/common/notification_service.h)64
-rw-r--r--content/browser/notification_service_impl_unittest.cc (renamed from content/common/notification_service_unittest.cc)40
-rw-r--r--content/browser/plugin_service.cc4
-rw-r--r--content/browser/renderer_host/backing_store_manager.cc1
-rw-r--r--content/browser/renderer_host/browser_render_process_host.cc12
-rw-r--r--content/browser/renderer_host/render_message_filter.cc1
-rw-r--r--content/browser/renderer_host/render_process_host.cc6
-rw-r--r--content/browser/renderer_host/render_view_host.cc24
-rw-r--r--content/browser/renderer_host/render_widget_host.cc22
-rw-r--r--content/browser/renderer_host/render_widget_host_view_win.cc4
-rw-r--r--content/browser/renderer_host/resource_dispatcher_host.cc4
-rw-r--r--content/browser/renderer_host/resource_dispatcher_host_browsertest.cc3
-rw-r--r--content/browser/site_instance.cc8
-rw-r--r--content/browser/ssl/ssl_client_auth_handler.cc7
-rw-r--r--content/browser/ssl/ssl_manager.cc10
-rw-r--r--content/browser/tab_contents/interstitial_page.cc6
-rw-r--r--content/browser/tab_contents/navigation_controller.cc18
-rw-r--r--content/browser/tab_contents/render_view_host_manager.cc8
-rw-r--r--content/browser/tab_contents/tab_contents.cc38
-rw-r--r--content/browser/user_metrics.cc6
-rw-r--r--content/common/child_thread.cc6
-rw-r--r--content/common/child_thread.h3
-rw-r--r--content/content_browser.gypi3
-rw-r--r--content/content_common.gypi2
-rw-r--r--content/content_tests.gypi2
-rw-r--r--content/public/browser/DEPS3
-rw-r--r--content/public/browser/notification_registrar.cc10
-rw-r--r--content/public/browser/notification_service.h64
-rw-r--r--content/renderer/render_view_impl.cc1
-rw-r--r--content/test/content_test_suite.cc6
-rw-r--r--content/test/test_notification_tracker.cc6
44 files changed, 256 insertions, 228 deletions
diff --git a/content/browser/appcache/chrome_appcache_service.cc b/content/browser/appcache/chrome_appcache_service.cc
index 777ec03..08336ada 100644
--- a/content/browser/appcache/chrome_appcache_service.cc
+++ b/content/browser/appcache/chrome_appcache_service.cc
@@ -6,8 +6,8 @@
#include "base/file_path.h"
#include "base/file_util.h"
-#include "content/common/notification_service.h"
#include "content/public/browser/content_browser_client.h"
+#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
#include "net/base/net_errors.h"
#include "webkit/quota/quota_manager.h"
@@ -28,7 +28,7 @@ void ChromeAppCacheService::InitializeOnIOThread(
resource_context_ = resource_context;
registrar_.Add(
this, content::NOTIFICATION_PURGE_MEMORY,
- NotificationService::AllSources());
+ content::NotificationService::AllSources());
// Init our base class.
Initialize(cache_path_,
diff --git a/content/browser/browser_child_process_host.cc b/content/browser/browser_child_process_host.cc
index e2e99a5..7b79495 100644
--- a/content/browser/browser_child_process_host.cc
+++ b/content/browser/browser_child_process_host.cc
@@ -16,7 +16,7 @@
#include "content/browser/browser_thread.h"
#include "content/browser/renderer_host/resource_message_filter.h"
#include "content/browser/trace_message_filter.h"
-#include "content/common/notification_service.h"
+#include "content/public/browser/notification_service.h"
#include "content/common/plugin_messages.h"
#include "content/common/process_watcher.h"
#include "content/common/result_codes.h"
@@ -44,8 +44,8 @@ class ChildNotificationTask : public Task {
: notification_type_(notification_type), info_(*info) { }
virtual void Run() {
- NotificationService::current()->
- Notify(notification_type_, NotificationService::AllSources(),
+ content::NotificationService::current()->
+ Notify(notification_type_, content::NotificationService::AllSources(),
content::Details<ChildProcessInfo>(&info_));
}
diff --git a/content/browser/browser_main.cc b/content/browser/browser_main.cc
index 8c75d2a..5bccf00 100644
--- a/content/browser/browser_main.cc
+++ b/content/browser/browser_main.cc
@@ -14,9 +14,9 @@
#include "base/threading/thread_restrictions.h"
#include "base/tracked_objects.h"
#include "content/browser/browser_thread.h"
+#include "content/browser/notification_service_impl.h"
#include "content/common/hi_res_timer_manager.h"
#include "content/common/main_function_params.h"
-#include "content/common/notification_service.h"
#include "content/common/result_codes.h"
#include "content/common/sandbox_policy.h"
#include "content/public/browser/content_browser_client.h"
@@ -375,7 +375,7 @@ bool ExitedMainMessageLoop() {
int BrowserMain(const MainFunctionParams& parameters) {
TRACE_EVENT_BEGIN_ETW("BrowserMain", 0, "");
- NotificationService main_notification_service;
+ NotificationServiceImpl main_notification_service;
scoped_ptr<content::BrowserMainParts> parts(
content::GetContentClient()->browser()->CreateBrowserMainParts(
diff --git a/content/browser/browser_process_sub_thread.cc b/content/browser/browser_process_sub_thread.cc
index ed904a3..f748d08 100644
--- a/content/browser/browser_process_sub_thread.cc
+++ b/content/browser/browser_process_sub_thread.cc
@@ -5,7 +5,7 @@
#include "content/browser/browser_process_sub_thread.h"
#include "build/build_config.h"
-#include "content/common/notification_service.h"
+#include "content/browser/notification_service_impl.h"
#if defined(OS_WIN)
#include <Objbase.h>
@@ -26,7 +26,7 @@ void BrowserProcessSubThread::Init() {
CoInitialize(NULL);
#endif
- notification_service_ = new NotificationService;
+ notification_service_ = new NotificationServiceImpl;
}
void BrowserProcessSubThread::CleanUp() {
diff --git a/content/browser/browser_process_sub_thread.h b/content/browser/browser_process_sub_thread.h
index bfaab3f..adbda97 100644
--- a/content/browser/browser_process_sub_thread.h
+++ b/content/browser/browser_process_sub_thread.h
@@ -10,7 +10,9 @@
#include "content/browser/browser_thread.h"
#include "content/common/content_export.h"
+namespace content {
class NotificationService;
+}
// ----------------------------------------------------------------------------
// BrowserProcessSubThread
@@ -34,7 +36,7 @@ class CONTENT_EXPORT BrowserProcessSubThread : public BrowserThread {
// Each specialized thread has its own notification service.
// Note: We don't use scoped_ptr because the destructor runs on the wrong
// thread.
- NotificationService* notification_service_;
+ content::NotificationService* notification_service_;
DISALLOW_COPY_AND_ASSIGN(BrowserProcessSubThread);
};
diff --git a/content/browser/cert_store.cc b/content/browser/cert_store.cc
index 22c8c47..2caf2f14 100644
--- a/content/browser/cert_store.cc
+++ b/content/browser/cert_store.cc
@@ -10,7 +10,7 @@
#include "base/stl_util.h"
#include "content/browser/renderer_host/render_process_host.h"
#include "content/browser/renderer_host/render_view_host.h"
-#include "content/common/notification_service.h"
+#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
template <typename T>
@@ -37,9 +37,9 @@ CertStore::CertStore() : next_cert_id_(1) {
// is not used anymore.
registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
- NotificationService::AllBrowserContextsAndSources());
+ content::NotificationService::AllBrowserContextsAndSources());
registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
- NotificationService::AllBrowserContextsAndSources());
+ content::NotificationService::AllBrowserContextsAndSources());
}
CertStore::~CertStore() {
diff --git a/content/browser/debugger/render_view_devtools_agent_host.cc b/content/browser/debugger/render_view_devtools_agent_host.cc
index 1adf627..8eff4c7 100644
--- a/content/browser/debugger/render_view_devtools_agent_host.cc
+++ b/content/browser/debugger/render_view_devtools_agent_host.cc
@@ -12,8 +12,8 @@
#include "content/browser/site_instance.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "content/common/devtools_messages.h"
-#include "content/common/notification_service.h"
#include "content/public/browser/content_browser_client.h"
+#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
RenderViewDevToolsAgentHost::Instances RenderViewDevToolsAgentHost::instances_;
@@ -54,7 +54,7 @@ void RenderViewDevToolsAgentHost::SendMessageToAgent(IPC::Message* msg) {
}
void RenderViewDevToolsAgentHost::NotifyClientClosing() {
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_DEVTOOLS_WINDOW_CLOSING,
content::Source<content::BrowserContext>(
render_view_host_->site_instance()->GetProcess()->browser_context()),
diff --git a/content/browser/debugger/worker_devtools_manager.cc b/content/browser/debugger/worker_devtools_manager.cc
index 9f5e626..c0e01b7 100644
--- a/content/browser/debugger/worker_devtools_manager.cc
+++ b/content/browser/debugger/worker_devtools_manager.cc
@@ -17,7 +17,7 @@
#include "content/common/devtools_messages.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
-#include "content/common/notification_service.h"
+#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
class WorkerDevToolsManager::AgentHosts
@@ -54,7 +54,7 @@ public:
private:
AgentHosts() {
registrar_.Add(this, content::NOTIFICATION_APP_TERMINATING,
- NotificationService::AllSources());
+ content::NotificationService::AllSources());
}
~AgentHosts() {}
diff --git a/content/browser/download/download_manager.cc b/content/browser/download/download_manager.cc
index c875a56..7f31385 100644
--- a/content/browser/download/download_manager.cc
+++ b/content/browser/download/download_manager.cc
@@ -31,8 +31,8 @@
#include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/renderer_host/resource_dispatcher_host.h"
#include "content/browser/tab_contents/tab_contents.h"
-#include "content/common/notification_service.h"
#include "content/public/browser/content_browser_client.h"
+#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
namespace {
@@ -1073,7 +1073,7 @@ void DownloadManager::SavePageDownloadFinished(DownloadItem* download) {
save_page_downloads_.erase(download->id());
if (download->IsComplete())
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_SAVE_PACKAGE_SUCCESSFULLY_FINISHED,
content::Source<DownloadManager>(this),
content::Details<DownloadItem>(download));
diff --git a/content/browser/download/mhtml_generation_manager.cc b/content/browser/download/mhtml_generation_manager.cc
index 2802c24..3c8f76c 100644
--- a/content/browser/download/mhtml_generation_manager.cc
+++ b/content/browser/download/mhtml_generation_manager.cc
@@ -8,7 +8,7 @@
#include "content/browser/renderer_host/render_process_host.h"
#include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/tab_contents/tab_contents.h"
-#include "content/common/notification_service.h"
+#include "content/public/browser/notification_service.h"
#include "content/common/view_messages.h"
#include "content/public/browser/notification_types.h"
@@ -113,7 +113,7 @@ void MHTMLGenerationManager::JobFinished(int job_id, int64 file_size) {
details.file_path = job.file_path;
details.file_size = file_size;
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_MHTML_GENERATED,
content::Source<RenderViewHost>(rvh),
content::Details<NotificationDetails>(&details));
diff --git a/content/browser/host_zoom_map.cc b/content/browser/host_zoom_map.cc
index 6aa228b..19b64f1 100644
--- a/content/browser/host_zoom_map.cc
+++ b/content/browser/host_zoom_map.cc
@@ -12,7 +12,7 @@
#include "content/browser/browser_thread.h"
#include "content/browser/renderer_host/render_process_host.h"
#include "content/browser/renderer_host/render_view_host.h"
-#include "content/common/notification_service.h"
+#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
#include "googleurl/src/gurl.h"
#include "net/base/net_util.h"
@@ -41,7 +41,7 @@ HostZoomMap::HostZoomMap(HostZoomMap* original)
void HostZoomMap::Init() {
registrar_.Add(
this, content::NOTIFICATION_RENDER_VIEW_HOST_WILL_CLOSE_RENDER_VIEW,
- NotificationService::AllSources());
+ content::NotificationService::AllSources());
}
double HostZoomMap::GetZoomLevel(const std::string& host) const {
@@ -61,7 +61,7 @@ void HostZoomMap::SetZoomLevel(std::string host, double level) {
host_zoom_levels_[host] = level;
}
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_ZOOM_LEVEL_CHANGED,
content::Source<HostZoomMap>(this),
content::Details<const std::string>(&host));
@@ -109,7 +109,7 @@ void HostZoomMap::SetTemporaryZoomLevel(int render_process_id,
}
std::string host;
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_ZOOM_LEVEL_CHANGED,
content::Source<HostZoomMap>(this),
content::Details<const std::string>(&host));
diff --git a/content/browser/mach_broker_mac.cc b/content/browser/mach_broker_mac.cc
index 2dbd1c8..6905c7f 100644
--- a/content/browser/mach_broker_mac.cc
+++ b/content/browser/mach_broker_mac.cc
@@ -15,7 +15,7 @@
#include "content/browser/browser_thread.h"
#include "content/browser/renderer_host/render_process_host.h"
#include "content/common/child_process_info.h"
-#include "content/common/notification_service.h"
+#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
#include "content/public/common/content_switches.h"
@@ -36,16 +36,16 @@ class RegisterNotificationTask : public Task {
virtual void Run() {
broker_->registrar_.Add(broker_,
content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
- NotificationService::AllBrowserContextsAndSources());
+ content::NotificationService::AllBrowserContextsAndSources());
broker_->registrar_.Add(broker_,
content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
- NotificationService::AllBrowserContextsAndSources());
+ content::NotificationService::AllBrowserContextsAndSources());
broker_->registrar_.Add(broker_,
content::NOTIFICATION_CHILD_PROCESS_CRASHED,
- NotificationService::AllBrowserContextsAndSources());
+ content::NotificationService::AllBrowserContextsAndSources());
broker_->registrar_.Add(broker_,
content::NOTIFICATION_CHILD_PROCESS_HOST_DISCONNECTED,
- NotificationService::AllBrowserContextsAndSources());
+ content::NotificationService::AllBrowserContextsAndSources());
}
private:
diff --git a/content/common/notification_service.cc b/content/browser/notification_service_impl.cc
index 81ad733..795cb30 100644
--- a/content/common/notification_service.cc
+++ b/content/browser/notification_service_impl.cc
@@ -2,33 +2,38 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "content/common/notification_service.h"
+#include "content/browser/notification_service_impl.h"
#include "base/lazy_instance.h"
#include "base/threading/thread_local.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_types.h"
-static base::LazyInstance<base::ThreadLocalPointer<NotificationService> >
+static base::LazyInstance<base::ThreadLocalPointer<NotificationServiceImpl> >
lazy_tls_ptr(base::LINKER_INITIALIZED);
// static
-NotificationService* NotificationService::current() {
+NotificationServiceImpl* NotificationServiceImpl::current() {
return lazy_tls_ptr.Pointer()->Get();
}
// static
-bool NotificationService::HasKey(const NotificationSourceMap& map,
+content::NotificationService* content::NotificationService::current() {
+ return NotificationServiceImpl::current();
+}
+
+// static
+bool NotificationServiceImpl::HasKey(const NotificationSourceMap& map,
const content::NotificationSource& source) {
return map.find(source.map_key()) != map.end();
}
-NotificationService::NotificationService() {
+NotificationServiceImpl::NotificationServiceImpl() {
DCHECK(current() == NULL);
lazy_tls_ptr.Pointer()->Set(this);
}
-void NotificationService::AddObserver(
+void NotificationServiceImpl::AddObserver(
content::NotificationObserver* observer,
int type,
const content::NotificationSource& source) {
@@ -53,12 +58,12 @@ void NotificationService::AddObserver(
#endif
}
-void NotificationService::RemoveObserver(
+void NotificationServiceImpl::RemoveObserver(
content::NotificationObserver* observer,
int type,
const content::NotificationSource& source) {
// This is a very serious bug. An object is most likely being deleted on
- // the wrong thread, and as a result another thread's NotificationService
+ // the wrong thread, and as a result another thread's NotificationServiceImpl
// has its deleted pointer in its map. A garbge object will be called in the
// future.
// NOTE: when this check shows crashes, use BrowserThread::DeleteOnIOThread or
@@ -77,9 +82,10 @@ void NotificationService::RemoveObserver(
// TODO(jhughes): Remove observer list from map if empty?
}
-void NotificationService::Notify(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
+void NotificationServiceImpl::Notify(
+ int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) {
DCHECK(type > content::NOTIFICATION_ALL) <<
"Allowed for observing, but not posting.";
@@ -118,7 +124,7 @@ void NotificationService::Notify(int type,
}
-NotificationService::~NotificationService() {
+NotificationServiceImpl::~NotificationServiceImpl() {
lazy_tls_ptr.Pointer()->Set(NULL);
#ifndef NDEBUG
diff --git a/content/common/notification_service.h b/content/browser/notification_service_impl.h
index ae8e87f..0898234 100644
--- a/content/common/notification_service.h
+++ b/content/browser/notification_service_impl.h
@@ -2,75 +2,35 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// This file describes a central switchboard for notifications that might
-// happen in various parts of the application, and allows users to register
-// observers for various classes of events that they're interested in.
-
-#ifndef CONTENT_COMMON_NOTIFICATION_SERVICE_H_
-#define CONTENT_COMMON_NOTIFICATION_SERVICE_H_
+#ifndef CONTENT_PUBLIC_BROWSER_NOTIFICATION_SERVICE_IMPL_H_
+#define CONTENT_PUBLIC_BROWSER_NOTIFICATION_SERVICE_IMPL_H_
#pragma once
#include <map>
#include "base/observer_list.h"
#include "content/common/content_export.h"
-#include "content/public/browser/notification_details.h"
-#include "content/public/browser/notification_source.h"
+#include "content/public/browser/notification_service.h"
namespace content {
class NotificationObserver;
class NotificationRegistrar;
}
-class CONTENT_EXPORT NotificationService {
+class NotificationServiceImpl : public content::NotificationService {
public:
- // Returns the NotificationService object for the current thread, or NULL if
- // none.
- static NotificationService* current();
+ static NotificationServiceImpl* current();
// Normally instantiated when the thread is created. Not all threads have
// a NotificationService. Only one instance should be created per thread.
- NotificationService();
- ~NotificationService();
-
- // Synchronously posts a notification to all interested observers.
- // Source is a reference to a NotificationSource object representing
- // the object originating the notification (can be
- // NotificationService::AllSources(), in which case
- // only observers interested in all sources will be notified).
- // Details is a reference to an object containing additional data about
- // the notification. If no additional data is needed, NoDetails() is used.
- // There is no particular order in which the observers will be notified.
- void Notify(int type,
+ NotificationServiceImpl();
+ virtual ~NotificationServiceImpl();
+
+ // content::NotificationService
+ virtual void Notify(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details);
- // Returns a NotificationSource that represents all notification sources
- // (for the purpose of registering an observer for events from all sources).
- static content::Source<void> AllSources() {
- return content::Source<void>(NULL);
- }
-
- // Returns the same value as AllSources(). This function has semantic
- // differences to the programmer: We have checked that this AllSources()
- // usage is safe in the face of multiple profiles. Objects that were
- // singletons now will always have multiple instances, one per browser
- // context.
- //
- // Some usage is safe, where the Source is checked to see if it's a member of
- // a container before use. But, we want the number of AllSources() calls to
- // drop to almost nothing, because most usages are not multiprofile safe and
- // were done because it was easier to listen to everything.
- static content::Source<void> AllBrowserContextsAndSources() {
- return content::Source<void>(NULL);
- }
-
- // Returns a NotificationDetails object that represents a lack of details
- // associated with a notification. (This is effectively a null pointer.)
- static content::Details<void> NoDetails() {
- return content::Details<void>(NULL);
- }
-
private:
friend class content::NotificationRegistrar;
@@ -126,7 +86,7 @@ class CONTENT_EXPORT NotificationService {
NotificationObserverCount observer_counts_;
#endif
- DISALLOW_COPY_AND_ASSIGN(NotificationService);
+ DISALLOW_COPY_AND_ASSIGN(NotificationServiceImpl);
};
-#endif // CONTENT_COMMON_NOTIFICATION_SERVICE_H_
+#endif // CONTENT_PUBLIC_BROWSER_NOTIFICATION_SERVICE_IMPL_H_
diff --git a/content/common/notification_service_unittest.cc b/content/browser/notification_service_impl_unittest.cc
index 2cafd37..62a0e51 100644
--- a/content/common/notification_service_unittest.cc
+++ b/content/browser/notification_service_impl_unittest.cc
@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "content/browser/notification_service_impl.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
-#include "content/common/notification_service.h"
#include "content/public/browser/notification_types.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -32,12 +32,12 @@ private:
} // namespace
-class NotificationServiceTest : public testing::Test {
+class NotificationServiceImplTest : public testing::Test {
protected:
content::NotificationRegistrar registrar_;
};
-TEST_F(NotificationServiceTest, Basic) {
+TEST_F(NotificationServiceImplTest, Basic) {
TestSource test_source;
TestSource other_source;
@@ -53,15 +53,16 @@ TEST_F(NotificationServiceTest, Basic) {
TestObserver idle_test_source;
// Make sure it doesn't freak out when there are no observers.
- NotificationService* service = NotificationService::current();
+ content::NotificationService* service =
+ content::NotificationService::current();
service->Notify(content::NOTIFICATION_IDLE,
content::Source<TestSource>(&test_source),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
registrar_.Add(&all_types_all_sources, content::NOTIFICATION_ALL,
- NotificationService::AllSources());
+ content::NotificationService::AllSources());
registrar_.Add(&idle_all_sources, content::NOTIFICATION_IDLE,
- NotificationService::AllSources());
+ content::NotificationService::AllSources());
registrar_.Add(&all_types_test_source, content::NOTIFICATION_ALL,
content::Source<TestSource>(&test_source));
registrar_.Add(&idle_test_source, content::NOTIFICATION_IDLE,
@@ -74,7 +75,7 @@ TEST_F(NotificationServiceTest, Basic) {
service->Notify(content::NOTIFICATION_IDLE,
content::Source<TestSource>(&test_source),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
EXPECT_EQ(1, all_types_all_sources.notification_count());
EXPECT_EQ(1, idle_all_sources.notification_count());
@@ -83,7 +84,7 @@ TEST_F(NotificationServiceTest, Basic) {
service->Notify(content::NOTIFICATION_BUSY,
content::Source<TestSource>(&test_source),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
EXPECT_EQ(2, all_types_all_sources.notification_count());
EXPECT_EQ(1, idle_all_sources.notification_count());
@@ -92,7 +93,7 @@ TEST_F(NotificationServiceTest, Basic) {
service->Notify(content::NOTIFICATION_IDLE,
content::Source<TestSource>(&other_source),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
EXPECT_EQ(3, all_types_all_sources.notification_count());
EXPECT_EQ(2, idle_all_sources.notification_count());
@@ -101,7 +102,7 @@ TEST_F(NotificationServiceTest, Basic) {
service->Notify(content::NOTIFICATION_BUSY,
content::Source<TestSource>(&other_source),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
EXPECT_EQ(4, all_types_all_sources.notification_count());
EXPECT_EQ(2, idle_all_sources.notification_count());
@@ -110,8 +111,8 @@ TEST_F(NotificationServiceTest, Basic) {
// Try send with NULL source.
service->Notify(content::NOTIFICATION_IDLE,
- NotificationService::AllSources(),
- NotificationService::NoDetails());
+ content::NotificationService::AllSources(),
+ content::NotificationService::NoDetails());
EXPECT_EQ(5, all_types_all_sources.notification_count());
EXPECT_EQ(3, idle_all_sources.notification_count());
@@ -122,7 +123,7 @@ TEST_F(NotificationServiceTest, Basic) {
service->Notify(content::NOTIFICATION_IDLE,
content::Source<TestSource>(&test_source),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
EXPECT_EQ(5, all_types_all_sources.notification_count());
EXPECT_EQ(3, idle_all_sources.notification_count());
@@ -130,12 +131,13 @@ TEST_F(NotificationServiceTest, Basic) {
EXPECT_EQ(1, idle_test_source.notification_count());
}
-TEST_F(NotificationServiceTest, MultipleRegistration) {
+TEST_F(NotificationServiceImplTest, MultipleRegistration) {
TestSource test_source;
TestObserver idle_test_source;
- NotificationService* service = NotificationService::current();
+ content::NotificationService* service =
+ content::NotificationService::current();
registrar_.Add(&idle_test_source, content::NOTIFICATION_IDLE,
content::Source<TestSource>(&test_source));
@@ -144,7 +146,7 @@ TEST_F(NotificationServiceTest, MultipleRegistration) {
service->Notify(content::NOTIFICATION_IDLE,
content::Source<TestSource>(&test_source),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
EXPECT_EQ(2, idle_test_source.notification_count());
registrar_.Remove(&idle_test_source, content::NOTIFICATION_IDLE,
@@ -152,7 +154,7 @@ TEST_F(NotificationServiceTest, MultipleRegistration) {
service->Notify(content::NOTIFICATION_IDLE,
content::Source<TestSource>(&test_source),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
EXPECT_EQ(3, idle_test_source.notification_count());
registrar_.Remove(&idle_test_source, content::NOTIFICATION_ALL,
@@ -160,6 +162,6 @@ TEST_F(NotificationServiceTest, MultipleRegistration) {
service->Notify(content::NOTIFICATION_IDLE,
content::Source<TestSource>(&test_source),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
EXPECT_EQ(3, idle_test_source.notification_count());
}
diff --git a/content/browser/plugin_service.cc b/content/browser/plugin_service.cc
index b88bed2..378ee28 100644
--- a/content/browser/plugin_service.cc
+++ b/content/browser/plugin_service.cc
@@ -24,7 +24,7 @@
#include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/resource_context.h"
#include "content/browser/utility_process_host.h"
-#include "content/common/notification_service.h"
+#include "content/public/browser/notification_service.h"
#include "content/common/pepper_plugin_registry.h"
#include "content/common/plugin_messages.h"
#include "content/common/utility_messages.h"
@@ -131,7 +131,7 @@ PluginService::PluginService()
// We need to know when the browser comes forward so we can bring modal plugin
// windows forward too.
registrar_.Add(this, content::NOTIFICATION_APP_ACTIVATED,
- NotificationService::AllSources());
+ content::NotificationService::AllSources());
#endif
}
diff --git a/content/browser/renderer_host/backing_store_manager.cc b/content/browser/renderer_host/backing_store_manager.cc
index 16e84b5..c6dedd4 100644
--- a/content/browser/renderer_host/backing_store_manager.cc
+++ b/content/browser/renderer_host/backing_store_manager.cc
@@ -9,7 +9,6 @@
#include "base/sys_info.h"
#include "content/browser/renderer_host/backing_store.h"
#include "content/browser/renderer_host/render_widget_host.h"
-#include "content/common/notification_service.h"
#include "content/public/common/content_switches.h"
namespace {
diff --git a/content/browser/renderer_host/browser_render_process_host.cc b/content/browser/renderer_host/browser_render_process_host.cc
index 7711a50..f5b10a9 100644
--- a/content/browser/renderer_host/browser_render_process_host.cc
+++ b/content/browser/renderer_host/browser_render_process_host.cc
@@ -72,7 +72,7 @@
#include "content/common/child_process_info.h"
#include "content/common/child_process_messages.h"
#include "content/common/gpu/gpu_messages.h"
-#include "content/common/notification_service.h"
+#include "content/public/browser/notification_service.h"
#include "content/common/process_watcher.h"
#include "content/common/resource_messages.h"
#include "content/common/result_codes.h"
@@ -870,7 +870,7 @@ void BrowserRenderProcessHost::ProcessDied(
// already handled the error.
RendererClosedDetails details(status, exit_code, was_alive);
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
content::Source<RenderProcessHost>(this),
content::Details<RendererClosedDetails>(&details));
@@ -900,10 +900,10 @@ void BrowserRenderProcessHost::OnShutdownRequest() {
// Notify any tabs that might have swapped out renderers from this process.
// They should not attempt to swap them back in.
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_RENDERER_PROCESS_CLOSING,
content::Source<RenderProcessHost>(this),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
Send(new ChildProcessMsg_Shutdown());
}
@@ -965,10 +965,10 @@ void BrowserRenderProcessHost::OnProcessLaunched() {
// The queued messages contain such things as "navigate". If this notification
// was after, we can end up executing JavaScript before the initialization
// happens.
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_RENDERER_PROCESS_CREATED,
content::Source<RenderProcessHost>(this),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
while (!queued_messages_.empty()) {
Send(queued_messages_.front());
diff --git a/content/browser/renderer_host/render_message_filter.cc b/content/browser/renderer_host/render_message_filter.cc
index 1e67aba..5f3e5cd 100644
--- a/content/browser/renderer_host/render_message_filter.cc
+++ b/content/browser/renderer_host/render_message_filter.cc
@@ -31,7 +31,6 @@
#include "content/common/child_process_host.h"
#include "content/common/child_process_messages.h"
#include "content/common/desktop_notification_messages.h"
-#include "content/common/notification_service.h"
#include "content/common/view_messages.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/common/content_switches.h"
diff --git a/content/browser/renderer_host/render_process_host.cc b/content/browser/renderer_host/render_process_host.cc
index 1969e35..d9ce96b 100644
--- a/content/browser/renderer_host/render_process_host.cc
+++ b/content/browser/renderer_host/render_process_host.cc
@@ -13,8 +13,8 @@
#include "content/browser/webui/web_ui_factory.h"
#include "content/common/child_process_info.h"
#include "content/common/content_constants.h"
-#include "content/common/notification_service.h"
#include "content/public/browser/content_browser_client.h"
+#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
#include "content/public/common/content_switches.h"
@@ -149,10 +149,10 @@ void RenderProcessHost::Release(int listener_id) {
void RenderProcessHost::Cleanup() {
// When no other owners of this object, we can delete ourselves
if (listeners_.IsEmpty()) {
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
content::Source<RenderProcessHost>(this),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
MessageLoop::current()->DeleteSoon(FROM_HERE, this);
deleting_soon_ = true;
// It's important not to wait for the DeleteTask to delete the channel
diff --git a/content/browser/renderer_host/render_view_host.cc b/content/browser/renderer_host/render_view_host.cc
index 5fa3bb6..8135f5e 100644
--- a/content/browser/renderer_host/render_view_host.cc
+++ b/content/browser/renderer_host/render_view_host.cc
@@ -33,7 +33,7 @@
#include "content/common/content_constants.h"
#include "content/common/desktop_notification_messages.h"
#include "content/common/drag_messages.h"
-#include "content/common/notification_service.h"
+#include "content/public/browser/notification_service.h"
#include "content/common/result_codes.h"
#include "content/common/speech_input_messages.h"
#include "content/common/swapped_out_messages.h"
@@ -131,20 +131,20 @@ RenderViewHost::RenderViewHost(SiteInstance* instance,
content::GetContentClient()->browser()->RenderViewHostCreated(this);
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_RENDER_VIEW_HOST_CREATED,
content::Source<RenderViewHost>(this),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
}
RenderViewHost::~RenderViewHost() {
FOR_EACH_OBSERVER(
RenderViewHostObserver, observers_, RenderViewHostDestruction());
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_RENDER_VIEW_HOST_DELETED,
content::Source<RenderViewHost>(this),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
ClearPowerSaveBlockers();
@@ -370,10 +370,10 @@ void RenderViewHost::ClosePage() {
if (IsRenderViewLive()) {
// TODO(creis): Should this be moved to Shutdown? It may not be called for
// RenderViewHosts that have been swapped out.
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_RENDER_VIEW_HOST_WILL_CLOSE_RENDER_VIEW,
content::Source<RenderViewHost>(this),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
Send(new ViewMsg_ClosePage(routing_id()));
} else {
@@ -1074,10 +1074,10 @@ void RenderViewHost::OnUpdateDragCursor(WebDragOperation current_op) {
}
void RenderViewHost::OnTargetDropACK() {
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_RENDER_VIEW_HOST_DID_RECEIVE_DRAG_TARGET_DROP_ACK,
content::Source<RenderViewHost>(this),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
}
void RenderViewHost::OnTakeFocus(bool reverse) {
@@ -1344,10 +1344,10 @@ void RenderViewHost::OnAccessibilityNotifications(
}
}
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
content::Source<RenderViewHost>(this),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
}
Send(new ViewMsg_AccessibilityNotifications_ACK(routing_id()));
@@ -1361,7 +1361,7 @@ void RenderViewHost::OnScriptEvalResponse(int id, const ListValue& result) {
return;
}
std::pair<int, Value*> details(id, result_value);
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_EXECUTE_JAVASCRIPT_RESULT,
content::Source<RenderViewHost>(this),
content::Details<std::pair<int, Value*> >(&details));
diff --git a/content/browser/renderer_host/render_widget_host.cc b/content/browser/renderer_host/render_widget_host.cc
index b98a702..c826f07 100644
--- a/content/browser/renderer_host/render_widget_host.cc
+++ b/content/browser/renderer_host/render_widget_host.cc
@@ -21,7 +21,7 @@
#include "content/browser/renderer_host/render_widget_host_view.h"
#include "content/browser/user_metrics.h"
#include "content/common/gpu/gpu_messages.h"
-#include "content/common/notification_service.h"
+#include "content/public/browser/notification_service.h"
#include "content/common/result_codes.h"
#include "content/common/view_messages.h"
#include "content/public/browser/native_web_keyboard_event.h"
@@ -265,7 +265,7 @@ void RenderWidgetHost::WasHidden() {
process_->WidgetHidden();
bool is_visible = false;
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED,
content::Source<RenderWidgetHost>(this),
content::Details<bool>(&is_visible));
@@ -300,7 +300,7 @@ void RenderWidgetHost::WasRestored() {
process_->WidgetRestored();
bool is_visible = true;
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED,
content::Source<RenderWidgetHost>(this),
content::Details<bool>(&is_visible));
@@ -833,10 +833,10 @@ bool RenderWidgetHost::IsFullscreen() const {
}
void RenderWidgetHost::Destroy() {
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED,
content::Source<RenderWidgetHost>(this),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
// Tell the view to die.
// Note that in the process of the view shutting down, it can call a ton
@@ -861,10 +861,10 @@ void RenderWidgetHost::CheckRendererIsUnresponsive() {
}
// OK, looks like we have a hung renderer!
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_RENDERER_PROCESS_HANG,
content::Source<RenderWidgetHost>(this),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
is_unresponsive_ = true;
NotifyRendererUnresponsive();
}
@@ -934,7 +934,7 @@ void RenderWidgetHost::OnMsgRequestMove(const gfx::Rect& pos) {
void RenderWidgetHost::OnMsgPaintAtSizeAck(int tag, const gfx::Size& size) {
PaintAtSizeAckDetails details = {tag, size};
gfx::Size size_details = size;
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_RENDER_WIDGET_HOST_DID_RECEIVE_PAINT_AT_SIZE_ACK,
content::Source<RenderWidgetHost>(this),
content::Details<PaintAtSizeAckDetails>(&details));
@@ -1038,10 +1038,10 @@ void RenderWidgetHost::OnMsgUpdateRect(
view_being_painted_ = false;
}
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_RENDER_WIDGET_HOST_DID_PAINT,
content::Source<RenderWidgetHost>(this),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
// If we got a resize ack, then perhaps we have another resize to send?
if (is_resize_ack && view_) {
@@ -1090,7 +1090,7 @@ void RenderWidgetHost::OnMsgInputEventAck(WebInputEvent::Type event_type,
}
}
// This is used only for testing.
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_RENDER_WIDGET_HOST_DID_RECEIVE_INPUT_EVENT_ACK,
content::Source<RenderWidgetHost>(this),
content::Details<int>(&type));
diff --git a/content/browser/renderer_host/render_widget_host_view_win.cc b/content/browser/renderer_host/render_widget_host_view_win.cc
index 9087bb0..ec83c95 100644
--- a/content/browser/renderer_host/render_widget_host_view_win.cc
+++ b/content/browser/renderer_host/render_widget_host_view_win.cc
@@ -24,7 +24,7 @@
#include "content/browser/renderer_host/backing_store_win.h"
#include "content/browser/renderer_host/render_process_host.h"
#include "content/browser/renderer_host/render_widget_host.h"
-#include "content/common/notification_service.h"
+#include "content/public/browser/notification_service.h"
#include "content/common/plugin_messages.h"
#include "content/common/view_messages.h"
#include "content/public/browser/content_browser_client.h"
@@ -236,7 +236,7 @@ RenderWidgetHostViewWin::RenderWidgetHostViewWin(RenderWidgetHost* widget)
render_widget_host_->SetView(this);
registrar_.Add(this,
content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
- NotificationService::AllBrowserContextsAndSources());
+ content::NotificationService::AllBrowserContextsAndSources());
}
RenderWidgetHostViewWin::~RenderWidgetHostViewWin() {
diff --git a/content/browser/renderer_host/resource_dispatcher_host.cc b/content/browser/renderer_host/resource_dispatcher_host.cc
index e15bf14..626d310 100644
--- a/content/browser/renderer_host/resource_dispatcher_host.cc
+++ b/content/browser/renderer_host/resource_dispatcher_host.cc
@@ -51,7 +51,7 @@
#include "content/browser/ssl/ssl_client_auth_handler.h"
#include "content/browser/ssl/ssl_manager.h"
#include "content/browser/worker_host/worker_service.h"
-#include "content/common/notification_service.h"
+#include "content/public/browser/notification_service.h"
#include "content/common/resource_messages.h"
#include "content/common/view_messages.h"
#include "content/public/browser/content_browser_client.h"
@@ -1904,7 +1904,7 @@ void ResourceDispatcherHost::NotifyOnUI(int type,
RenderViewHost::FromID(render_process_id, render_view_id);
if (rvh) {
RenderViewHostDelegate* rvhd = rvh->delegate();
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
type, content::Source<RenderViewHostDelegate>(rvhd),
content::Details<T>(detail));
}
diff --git a/content/browser/renderer_host/resource_dispatcher_host_browsertest.cc b/content/browser/renderer_host/resource_dispatcher_host_browsertest.cc
index 98ed614..d2b5ffe 100644
--- a/content/browser/renderer_host/resource_dispatcher_host_browsertest.cc
+++ b/content/browser/renderer_host/resource_dispatcher_host_browsertest.cc
@@ -8,6 +8,7 @@
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/browser/tab_contents/tab_contents.h"
+#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
#include "net/test/test_server.h"
@@ -31,7 +32,7 @@ bool ResourceDispatcherHostBrowserTest::GetPopupTitle(const GURL& url,
ui_test_utils::WindowedNotificationObserver observer(
content::NOTIFICATION_TAB_ADDED,
- NotificationService::AllSources());
+ content::NotificationService::AllSources());
// Create dynamic popup.
if (!ui_test_utils::ExecuteJavaScript(
diff --git a/content/browser/site_instance.cc b/content/browser/site_instance.cc
index 8f65c4d..ad79d74 100644
--- a/content/browser/site_instance.cc
+++ b/content/browser/site_instance.cc
@@ -7,8 +7,8 @@
#include "content/browser/browsing_instance.h"
#include "content/browser/renderer_host/browser_render_process_host.h"
#include "content/browser/webui/web_ui_factory.h"
-#include "content/common/notification_service.h"
#include "content/public/browser/content_browser_client.h"
+#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
#include "content/public/common/url_constants.h"
#include "net/base/registry_controlled_domain.h"
@@ -38,14 +38,14 @@ SiteInstance::SiteInstance(BrowsingInstance* browsing_instance)
DCHECK(browsing_instance);
registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
- NotificationService::AllBrowserContextsAndSources());
+ content::NotificationService::AllBrowserContextsAndSources());
}
SiteInstance::~SiteInstance() {
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_SITE_INSTANCE_DELETED,
content::Source<SiteInstance>(this),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
// Now that no one is referencing us, we can safely remove ourselves from
// the BrowsingInstance. Any future visits to a page from this site
diff --git a/content/browser/ssl/ssl_client_auth_handler.cc b/content/browser/ssl/ssl_client_auth_handler.cc
index 667e3ba..f4bfe3d 100644
--- a/content/browser/ssl/ssl_client_auth_handler.cc
+++ b/content/browser/ssl/ssl_client_auth_handler.cc
@@ -9,8 +9,8 @@
#include "content/browser/renderer_host/resource_dispatcher_host.h"
#include "content/browser/renderer_host/resource_dispatcher_host_request_info.h"
#include "content/browser/ssl/ssl_client_auth_notification_details.h"
-#include "content/common/notification_service.h"
#include "content/public/browser/content_browser_client.h"
+#include "content/public/browser/notification_service.h"
#include "net/base/x509_certificate.h"
#include "net/url_request/url_request.h"
@@ -58,7 +58,8 @@ void SSLClientAuthHandler::CertificateSelected(net::X509Certificate* cert) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
SSLClientAuthNotificationDetails details(cert_request_info_, cert);
- NotificationService* service = NotificationService::current();
+ content::NotificationService* service =
+ content::NotificationService::current();
service->Notify(content::NOTIFICATION_SSL_CLIENT_AUTH_CERT_SELECTED,
content::Source<SSLClientAuthHandler>(this),
content::Details<SSLClientAuthNotificationDetails>(&details));
@@ -141,7 +142,7 @@ void SSLClientAuthObserver::StartObserving() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
notification_registrar_.Add(
this, content::NOTIFICATION_SSL_CLIENT_AUTH_CERT_SELECTED,
- NotificationService::AllSources());
+ content::NotificationService::AllSources());
}
void SSLClientAuthObserver::StopObserving() {
diff --git a/content/browser/ssl/ssl_manager.cc b/content/browser/ssl/ssl_manager.cc
index 19c0546..f4abf54 100644
--- a/content/browser/ssl/ssl_manager.cc
+++ b/content/browser/ssl/ssl_manager.cc
@@ -18,7 +18,7 @@
#include "content/browser/tab_contents/navigation_entry.h"
#include "content/browser/tab_contents/provisional_load_details.h"
#include "content/browser/tab_contents/tab_contents.h"
-#include "content/common/notification_service.h"
+#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h"
#include "net/base/cert_status_flags.h"
@@ -50,10 +50,10 @@ void SSLManager::OnSSLCertificateError(ResourceDispatcherHost* rdh,
// static
void SSLManager::NotifySSLInternalStateChanged(
NavigationController* controller) {
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_SSL_INTERNAL_STATE_CHANGED,
content::Source<content::BrowserContext>(controller->browser_context()),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
}
// static
@@ -250,9 +250,9 @@ void SSLManager::UpdateEntry(NavigationEntry* entry) {
policy()->UpdateEntry(entry, controller_->tab_contents());
if (!entry->ssl().Equals(original_ssl_status)) {
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_SSL_VISIBLE_STATE_CHANGED,
content::Source<NavigationController>(controller_),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
}
}
diff --git a/content/browser/tab_contents/interstitial_page.cc b/content/browser/tab_contents/interstitial_page.cc
index 851288ca..3a8568b 100644
--- a/content/browser/tab_contents/interstitial_page.cc
+++ b/content/browser/tab_contents/interstitial_page.cc
@@ -22,7 +22,7 @@
#include "content/browser/tab_contents/tab_contents.h"
#include "content/browser/tab_contents/tab_contents_view.h"
#include "content/common/dom_storage_common.h"
-#include "content/common/notification_service.h"
+#include "content/public/browser/notification_service.h"
#include "content/common/view_messages.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/notification_source.h"
@@ -348,10 +348,10 @@ void InterstitialPage::DidNavigate(
// after the interstitial page was registered with |tab_|, since there will be
// a callback to |tab_| testing if an interstitial page is showing before
// hiding the bookmark bar.
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_INTERSTITIAL_ATTACHED,
content::Source<TabContents>(tab_),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
RenderWidgetHostView* rwh_view = tab_->render_view_host()->view();
diff --git a/content/browser/tab_contents/navigation_controller.cc b/content/browser/tab_contents/navigation_controller.cc
index 4e78f36..c2d5185 100644
--- a/content/browser/tab_contents/navigation_controller.cc
+++ b/content/browser/tab_contents/navigation_controller.cc
@@ -21,7 +21,7 @@
#include "content/browser/tab_contents/tab_contents_delegate.h"
#include "content/browser/user_metrics.h"
#include "content/common/content_constants.h"
-#include "content/common/notification_service.h"
+#include "content/public/browser/notification_service.h"
#include "content/common/view_messages.h"
#include "content/public/browser/notification_types.h"
#include "net/base/escape.h"
@@ -42,7 +42,7 @@ void NotifyPrunedEntries(NavigationController* nav_controller,
content::PrunedDetails details;
details.from_front = from_front;
details.count = count;
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_NAV_LIST_PRUNED,
content::Source<NavigationController>(nav_controller),
content::Details<content::PrunedDetails>(&details));
@@ -133,10 +133,10 @@ NavigationController::NavigationController(
NavigationController::~NavigationController() {
DiscardNonCommittedEntriesInternal();
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_TAB_CLOSED,
content::Source<NavigationController>(this),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
}
void NavigationController::Restore(
@@ -183,10 +183,10 @@ void NavigationController::ReloadInternal(bool check_for_repost,
// The user is asking to reload a page with POST data. Prompt to make sure
// they really want to do this. If they do, the dialog will call us back
// with check_for_repost = false.
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_REPOST_WARNING_SHOWN,
content::Source<NavigationController>(this),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
pending_reload_ = reload_type;
tab_contents_->Activate();
@@ -274,7 +274,7 @@ void NavigationController::LoadEntry(NavigationEntry* entry) {
// result in a download or a 'no content' response (e.g., a mailto: URL).
DiscardNonCommittedEntriesInternal();
pending_entry_ = entry;
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_NAV_ENTRY_PENDING,
content::Source<NavigationController>(this),
content::Details<NavigationEntry>(entry));
@@ -1139,7 +1139,7 @@ void NavigationController::NotifyNavigationEntryCommitted(
// notification below instead.
tab_contents_->NotifyNavigationStateChanged(kInvalidateAll);
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_NAV_ENTRY_COMMITTED,
content::Source<NavigationController>(this),
notification_details);
@@ -1171,7 +1171,7 @@ void NavigationController::NotifyEntryChanged(const NavigationEntry* entry,
content::EntryChangedDetails det;
det.changed_entry = entry;
det.index = index;
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_NAV_ENTRY_CHANGED,
content::Source<NavigationController>(this),
content::Details<content::EntryChangedDetails>(&det));
diff --git a/content/browser/tab_contents/render_view_host_manager.cc b/content/browser/tab_contents/render_view_host_manager.cc
index 977d749..2627862 100644
--- a/content/browser/tab_contents/render_view_host_manager.cc
+++ b/content/browser/tab_contents/render_view_host_manager.cc
@@ -16,7 +16,7 @@
#include "content/browser/tab_contents/tab_contents_view.h"
#include "content/browser/webui/web_ui.h"
#include "content/browser/webui/web_ui_factory.h"
-#include "content/common/notification_service.h"
+#include "content/public/browser/notification_service.h"
#include "content/common/view_messages.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/notification_types.h"
@@ -69,7 +69,7 @@ void RenderViewHostManager::Init(content::BrowserContext* browser_context,
// Keep track of renderer processes as they start to shut down.
registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSING,
- NotificationService::AllSources());
+ content::NotificationService::AllSources());
}
RenderWidgetHostView* RenderViewHostManager::GetRenderWidgetHostView() const {
@@ -112,7 +112,7 @@ RenderViewHost* RenderViewHostManager::Navigate(const NavigationEntry& entry) {
RenderViewHostSwitchedDetails details;
details.new_host = render_view_host_;
details.old_host = NULL;
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
content::Source<NavigationController>(
&delegate_->GetControllerForRenderManager()),
@@ -613,7 +613,7 @@ void RenderViewHostManager::CommitPending() {
RenderViewHostSwitchedDetails details;
details.new_host = render_view_host_;
details.old_host = old_render_view_host;
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
content::Source<NavigationController>(
&delegate_->GetControllerForRenderManager()),
diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc
index 5b98734..371cf89 100644
--- a/content/browser/tab_contents/tab_contents.cc
+++ b/content/browser/tab_contents/tab_contents.cc
@@ -41,7 +41,7 @@
#include "content/common/content_constants.h"
#include "content/common/content_restriction.h"
#include "content/common/intents_messages.h"
-#include "content/common/notification_service.h"
+#include "content/public/browser/notification_service.h"
#include "content/common/view_messages.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/navigation_types.h"
@@ -222,10 +222,10 @@ TabContents::~TabContents() {
NotifyDisconnected();
// Notify any observer that have a reference on this tab contents.
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_TAB_CONTENTS_DESTROYED,
content::Source<TabContents>(this),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
// TODO(brettw) this should be moved to the view.
#if defined(OS_WIN)
@@ -451,10 +451,10 @@ void TabContents::WasHidden() {
rwhv->WasHidden();
}
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_TAB_CONTENTS_HIDDEN,
content::Source<TabContents>(this),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
}
void TabContents::Activate() {
@@ -983,7 +983,7 @@ void TabContents::OnDidFailProvisionalLoadWithError(
params.frame_id);
details.set_error_code(params.error_code);
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_FAIL_PROVISIONAL_LOAD_WITH_ERROR,
content::Source<NavigationController>(&controller_),
content::Details<ProvisionalLoadDetails>(&details));
@@ -1017,7 +1017,7 @@ void TabContents::OnDidLoadResourceFromMemoryCache(
LoadFromMemoryCacheDetails details(url, GetRenderProcessHost()->id(),
cert_id, cert_status);
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_LOAD_FROM_MEMORY_CACHE,
content::Source<NavigationController>(&controller_),
content::Details<LoadFromMemoryCacheDetails>(&details));
@@ -1090,7 +1090,7 @@ void TabContents::OnUpdateZoomLimits(int minimum_percent,
}
void TabContents::OnFocusedNodeChanged(bool is_editable_node) {
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE,
content::Source<TabContents>(this),
content::Details<const bool>(&is_editable_node));
@@ -1177,10 +1177,10 @@ void TabContents::SetIsLoading(bool is_loading,
int type = is_loading ? content::NOTIFICATION_LOAD_START :
content::NOTIFICATION_LOAD_STOP;
- content::NotificationDetails det = NotificationService::NoDetails();
+ content::NotificationDetails det = content::NotificationService::NoDetails();
if (details)
det = content::Details<LoadNotificationDetails>(details);
- NotificationService::current()->Notify(type,
+ content::NotificationService::current()->Notify(type,
content::Source<NavigationController>(&controller_),
det);
}
@@ -1348,7 +1348,7 @@ bool TabContents::UpdateTitleForEntry(NavigationEntry* entry,
TitleUpdatedDetails details(entry, explicit_set);
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_TAB_CONTENTS_TITLE_UPDATED,
content::Source<TabContents>(this),
content::Details<TitleUpdatedDetails>(&details));
@@ -1361,18 +1361,18 @@ void TabContents::NotifySwapped() {
// notification so that clients that pick up a pointer to |this| can NULL the
// pointer. See Bug 1230284.
notify_disconnection_ = true;
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_TAB_CONTENTS_SWAPPED,
content::Source<TabContents>(this),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
}
void TabContents::NotifyConnected() {
notify_disconnection_ = true;
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_TAB_CONTENTS_CONNECTED,
content::Source<TabContents>(this),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
}
void TabContents::NotifyDisconnected() {
@@ -1380,10 +1380,10 @@ void TabContents::NotifyDisconnected() {
return;
notify_disconnection_ = false;
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_TAB_CONTENTS_DISCONNECTED,
content::Source<TabContents>(this),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
}
RenderViewHostDelegate::View* TabContents::GetViewDelegate() {
@@ -1409,7 +1409,7 @@ content::ViewType TabContents::GetRenderViewType() const {
}
void TabContents::RenderViewCreated(RenderViewHost* render_view_host) {
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB,
content::Source<TabContents>(this),
content::Details<RenderViewHost>(render_view_host));
@@ -1678,7 +1678,7 @@ void TabContents::DidChangeLoadProgress(double progress) {
void TabContents::DocumentOnLoadCompletedInMainFrame(
RenderViewHost* render_view_host,
int32 page_id) {
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
content::Source<TabContents>(this),
content::Details<int>(&page_id));
diff --git a/content/browser/user_metrics.cc b/content/browser/user_metrics.cc
index 7224b89..d58c666 100644
--- a/content/browser/user_metrics.cc
+++ b/content/browser/user_metrics.cc
@@ -5,7 +5,7 @@
#include "content/browser/user_metrics.h"
#include "content/browser/browser_thread.h"
-#include "content/common/notification_service.h"
+#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
void UserMetrics::RecordAction(const UserMetricsAction& action) {
@@ -24,9 +24,9 @@ void UserMetrics::Record(const char *action) {
return;
}
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_USER_ACTION,
- NotificationService::AllSources(),
+ content::NotificationService::AllSources(),
content::Details<const char*>(&action));
}
diff --git a/content/common/child_thread.cc b/content/common/child_thread.cc
index ff34f0b..93e7e14 100644
--- a/content/common/child_thread.cc
+++ b/content/common/child_thread.cc
@@ -11,7 +11,6 @@
#include "content/common/child_process_messages.h"
#include "content/common/child_trace_message_filter.h"
#include "content/common/file_system/file_system_dispatcher.h"
-#include "content/common/notification_service.h"
#include "content/common/quota_dispatcher.h"
#include "content/common/resource_dispatcher.h"
#include "content/common/socket_stream_dispatcher.h"
@@ -58,11 +57,6 @@ void ChildThread::Init() {
new IPC::SyncMessageFilter(ChildProcess::current()->GetShutDownEvent());
channel_->AddFilter(sync_message_filter_.get());
channel_->AddFilter(new ChildTraceMessageFilter());
-
- // When running in unit tests, there is already a NotificationService object.
- // Since only one can exist at a time per thread, check first.
- if (!NotificationService::current())
- notification_service_.reset(new NotificationService);
}
ChildThread::~ChildThread() {
diff --git a/content/common/child_thread.h b/content/common/child_thread.h
index a58fecf..970ce97 100644
--- a/content/common/child_thread.h
+++ b/content/common/child_thread.h
@@ -15,7 +15,6 @@
class FileSystemDispatcher;
class MessageLoop;
-class NotificationService;
class QuotaDispatcher;
class ResourceDispatcher;
class SocketStreamDispatcher;
@@ -133,8 +132,6 @@ class CONTENT_EXPORT ChildThread : public IPC::Channel::Listener,
MessageLoop* message_loop_;
- scoped_ptr<NotificationService> notification_service_;
-
scoped_ptr<FileSystemDispatcher> file_system_dispatcher_;
scoped_ptr<QuotaDispatcher> quota_dispatcher_;
diff --git a/content/content_browser.gypi b/content/content_browser.gypi
index b45d17f..c90f834 100644
--- a/content/content_browser.gypi
+++ b/content/content_browser.gypi
@@ -276,6 +276,8 @@
'browser/net/url_request_slow_download_job.h',
'browser/net/url_request_slow_http_job.cc',
'browser/net/url_request_slow_http_job.h',
+ 'browser/notification_service_impl.cc',
+ 'browser/notification_service_impl.h',
'browser/plugin_loader_posix.cc',
'browser/plugin_loader_posix.h',
'browser/plugin_process_host.cc',
@@ -569,6 +571,7 @@
'public/browser/notification_observer.h',
'public/browser/notification_registrar.cc',
'public/browser/notification_registrar.h',
+ 'public/browser/notification_service.h',
'public/browser/notification_source.h',
'public/browser/notification_types.h',
],
diff --git a/content/content_common.gypi b/content/content_common.gypi
index 5026187..cf4eadd9 100644
--- a/content/content_common.gypi
+++ b/content/content_common.gypi
@@ -160,8 +160,6 @@
'common/navigation_gesture.h',
'common/net/url_fetcher.cc',
'common/net/url_fetcher.h',
- 'common/notification_service.cc',
- 'common/notification_service.h',
'common/np_channel_base.cc',
'common/np_channel_base.h',
'common/npobject_base.h',
diff --git a/content/content_tests.gypi b/content/content_tests.gypi
index 4956d6c..8acc1d96 100644
--- a/content/content_tests.gypi
+++ b/content/content_tests.gypi
@@ -153,6 +153,7 @@
'browser/in_process_webkit/webkit_thread_unittest.cc',
'browser/mac/closure_blocks_leopard_compat_unittest.cc',
'browser/mach_broker_mac_unittest.cc',
+ 'browser/notification_service_impl_unittest.cc',
'browser/renderer_host/accelerated_plugin_view_mac_unittest.mm',
'browser/renderer_host/gtk_key_bindings_handler_unittest.cc',
'browser/renderer_host/media/audio_input_device_manager_unittest.cc',
@@ -180,7 +181,6 @@
'common/gpu/gpu_info_unittest.cc',
'common/hi_res_timer_manager_unittest.cc',
'common/net/url_fetcher_unittest.cc',
- 'common/notification_service_unittest.cc',
'common/process_watcher_unittest.cc',
'common/property_bag_unittest.cc',
'common/resource_dispatcher_unittest.cc',
diff --git a/content/public/browser/DEPS b/content/public/browser/DEPS
new file mode 100644
index 0000000..a549956
--- /dev/null
+++ b/content/public/browser/DEPS
@@ -0,0 +1,3 @@
+include_rules = [
+ "+content/browser/notification_service_impl.h",
+]
diff --git a/content/public/browser/notification_registrar.cc b/content/public/browser/notification_registrar.cc
index 069b6a2..d539902 100644
--- a/content/public/browser/notification_registrar.cc
+++ b/content/public/browser/notification_registrar.cc
@@ -8,7 +8,7 @@
#include "base/logging.h"
#include "base/threading/platform_thread.h"
-#include "content/common/notification_service.h"
+#include "content/browser/notification_service_impl.h"
namespace {
@@ -45,7 +45,7 @@ NotificationRegistrar::NotificationRegistrar() {
// AtExitManager before any objects which access it via NotificationRegistrar.
// This in turn means it will be destroyed after these objects, so they will
// never try to access the NotificationService after it's been destroyed.
- NotificationService::current();
+ NotificationServiceImpl::current();
}
NotificationRegistrar::~NotificationRegistrar() {
@@ -60,7 +60,7 @@ void NotificationRegistrar::Add(NotificationObserver* observer,
Record record = { observer, type, source, base::PlatformThread::CurrentId() };
registered_.push_back(record);
- NotificationService::current()->AddObserver(observer, type, source);
+ NotificationServiceImpl::current()->AddObserver(observer, type, source);
}
void NotificationRegistrar::Remove(NotificationObserver* observer,
@@ -80,7 +80,7 @@ void NotificationRegistrar::Remove(NotificationObserver* observer,
// This can be NULL if our owner outlives the NotificationService, e.g. if our
// owner is a Singleton.
- NotificationService* service = NotificationService::current();
+ NotificationServiceImpl* service = NotificationServiceImpl::current();
if (service)
service->RemoveObserver(observer, type, source);
}
@@ -98,7 +98,7 @@ void NotificationRegistrar::RemoveAll() {
// This can be NULL if our owner outlives the NotificationService, e.g. if our
// owner is a Singleton.
- NotificationService* service = NotificationService::current();
+ NotificationServiceImpl* service = NotificationServiceImpl::current();
if (service) {
for (size_t i = 0; i < registered_.size(); i++) {
CheckCalledOnValidThread(registered_[i].thread_id);
diff --git a/content/public/browser/notification_service.h b/content/public/browser/notification_service.h
new file mode 100644
index 0000000..2b19e2fd
--- /dev/null
+++ b/content/public/browser/notification_service.h
@@ -0,0 +1,64 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This file describes a central switchboard for notifications that might
+// happen in various parts of the application, and allows users to register
+// observers for various classes of events that they're interested in.
+
+#ifndef CONTENT_PUBLIC_NOTIFICATION_SERVICE_H_
+#define CONTENT_PUBLIC_NOTIFICATION_SERVICE_H_
+#pragma once
+
+#include "content/common/content_export.h"
+#include "content/public/browser/notification_details.h"
+#include "content/public/browser/notification_source.h"
+
+namespace content {
+
+class NotificationService {
+ public:
+ // Returns the NotificationService object for the current thread, or NULL if
+ // none.
+ static CONTENT_EXPORT NotificationService* current();
+
+ virtual ~NotificationService() {}
+
+ // Synchronously posts a notification to all interested observers.
+ // Source is a reference to a NotificationSource object representing
+ // the object originating the notification (can be
+ // NotificationService::AllSources(), in which case
+ // only observers interested in all sources will be notified).
+ // Details is a reference to an object containing additional data about
+ // the notification. If no additional data is needed, NoDetails() is used.
+ // There is no particular order in which the observers will be notified.
+ virtual void Notify(int type,
+ const NotificationSource& source,
+ const NotificationDetails& details) = 0;
+
+ // Returns a NotificationSource that represents all notification sources
+ // (for the purpose of registering an observer for events from all sources).
+ static Source<void> AllSources() { return Source<void>(NULL); }
+
+ // Returns the same value as AllSources(). This function has semantic
+ // differences to the programmer: We have checked that this AllSources()
+ // usage is safe in the face of multiple profiles. Objects that were
+ // singletons now will always have multiple instances, one per browser
+ // context.
+ //
+ // Some usage is safe, where the Source is checked to see if it's a member of
+ // a container before use. But, we want the number of AllSources() calls to
+ // drop to almost nothing, because most usages are not multiprofile safe and
+ // were done because it was easier to listen to everything.
+ static Source<void> AllBrowserContextsAndSources() {
+ return Source<void>(NULL);
+ }
+
+ // Returns a NotificationDetails object that represents a lack of details
+ // associated with a notification. (This is effectively a null pointer.)
+ static Details<void> NoDetails() { return content::Details<void>(NULL); }
+};
+
+} // namespace content
+
+#endif // CONTENT_COMMON_NOTIFICATION_SERVICE_H_
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index 9d1b766..b71be63 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -32,7 +32,6 @@
#include "content/common/file_system/file_system_dispatcher.h"
#include "content/common/file_system/webfilesystem_callback_dispatcher.h"
#include "content/common/intents_messages.h"
-#include "content/common/notification_service.h"
#include "content/common/pepper_messages.h"
#include "content/common/pepper_plugin_registry.h"
#include "content/common/quota_dispatcher.h"
diff --git a/content/test/content_test_suite.cc b/content/test/content_test_suite.cc
index f089ea5..11588c1 100644
--- a/content/test/content_test_suite.cc
+++ b/content/test/content_test_suite.cc
@@ -8,7 +8,7 @@
#include "base/memory/scoped_ptr.h"
#include "content/browser/mock_content_browser_client.h"
#include "content/common/content_paths.h"
-#include "content/common/notification_service.h"
+#include "content/browser/notification_service_impl.h"
#include "content/public/common/content_client.h"
#include "content/test/test_content_client.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -22,7 +22,7 @@ class TestContentClientInitializer : public testing::EmptyTestEventListener {
}
virtual void OnTestStart(const testing::TestInfo& test_info) OVERRIDE {
- notification_service_.reset(new NotificationService());
+ notification_service_.reset(new NotificationServiceImpl());
DCHECK(!content::GetContentClient());
content_client_.reset(new TestContentClient);
@@ -43,7 +43,7 @@ class TestContentClientInitializer : public testing::EmptyTestEventListener {
}
private:
- scoped_ptr<NotificationService> notification_service_;
+ scoped_ptr<NotificationServiceImpl> notification_service_;
scoped_ptr<content::ContentClient> content_client_;
scoped_ptr<content::ContentBrowserClient> content_browser_client_;
diff --git a/content/test/test_notification_tracker.cc b/content/test/test_notification_tracker.cc
index 46906c061..04de93f 100644
--- a/content/test/test_notification_tracker.cc
+++ b/content/test/test_notification_tracker.cc
@@ -4,13 +4,13 @@
#include "content/test/test_notification_tracker.h"
-#include "content/common/notification_service.h"
+#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
TestNotificationTracker::Event::Event()
: type(content::NOTIFICATION_ALL),
- source(NotificationService::AllSources()),
- details(NotificationService::NoDetails()) {
+ source(content::NotificationService::AllSources()),
+ details(content::NotificationService::NoDetails()) {
}
TestNotificationTracker::Event::Event(int t,
content::NotificationSource s,