| 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 defines the type used to provide sources for NotificationService | 5 // This file defines the type used to provide sources for NotificationService |
| 6 // notifications. | 6 // notifications. |
| 7 | 7 |
| 8 #ifndef CONTENT_COMMON_NOTIFICATION_SOURCE_H_ | 8 #ifndef CONTENT_COMMON_NOTIFICATION_SOURCE_H_ |
| 9 #define CONTENT_COMMON_NOTIFICATION_SOURCE_H_ | 9 #define CONTENT_COMMON_NOTIFICATION_SOURCE_H_ |
| 10 #pragma once | 10 #pragma once |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "content/common/content_export.h" |
| 13 | 14 |
| 14 // Do not declare a NotificationSource directly--use either | 15 // Do not declare a NotificationSource directly--use either |
| 15 // "Source<sourceclassname>(sourceclasspointer)" or | 16 // "Source<sourceclassname>(sourceclasspointer)" or |
| 16 // NotificationService::AllSources(). | 17 // NotificationService::AllSources(). |
| 17 class NotificationSource { | 18 class CONTENT_EXPORT NotificationSource { |
| 18 public: | 19 public: |
| 19 NotificationSource(const NotificationSource& other); | 20 NotificationSource(const NotificationSource& other); |
| 20 ~NotificationSource(); | 21 ~NotificationSource(); |
| 21 | 22 |
| 22 // NotificationSource can be used as the index for a map; this method | 23 // NotificationSource can be used as the index for a map; this method |
| 23 // returns the pointer to the current source as an identifier, for use as a | 24 // returns the pointer to the current source as an identifier, for use as a |
| 24 // map index. | 25 // map index. |
| 25 uintptr_t map_key() const { return reinterpret_cast<uintptr_t>(ptr_); } | 26 uintptr_t map_key() const { return reinterpret_cast<uintptr_t>(ptr_); } |
| 26 | 27 |
| 27 bool operator!=(const NotificationSource& other) const { | 28 bool operator!=(const NotificationSource& other) const { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 46 Source(const T* ptr) : NotificationSource(ptr) {} // NOLINT | 47 Source(const T* ptr) : NotificationSource(ptr) {} // NOLINT |
| 47 Source(const NotificationSource& other) // NOLINT | 48 Source(const NotificationSource& other) // NOLINT |
| 48 : NotificationSource(other) {} | 49 : NotificationSource(other) {} |
| 49 | 50 |
| 50 T* operator->() const { return ptr(); } | 51 T* operator->() const { return ptr(); } |
| 51 // The casts here allow this to compile with both T = Foo and T = const Foo. | 52 // The casts here allow this to compile with both T = Foo and T = const Foo. |
| 52 T* ptr() const { return static_cast<T*>(const_cast<void*>(ptr_)); } | 53 T* ptr() const { return static_cast<T*>(const_cast<void*>(ptr_)); } |
| 53 }; | 54 }; |
| 54 | 55 |
| 55 #endif // CONTENT_COMMON_NOTIFICATION_SOURCE_H_ | 56 #endif // CONTENT_COMMON_NOTIFICATION_SOURCE_H_ |
| OLD | NEW |