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

Unified Diff: content/public/browser/notification_service.h

Issue 8342048: Make NotificationService an interface in the content namespace, and switch callers to use it. Mov... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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
« no previous file with comments | « content/public/browser/notification_registrar.cc ('k') | content/renderer/render_view_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/browser/notification_service.h
===================================================================
--- content/public/browser/notification_service.h (revision 0)
+++ content/public/browser/notification_service.h (revision 0)
@@ -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_
Property changes on: content\public\browser\notification_service.h
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « content/public/browser/notification_registrar.cc ('k') | content/renderer/render_view_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698