diff options
Diffstat (limited to 'content/common')
-rw-r--r-- | content/common/notification_details.cc | 18 | ||||
-rw-r--r-- | content/common/notification_details.h | 58 | ||||
-rw-r--r-- | content/common/notification_observer.h | 26 | ||||
-rw-r--r-- | content/common/notification_observer_mock.cc | 12 | ||||
-rw-r--r-- | content/common/notification_observer_mock.h | 25 | ||||
-rw-r--r-- | content/common/notification_registrar.cc | 121 | ||||
-rw-r--r-- | content/common/notification_registrar.h | 66 | ||||
-rw-r--r-- | content/common/notification_service.cc | 34 | ||||
-rw-r--r-- | content/common/notification_service.h | 37 | ||||
-rw-r--r-- | content/common/notification_service_unittest.cc | 50 |
10 files changed, 63 insertions, 384 deletions
diff --git a/content/common/notification_details.cc b/content/common/notification_details.cc deleted file mode 100644 index 6a399ae..0000000 --- a/content/common/notification_details.cc +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "content/common/notification_details.h" - -NotificationDetails::NotificationDetails() : ptr_(NULL) { -} - -NotificationDetails::NotificationDetails(const NotificationDetails& other) - : ptr_(other.ptr_) { -} - -NotificationDetails::NotificationDetails(const void* ptr) : ptr_(ptr) { -} - -NotificationDetails::~NotificationDetails() { -} diff --git a/content/common/notification_details.h b/content/common/notification_details.h deleted file mode 100644 index 50c7b23..0000000 --- a/content/common/notification_details.h +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// This file defines the type used to provide details for NotificationService -// notifications. - -#ifndef CONTENT_COMMON_NOTIFICATION_DETAILS_H_ -#define CONTENT_COMMON_NOTIFICATION_DETAILS_H_ -#pragma once - -#include "base/basictypes.h" -#include "content/common/content_export.h" - -// Do not declare a NotificationDetails directly--use either -// "Details<detailsclassname>(detailsclasspointer)" or -// NotificationService::NoDetails(). -class CONTENT_EXPORT NotificationDetails { - public: - NotificationDetails(); - NotificationDetails(const NotificationDetails& other); - ~NotificationDetails(); - - // NotificationDetails can be used as the index for a map; this method - // returns the pointer to the current details as an identifier, for use as a - // map index. - uintptr_t map_key() const { return reinterpret_cast<uintptr_t>(ptr_); } - - bool operator!=(const NotificationDetails& other) const { - return ptr_ != other.ptr_; - } - - bool operator==(const NotificationDetails& other) const { - return ptr_ == other.ptr_; - } - - protected: - explicit NotificationDetails(const void* ptr); - - // Declaring this const allows Details<T> to be used with both T = Foo and - // T = const Foo. - const void* ptr_; -}; - -template <class T> -class Details : public NotificationDetails { - public: - // TODO(erg): Our code hard relies on implicit conversion - Details(T* ptr) : NotificationDetails(ptr) {} // NOLINT - Details(const NotificationDetails& other) // NOLINT - : NotificationDetails(other) {} - - T* operator->() const { return ptr(); } - // The casts here allow this to compile with both T = Foo and T = const Foo. - T* ptr() const { return static_cast<T*>(const_cast<void*>(ptr_)); } -}; - -#endif // CONTENT_COMMON_NOTIFICATION_DETAILS_H_ diff --git a/content/common/notification_observer.h b/content/common/notification_observer.h deleted file mode 100644 index 5fa0cb9..0000000 --- a/content/common/notification_observer.h +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CONTENT_COMMON_NOTIFICATION_OBSERVER_H_ -#define CONTENT_COMMON_NOTIFICATION_OBSERVER_H_ -#pragma once - -#include "content/common/content_export.h" - -class NotificationDetails; -class NotificationSource; - -// This is the base class for notification observers. When a matching -// notification is posted to the notification service, Observe is called. -class CONTENT_EXPORT NotificationObserver { - public: - NotificationObserver(); - virtual ~NotificationObserver(); - - virtual void Observe(int type, - const NotificationSource& source, - const NotificationDetails& details) = 0; -}; - -#endif // CONTENT_COMMON_NOTIFICATION_OBSERVER_H_ diff --git a/content/common/notification_observer_mock.cc b/content/common/notification_observer_mock.cc deleted file mode 100644 index c743bbf..0000000 --- a/content/common/notification_observer_mock.cc +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "content/common/notification_observer_mock.h" - -#include "content/common/notification_details.h" -#include "content/common/notification_source.h" - -NotificationObserverMock::NotificationObserverMock() {} - -NotificationObserverMock::~NotificationObserverMock() {} diff --git a/content/common/notification_observer_mock.h b/content/common/notification_observer_mock.h deleted file mode 100644 index 8d5e4dc..0000000 --- a/content/common/notification_observer_mock.h +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CONTENT_COMMON_NOTIFICATION_OBSERVER_MOCK_H_ -#define CONTENT_COMMON_NOTIFICATION_OBSERVER_MOCK_H_ -#pragma once - -#include "content/common/notification_observer.h" -#include "testing/gmock/include/gmock/gmock.h" - -class NotificationDetails; -class NotificationSource; - -class NotificationObserverMock : public NotificationObserver { - public: - NotificationObserverMock(); - virtual ~NotificationObserverMock(); - - MOCK_METHOD3(Observe, void(int type, - const NotificationSource& source, - const NotificationDetails& details)); -}; - -#endif // CONTENT_COMMON_NOTIFICATION_OBSERVER_MOCK_H_ diff --git a/content/common/notification_registrar.cc b/content/common/notification_registrar.cc deleted file mode 100644 index eca5054..0000000 --- a/content/common/notification_registrar.cc +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "content/common/notification_registrar.h" - -#include <algorithm> - -#include "base/logging.h" -#include "base/threading/platform_thread.h" -#include "content/common/notification_service.h" - -namespace { - -void CheckCalledOnValidThread(base::PlatformThreadId thread_id) { - base::PlatformThreadId current_thread_id = base::PlatformThread::CurrentId(); - CHECK(current_thread_id == thread_id) << "called on invalid thread: " - << thread_id << " vs. " - << current_thread_id; -} - -} // namespace - -struct NotificationRegistrar::Record { - bool operator==(const Record& other) const; - - NotificationObserver* observer; - int type; - NotificationSource source; - base::PlatformThreadId thread_id; -}; - -bool NotificationRegistrar::Record::operator==(const Record& other) const { - return observer == other.observer && - type == other.type && - source == other.source; - // thread_id is for debugging purpose and thus not compared here. -} - -NotificationRegistrar::NotificationRegistrar() { - // Force the NotificationService to be constructed (if it isn't already). - // This ensures the NotificationService will be registered on the - // AtExitManager before any objects which access it via NotificationRegistrar. - // This in turn means it will be destroyed after these objects, so they will - // never try to access the NotificationService after it's been destroyed. - NotificationService::current(); -} - -NotificationRegistrar::~NotificationRegistrar() { - RemoveAll(); -} - -void NotificationRegistrar::Add(NotificationObserver* observer, - int type, - const NotificationSource& source) { - DCHECK(!IsRegistered(observer, type, source)) << "Duplicate registration."; - - Record record = { observer, type, source, base::PlatformThread::CurrentId() }; - registered_.push_back(record); - - NotificationService::current()->AddObserver(observer, type, source); -} - -void NotificationRegistrar::Remove(NotificationObserver* observer, - int type, - const NotificationSource& source) { - if (!IsRegistered(observer, type, source)) { - NOTREACHED() << "Trying to remove unregistered observer of type " << - type << " from list of size " << registered_.size() << "."; - return; - } - - Record record = { observer, type, source }; - RecordVector::iterator found = std::find( - registered_.begin(), registered_.end(), record); - CheckCalledOnValidThread(found->thread_id); - registered_.erase(found); - - // This can be NULL if our owner outlives the NotificationService, e.g. if our - // owner is a Singleton. - NotificationService* service = NotificationService::current(); - if (service) - service->RemoveObserver(observer, type, source); -} - -void NotificationRegistrar::RemoveAll() { - // Early-exit if no registrations, to avoid calling - // NotificationService::current. If we've constructed an object with a - // NotificationRegistrar member, but haven't actually used the notification - // service, and we reach prgram exit, then calling current() below could try - // to initialize the service's lazy TLS pointer during exit, which throws - // wrenches at things. - if (registered_.empty()) - return; - - - // This can be NULL if our owner outlives the NotificationService, e.g. if our - // owner is a Singleton. - NotificationService* service = NotificationService::current(); - if (service) { - for (size_t i = 0; i < registered_.size(); i++) { - CheckCalledOnValidThread(registered_[i].thread_id); - service->RemoveObserver(registered_[i].observer, - registered_[i].type, - registered_[i].source); - } - } - registered_.clear(); -} - -bool NotificationRegistrar::IsEmpty() const { - return registered_.empty(); -} - -bool NotificationRegistrar::IsRegistered(NotificationObserver* observer, - int type, - const NotificationSource& source) { - Record record = { observer, type, source }; - return std::find(registered_.begin(), registered_.end(), record) != - registered_.end(); -} diff --git a/content/common/notification_registrar.h b/content/common/notification_registrar.h deleted file mode 100644 index fddf5e2..0000000 --- a/content/common/notification_registrar.h +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CONTENT_COMMON_NOTIFICATION_REGISTRAR_H_ -#define CONTENT_COMMON_NOTIFICATION_REGISTRAR_H_ -#pragma once - -#include <vector> - -#include "base/basictypes.h" -#include "content/common/content_export.h" - -class NotificationObserver; -class NotificationSource; - -// Aids in registering for notifications and ensures that all registered -// notifications are unregistered when the class is destroyed. -// -// The intended use is that you make a NotificationRegistrar member in your -// class and use it to register your notifications instead of going through the -// notification service directly. It will automatically unregister them for -// you. -class CONTENT_EXPORT NotificationRegistrar { - public: - // This class must not be derived from (we don't have a virtual destructor so - // it won't work). Instead, use it as a member in your class. - NotificationRegistrar(); - ~NotificationRegistrar(); - - // Wrappers around NotificationService::[Add|Remove]Observer. - void Add(NotificationObserver* observer, - int type, - const NotificationSource& source); - void Remove(NotificationObserver* observer, - int type, - const NotificationSource& source); - - // Unregisters all notifications. - void RemoveAll(); - - // Returns true if no notifications are registered. - bool IsEmpty() const; - - // Returns true if there is already a registered notification with the - // specified details. - bool IsRegistered(NotificationObserver* observer, - int type, - const NotificationSource& source); - - private: - struct Record; - - // We keep registered notifications in a simple vector. This means we'll do - // brute-force searches when removing them individually, but individual - // removal is uncommon, and there will typically only be a couple of - // notifications anyway. - typedef std::vector<Record> RecordVector; - - // Lists all notifications we're currently registered for. - RecordVector registered_; - - DISALLOW_COPY_AND_ASSIGN(NotificationRegistrar); -}; - -#endif // CONTENT_COMMON_NOTIFICATION_REGISTRAR_H_ diff --git a/content/common/notification_service.cc b/content/common/notification_service.cc index be42df8..81ad733 100644 --- a/content/common/notification_service.cc +++ b/content/common/notification_service.cc @@ -6,7 +6,7 @@ #include "base/lazy_instance.h" #include "base/threading/thread_local.h" -#include "content/common/notification_observer.h" +#include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_types.h" static base::LazyInstance<base::ThreadLocalPointer<NotificationService> > @@ -19,7 +19,7 @@ NotificationService* NotificationService::current() { // static bool NotificationService::HasKey(const NotificationSourceMap& map, - const NotificationSource& source) { + const content::NotificationSource& source) { return map.find(source.map_key()) != map.end(); } @@ -28,9 +28,10 @@ NotificationService::NotificationService() { lazy_tls_ptr.Pointer()->Set(this); } -void NotificationService::AddObserver(NotificationObserver* observer, - int type, - const NotificationSource& source) { +void NotificationService::AddObserver( + content::NotificationObserver* observer, + int type, + const content::NotificationSource& source) { // We have gotten some crashes where the observer pointer is NULL. The problem // is that this happens when we actually execute a notification, so have no // way of knowing who the bad observer was. We want to know when this happens @@ -52,9 +53,10 @@ void NotificationService::AddObserver(NotificationObserver* observer, #endif } -void NotificationService::RemoveObserver(NotificationObserver* observer, - int type, - const NotificationSource& source) { +void NotificationService::RemoveObserver( + content::NotificationObserver* observer, + int type, + const content::NotificationSource& source) { // This is a very serious bug. An object is most likely being deleted on // the wrong thread, and as a result another thread's NotificationService // has its deleted pointer in its map. A garbge object will be called in the @@ -76,8 +78,8 @@ void NotificationService::RemoveObserver(NotificationObserver* observer, } void NotificationService::Notify(int type, - const NotificationSource& source, - const NotificationDetails& details) { + const content::NotificationSource& source, + const content::NotificationDetails& details) { DCHECK(type > content::NOTIFICATION_ALL) << "Allowed for observing, but not posting."; @@ -87,14 +89,14 @@ void NotificationService::Notify(int type, // Notify observers of all types and all sources if (HasKey(observers_[content::NOTIFICATION_ALL], AllSources()) && source != AllSources()) { - FOR_EACH_OBSERVER(NotificationObserver, + FOR_EACH_OBSERVER(content::NotificationObserver, *observers_[content::NOTIFICATION_ALL][AllSources().map_key()], Observe(type, source, details)); } // Notify observers of all types and the given source if (HasKey(observers_[content::NOTIFICATION_ALL], source)) { - FOR_EACH_OBSERVER(NotificationObserver, + FOR_EACH_OBSERVER(content::NotificationObserver, *observers_[content::NOTIFICATION_ALL][source.map_key()], Observe(type, source, details)); } @@ -102,14 +104,14 @@ void NotificationService::Notify(int type, // Notify observers of the given type and all sources if (HasKey(observers_[type], AllSources()) && source != AllSources()) { - FOR_EACH_OBSERVER(NotificationObserver, + FOR_EACH_OBSERVER(content::NotificationObserver, *observers_[type][AllSources().map_key()], Observe(type, source, details)); } // Notify observers of the given type and the given source if (HasKey(observers_[type], source)) { - FOR_EACH_OBSERVER(NotificationObserver, + FOR_EACH_OBSERVER(content::NotificationObserver, *observers_[type][source.map_key()], Observe(type, source, details)); } @@ -137,7 +139,3 @@ NotificationService::~NotificationService() { delete it->second; } } - -NotificationObserver::NotificationObserver() {} - -NotificationObserver::~NotificationObserver() {} diff --git a/content/common/notification_service.h b/content/common/notification_service.h index 0dffa55..ae8e87f 100644 --- a/content/common/notification_service.h +++ b/content/common/notification_service.h @@ -14,10 +14,13 @@ #include "base/observer_list.h" #include "content/common/content_export.h" -#include "content/common/notification_details.h" -#include "content/common/notification_source.h" +#include "content/public/browser/notification_details.h" +#include "content/public/browser/notification_source.h" +namespace content { class NotificationObserver; +class NotificationRegistrar; +} class CONTENT_EXPORT NotificationService { public: @@ -39,12 +42,14 @@ class CONTENT_EXPORT NotificationService { // the notification. If no additional data is needed, NoDetails() is used. // There is no particular order in which the observers will be notified. void Notify(int type, - const NotificationSource& source, - const NotificationDetails& details); + const content::NotificationSource& source, + const content::NotificationDetails& details); // Returns a NotificationSource that represents all notification sources // (for the purpose of registering an observer for events from all sources). - static Source<void> AllSources() { return Source<void>(NULL); } + static content::Source<void> AllSources() { + return content::Source<void>(NULL); + } // Returns the same value as AllSources(). This function has semantic // differences to the programmer: We have checked that this AllSources() @@ -56,18 +61,20 @@ class CONTENT_EXPORT NotificationService { // a container before use. But, we want the number of AllSources() calls to // drop to almost nothing, because most usages are not multiprofile safe and // were done because it was easier to listen to everything. - static Source<void> AllBrowserContextsAndSources() { - return Source<void>(NULL); + static content::Source<void> AllBrowserContextsAndSources() { + return content::Source<void>(NULL); } // Returns a NotificationDetails object that represents a lack of details // associated with a notification. (This is effectively a null pointer.) - static Details<void> NoDetails() { return Details<void>(NULL); } + static content::Details<void> NoDetails() { + return content::Details<void>(NULL); + } private: - friend class NotificationRegistrar; + friend class content::NotificationRegistrar; - typedef ObserverList<NotificationObserver> NotificationObserverList; + typedef ObserverList<content::NotificationObserver> NotificationObserverList; typedef std::map<uintptr_t, NotificationObserverList*> NotificationSourceMap; typedef std::map<int, NotificationSourceMap> NotificationObserverMap; typedef std::map<int, int> NotificationObserverCount; @@ -75,7 +82,7 @@ class CONTENT_EXPORT NotificationService { // Convenience function to determine whether a source has a // NotificationObserverList in the given map; static bool HasKey(const NotificationSourceMap& map, - const NotificationSource& source); + const content::NotificationSource& source); // NOTE: Rather than using this directly, you should use a // NotificationRegistrar. @@ -96,8 +103,8 @@ class CONTENT_EXPORT NotificationService { // it must be removed for each of those combinations of type and source later. // // The caller retains ownership of the object pointed to by observer. - void AddObserver(NotificationObserver* observer, - int type, const NotificationSource& source); + void AddObserver(content::NotificationObserver* observer, + int type, const content::NotificationSource& source); // NOTE: Rather than using this directly, you should use a // NotificationRegistrar. @@ -105,8 +112,8 @@ class CONTENT_EXPORT NotificationService { // Removes the object pointed to by observer from receiving notifications // that match type and source. If no object matching the parameters is // currently registered, this method is a no-op. - void RemoveObserver(NotificationObserver* observer, - int type, const NotificationSource& source); + void RemoveObserver(content::NotificationObserver* observer, + int type, const content::NotificationSource& source); // Keeps track of the observers for each type of notification. // Until we get a prohibitively large number of notification types, diff --git a/content/common/notification_service_unittest.cc b/content/common/notification_service_unittest.cc index 3251448..cff4420 100644 --- a/content/common/notification_service_unittest.cc +++ b/content/common/notification_service_unittest.cc @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/common/notification_observer.h" -#include "content/common/notification_registrar.h" +#include "content/public/browser/notification_observer.h" +#include "content/public/browser/notification_registrar.h" #include "content/common/notification_service.h" #include "content/public/browser/notification_types.h" #include "testing/gtest/include/gtest/gtest.h" @@ -13,15 +13,15 @@ namespace { // Bogus class to act as a NotificationSource for the messages. class TestSource {}; -class TestObserver : public NotificationObserver { +class TestObserver : public content::NotificationObserver { public: TestObserver() : notification_count_(0) {} int notification_count() { return notification_count_; } void Observe(int type, - const NotificationSource& source, - const NotificationDetails& details) { + const content::NotificationSource& source, + const content::NotificationDetails& details) { ++notification_count_; } @@ -34,7 +34,7 @@ private: class NotificationServiceTest : public testing::Test { protected: - NotificationRegistrar registrar_; + content::NotificationRegistrar registrar_; }; TEST_F(NotificationServiceTest, Basic) { @@ -42,10 +42,10 @@ TEST_F(NotificationServiceTest, Basic) { TestSource other_source; // Check the equality operators defined for NotificationSource - EXPECT_TRUE( - Source<TestSource>(&test_source) == Source<TestSource>(&test_source)); - EXPECT_TRUE( - Source<TestSource>(&test_source) != Source<TestSource>(&other_source)); + EXPECT_TRUE(content::Source<TestSource>(&test_source) == + Source<TestSource>(&test_source)); + EXPECT_TRUE(content::Source<TestSource>(&test_source) != + content::Source<TestSource>(&other_source)); TestObserver all_types_all_sources; TestObserver idle_all_sources; @@ -55,7 +55,7 @@ TEST_F(NotificationServiceTest, Basic) { // Make sure it doesn't freak out when there are no observers. NotificationService* service = NotificationService::current(); service->Notify(content::NOTIFICATION_IDLE, - Source<TestSource>(&test_source), + content::Source<TestSource>(&test_source), NotificationService::NoDetails()); registrar_.Add(&all_types_all_sources, content::NOTIFICATION_ALL, @@ -63,9 +63,9 @@ TEST_F(NotificationServiceTest, Basic) { registrar_.Add(&idle_all_sources, content::NOTIFICATION_IDLE, NotificationService::AllSources()); registrar_.Add(&all_types_test_source, content::NOTIFICATION_ALL, - Source<TestSource>(&test_source)); + content::Source<TestSource>(&test_source)); registrar_.Add(&idle_test_source, content::NOTIFICATION_IDLE, - Source<TestSource>(&test_source)); + content::Source<TestSource>(&test_source)); EXPECT_EQ(0, all_types_all_sources.notification_count()); EXPECT_EQ(0, idle_all_sources.notification_count()); @@ -73,7 +73,7 @@ TEST_F(NotificationServiceTest, Basic) { EXPECT_EQ(0, idle_test_source.notification_count()); service->Notify(content::NOTIFICATION_IDLE, - Source<TestSource>(&test_source), + content::Source<TestSource>(&test_source), NotificationService::NoDetails()); EXPECT_EQ(1, all_types_all_sources.notification_count()); @@ -82,7 +82,7 @@ TEST_F(NotificationServiceTest, Basic) { EXPECT_EQ(1, idle_test_source.notification_count()); service->Notify(content::NOTIFICATION_BUSY, - Source<TestSource>(&test_source), + content::Source<TestSource>(&test_source), NotificationService::NoDetails()); EXPECT_EQ(2, all_types_all_sources.notification_count()); @@ -91,7 +91,7 @@ TEST_F(NotificationServiceTest, Basic) { EXPECT_EQ(1, idle_test_source.notification_count()); service->Notify(content::NOTIFICATION_IDLE, - Source<TestSource>(&other_source), + content::Source<TestSource>(&other_source), NotificationService::NoDetails()); EXPECT_EQ(3, all_types_all_sources.notification_count()); @@ -100,7 +100,7 @@ TEST_F(NotificationServiceTest, Basic) { EXPECT_EQ(1, idle_test_source.notification_count()); service->Notify(content::NOTIFICATION_BUSY, - Source<TestSource>(&other_source), + content::Source<TestSource>(&other_source), NotificationService::NoDetails()); EXPECT_EQ(4, all_types_all_sources.notification_count()); @@ -121,7 +121,7 @@ TEST_F(NotificationServiceTest, Basic) { registrar_.RemoveAll(); service->Notify(content::NOTIFICATION_IDLE, - Source<TestSource>(&test_source), + content::Source<TestSource>(&test_source), NotificationService::NoDetails()); EXPECT_EQ(5, all_types_all_sources.notification_count()); @@ -138,28 +138,28 @@ TEST_F(NotificationServiceTest, MultipleRegistration) { NotificationService* service = NotificationService::current(); registrar_.Add(&idle_test_source, content::NOTIFICATION_IDLE, - Source<TestSource>(&test_source)); + content::Source<TestSource>(&test_source)); registrar_.Add(&idle_test_source, content::NOTIFICATION_ALL, - Source<TestSource>(&test_source)); + content::Source<TestSource>(&test_source)); service->Notify(content::NOTIFICATION_IDLE, - Source<TestSource>(&test_source), + content::Source<TestSource>(&test_source), NotificationService::NoDetails()); EXPECT_EQ(2, idle_test_source.notification_count()); registrar_.Remove(&idle_test_source, content::NOTIFICATION_IDLE, - Source<TestSource>(&test_source)); + content::Source<TestSource>(&test_source)); service->Notify(content::NOTIFICATION_IDLE, - Source<TestSource>(&test_source), + content::Source<TestSource>(&test_source), NotificationService::NoDetails()); EXPECT_EQ(3, idle_test_source.notification_count()); registrar_.Remove(&idle_test_source, content::NOTIFICATION_ALL, - Source<TestSource>(&test_source)); + content::Source<TestSource>(&test_source)); service->Notify(content::NOTIFICATION_IDLE, - Source<TestSource>(&test_source), + content::Source<TestSource>(&test_source), NotificationService::NoDetails()); EXPECT_EQ(3, idle_test_source.notification_count()); } |