| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // This file describes a central switchboard for notifications that might | 5 // This file describes a central switchboard for notifications that might |
| 6 // happen in various parts of the application, and allows users to register | 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. | 7 // observers for various classes of events that they're interested in. |
| 8 | 8 |
| 9 #ifndef CONTENT_COMMON_NOTIFICATION_SERVICE_H_ | 9 #ifndef CONTENT_COMMON_NOTIFICATION_SERVICE_H_ |
| 10 #define CONTENT_COMMON_NOTIFICATION_SERVICE_H_ | 10 #define CONTENT_COMMON_NOTIFICATION_SERVICE_H_ |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 // the notification. If no additional data is needed, NoDetails() is used. | 39 // the notification. If no additional data is needed, NoDetails() is used. |
| 40 // There is no particular order in which the observers will be notified. | 40 // There is no particular order in which the observers will be notified. |
| 41 void Notify(int type, | 41 void Notify(int type, |
| 42 const NotificationSource& source, | 42 const NotificationSource& source, |
| 43 const NotificationDetails& details); | 43 const NotificationDetails& details); |
| 44 | 44 |
| 45 // Returns a NotificationSource that represents all notification sources | 45 // Returns a NotificationSource that represents all notification sources |
| 46 // (for the purpose of registering an observer for events from all sources). | 46 // (for the purpose of registering an observer for events from all sources). |
| 47 static Source<void> AllSources() { return Source<void>(NULL); } | 47 static Source<void> AllSources() { return Source<void>(NULL); } |
| 48 | 48 |
| 49 // Returns the same value as AllSources(). This function has semantic |
| 50 // differences to the programmer: We have checked that this AllSources() |
| 51 // usage is safe in the face of multiple profiles. Objects that were |
| 52 // singletons now will always have multiple instances, one per profile. |
| 53 // |
| 54 // Some usage is safe, where the Source is checked to see if it's a member of |
| 55 // a container before use. But, we want the number of AllSources() calls to |
| 56 // drop to almost nothing, because most usages are not multiprofile safe and |
| 57 // were done because it was easier to listen to everything. |
| 58 static Source<void> AllBrowserContextsAndSources() { |
| 59 return Source<void>(NULL); |
| 60 } |
| 61 |
| 49 // Returns a NotificationDetails object that represents a lack of details | 62 // Returns a NotificationDetails object that represents a lack of details |
| 50 // associated with a notification. (This is effectively a null pointer.) | 63 // associated with a notification. (This is effectively a null pointer.) |
| 51 static Details<void> NoDetails() { return Details<void>(NULL); } | 64 static Details<void> NoDetails() { return Details<void>(NULL); } |
| 52 | 65 |
| 53 private: | 66 private: |
| 54 friend class NotificationRegistrar; | 67 friend class NotificationRegistrar; |
| 55 | 68 |
| 56 typedef ObserverList<NotificationObserver> NotificationObserverList; | 69 typedef ObserverList<NotificationObserver> NotificationObserverList; |
| 57 typedef std::map<uintptr_t, NotificationObserverList*> NotificationSourceMap; | 70 typedef std::map<uintptr_t, NotificationObserverList*> NotificationSourceMap; |
| 58 typedef std::map<int, NotificationSourceMap> NotificationObserverMap; | 71 typedef std::map<int, NotificationSourceMap> NotificationObserverMap; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 #ifndef NDEBUG | 115 #ifndef NDEBUG |
| 103 // Used to check to see that AddObserver and RemoveObserver calls are | 116 // Used to check to see that AddObserver and RemoveObserver calls are |
| 104 // balanced. | 117 // balanced. |
| 105 NotificationObserverCount observer_counts_; | 118 NotificationObserverCount observer_counts_; |
| 106 #endif | 119 #endif |
| 107 | 120 |
| 108 DISALLOW_COPY_AND_ASSIGN(NotificationService); | 121 DISALLOW_COPY_AND_ASSIGN(NotificationService); |
| 109 }; | 122 }; |
| 110 | 123 |
| 111 #endif // CONTENT_COMMON_NOTIFICATION_SERVICE_H_ | 124 #endif // CONTENT_COMMON_NOTIFICATION_SERVICE_H_ |
| OLD | NEW |