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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // This file describes a central switchboard for notifications that might
6 // happen in various parts of the application, and allows users to register
7 // observers for various classes of events that they're interested in.
8
9 #ifndef CONTENT_PUBLIC_NOTIFICATION_SERVICE_H_
10 #define CONTENT_PUBLIC_NOTIFICATION_SERVICE_H_
11 #pragma once
12
13 #include "content/common/content_export.h"
14 #include "content/public/browser/notification_details.h"
15 #include "content/public/browser/notification_source.h"
16
17 namespace content {
18
19 class NotificationService {
20 public:
21 // Returns the NotificationService object for the current thread, or NULL if
22 // none.
23 static CONTENT_EXPORT NotificationService* current();
24
25 virtual ~NotificationService() {}
26
27 // Synchronously posts a notification to all interested observers.
28 // Source is a reference to a NotificationSource object representing
29 // the object originating the notification (can be
30 // NotificationService::AllSources(), in which case
31 // only observers interested in all sources will be notified).
32 // Details is a reference to an object containing additional data about
33 // the notification. If no additional data is needed, NoDetails() is used.
34 // There is no particular order in which the observers will be notified.
35 virtual void Notify(int type,
36 const NotificationSource& source,
37 const NotificationDetails& details) = 0;
Avi (use Gerrit) 2011/10/19 21:49:18 alignment
38
39 // Returns a NotificationSource that represents all notification sources
40 // (for the purpose of registering an observer for events from all sources).
41 static Source<void> AllSources() { return Source<void>(NULL); }
42
43 // Returns the same value as AllSources(). This function has semantic
44 // differences to the programmer: We have checked that this AllSources()
45 // usage is safe in the face of multiple profiles. Objects that were
46 // singletons now will always have multiple instances, one per browser
47 // context.
48 //
49 // Some usage is safe, where the Source is checked to see if it's a member of
50 // a container before use. But, we want the number of AllSources() calls to
51 // drop to almost nothing, because most usages are not multiprofile safe and
52 // were done because it was easier to listen to everything.
53 static Source<void> AllBrowserContextsAndSources() {
54 return Source<void>(NULL);
55 }
56
57 // Returns a NotificationDetails object that represents a lack of details
58 // associated with a notification. (This is effectively a null pointer.)
59 static Details<void> NoDetails() { return content::Details<void>(NULL); }
60 };
61
62 } // namespace content
63
64 #endif // CONTENT_COMMON_NOTIFICATION_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698