diff options
author | bryeung@google.com <bryeung@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-03 03:53:54 +0000 |
---|---|---|
committer | bryeung@google.com <bryeung@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-03 03:53:54 +0000 |
commit | c0751438662d59e24eb79b4a484df4a3fce7d3cc (patch) | |
tree | d48fc6e2612d3f80a5e4934313d58c23e9b4156c /chrome/test/ui_test_utils.h | |
parent | c7b1d2fde3236b8438a326037af08e933eb68905 (diff) | |
download | chromium_src-c0751438662d59e24eb79b4a484df4a3fce7d3cc.zip chromium_src-c0751438662d59e24eb79b4a484df4a3fce7d3cc.tar.gz chromium_src-c0751438662d59e24eb79b4a484df4a3fce7d3cc.tar.bz2 |
Simplfy WindowedNotificationObserverWithDetails.
This change makes the interface to
WindowedNotificationObserverWithDetails closer to that of
WindowedNotificationObserver, which should make it easier to use more
broadly in testing utility code.
I have a follow-up CL that will be somewhat simplified by this change.
BUG=none
TEST=browser_tests compiles and passes
Review URL: http://codereview.chromium.org/5365008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68147 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/ui_test_utils.h')
-rw-r--r-- | chrome/test/ui_test_utils.h | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/chrome/test/ui_test_utils.h b/chrome/test/ui_test_utils.h index a1eb5bc..09b96f1 100644 --- a/chrome/test/ui_test_utils.h +++ b/chrome/test/ui_test_utils.h @@ -20,6 +20,7 @@ #include "chrome/common/notification_observer.h" #include "chrome/common/notification_registrar.h" #include "chrome/common/notification_service.h" +#include "chrome/common/notification_source.h" #include "chrome/test/automation/dom_element_proxy.h" #include "gfx/native_widget_types.h" @@ -393,17 +394,18 @@ class WindowedNotificationObserver : public NotificationObserver { // the details associated with the notification. // Note that in order to use that class the details class should be copiable, // which is the case with most notifications. -template <class T, class U> +template <class U> class WindowedNotificationObserverWithDetails : public WindowedNotificationObserver { public: WindowedNotificationObserverWithDetails(NotificationType notification_type, - const T* source) - : WindowedNotificationObserver(notification_type, Source<T>(source)) {} + const NotificationSource& source) + : WindowedNotificationObserver(notification_type, source) {} // Fills |details| with the details of the notification received for |source|. - bool GetDetailsFor(T* source, U* details) { - typename std::map<T*, U>::const_iterator iter = details_.find(source); + bool GetDetailsFor(const void* source, U* details) { + typename std::map<uintptr_t, U>::const_iterator iter = + details_.find(reinterpret_cast<uintptr_t>(source)); if (iter == details_.end()) return false; *details = iter->second; @@ -413,12 +415,12 @@ class WindowedNotificationObserverWithDetails virtual void Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { - details_[Source<T>(source).ptr()] = *Details<U>(details).ptr(); + details_[source.map_key()] = *Details<U>(details).ptr(); WindowedNotificationObserver::Observe(type, source, details); } private: - std::map<T*, U> details_; + std::map<uintptr_t, U> details_; DISALLOW_COPY_AND_ASSIGN(WindowedNotificationObserverWithDetails); }; |