Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef CONTENT_COMMON_NOTIFICATION_REGISTRAR_H_ | 5 #ifndef CONTENT_COMMON_NOTIFICATION_REGISTRAR_H_ |
| 6 #define CONTENT_COMMON_NOTIFICATION_REGISTRAR_H_ | 6 #define CONTENT_COMMON_NOTIFICATION_REGISTRAR_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "content/common/content_notification_types.h" | 12 #include "content/common/content_notification_types.h" |
| 13 #include "content/common/content_export.h" | |
|
darin (slow to review)
2011/09/04 15:41:04
nit: "export" before "notification"
Dirk Pranke
2011/09/07 01:46:07
Done.
| |
| 13 | 14 |
| 14 class NotificationObserver; | 15 class NotificationObserver; |
| 15 class NotificationSource; | 16 class NotificationSource; |
| 16 | 17 |
| 17 // Aids in registering for notifications and ensures that all registered | 18 // Aids in registering for notifications and ensures that all registered |
| 18 // notifications are unregistered when the class is destroyed. | 19 // notifications are unregistered when the class is destroyed. |
| 19 // | 20 // |
| 20 // The intended use is that you make a NotificationRegistrar member in your | 21 // The intended use is that you make a NotificationRegistrar member in your |
| 21 // class and use it to register your notifications instead of going through the | 22 // class and use it to register your notifications instead of going through the |
| 22 // notification service directly. It will automatically unregister them for | 23 // notification service directly. It will automatically unregister them for |
| 23 // you. | 24 // you. |
| 24 class NotificationRegistrar { | 25 class CONTENT_EXPORT NotificationRegistrar { |
| 25 public: | 26 public: |
| 26 // This class must not be derived from (we don't have a virtual destructor so | 27 // This class must not be derived from (we don't have a virtual destructor so |
| 27 // it won't work). Instead, use it as a member in your class. | 28 // it won't work). Instead, use it as a member in your class. |
| 28 NotificationRegistrar(); | 29 NotificationRegistrar(); |
| 29 ~NotificationRegistrar(); | 30 ~NotificationRegistrar(); |
| 30 | 31 |
| 31 // Wrappers around NotificationService::[Add|Remove]Observer. | 32 // Wrappers around NotificationService::[Add|Remove]Observer. |
| 32 void Add(NotificationObserver* observer, | 33 void Add(NotificationObserver* observer, |
| 33 int type, | 34 int type, |
| 34 const NotificationSource& source); | 35 const NotificationSource& source); |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 57 // notifications anyway. | 58 // notifications anyway. |
| 58 typedef std::vector<Record> RecordVector; | 59 typedef std::vector<Record> RecordVector; |
| 59 | 60 |
| 60 // Lists all notifications we're currently registered for. | 61 // Lists all notifications we're currently registered for. |
| 61 RecordVector registered_; | 62 RecordVector registered_; |
| 62 | 63 |
| 63 DISALLOW_COPY_AND_ASSIGN(NotificationRegistrar); | 64 DISALLOW_COPY_AND_ASSIGN(NotificationRegistrar); |
| 64 }; | 65 }; |
| 65 | 66 |
| 66 #endif // CONTENT_COMMON_NOTIFICATION_REGISTRAR_H_ | 67 #endif // CONTENT_COMMON_NOTIFICATION_REGISTRAR_H_ |
| OLD | NEW |