diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-17 21:24:02 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-17 21:24:02 +0000 |
commit | afed2dc02a3cce27bbe132aa9f97cb5bbb31d45a (patch) | |
tree | dd57bea37e892bf63dbcbd3d759548a3b1b626eb /chrome/common/net | |
parent | e106b901229419b078903bdd7f2bac97f2932bdc (diff) | |
download | chromium_src-afed2dc02a3cce27bbe132aa9f97cb5bbb31d45a.zip chromium_src-afed2dc02a3cce27bbe132aa9f97cb5bbb31d45a.tar.gz chromium_src-afed2dc02a3cce27bbe132aa9f97cb5bbb31d45a.tar.bz2 |
Implement a TODO: Move "NonThreadSafe" inheritance from NetworkChangeNotifier interface to implementations. Also add CalledOnValidThread() DCHECKs in as many places as possible.
Some minor style changes.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/2813019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50139 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/net')
-rw-r--r-- | chrome/common/net/network_change_notifier_proxy.cc | 18 | ||||
-rw-r--r-- | chrome/common/net/network_change_notifier_proxy.h | 11 |
2 files changed, 12 insertions, 17 deletions
diff --git a/chrome/common/net/network_change_notifier_proxy.cc b/chrome/common/net/network_change_notifier_proxy.cc index 8a25d22..a0a1961 100644 --- a/chrome/common/net/network_change_notifier_proxy.cc +++ b/chrome/common/net/network_change_notifier_proxy.cc @@ -15,13 +15,6 @@ NetworkChangeNotifierProxy::NetworkChangeNotifierProxy( : observer_proxy_(new NetworkChangeObserverProxy( source_thread, MessageLoop::current())), observer_repeater_(&observers_) { - // TODO(akalin): We get this from NonThreadSafe, which - // net::NetworkChangeNotifier inherits from. Interface classes - // really shouldn't be inheriting from NonThreadSafe; make it so - // that all the implementations of net::NetworkChangeNotifier - // inherit from NonThreadSafe directly and - // net::NetworkChangeNotifier doesn't. - DCHECK(CalledOnValidThread()); DCHECK(observer_proxy_); observer_proxy_->Attach(&observer_repeater_); } @@ -44,16 +37,19 @@ void NetworkChangeNotifierProxy::RemoveObserver( } NetworkChangeNotifierProxy::ObserverRepeater::ObserverRepeater( - NetworkObserverList* observers) : observers_(observers) { + NetworkObserverList* observers) + : observers_(observers) { DCHECK(observers_); } -NetworkChangeNotifierProxy::ObserverRepeater::~ObserverRepeater() {} +NetworkChangeNotifierProxy::ObserverRepeater::~ObserverRepeater() { + DCHECK(CalledOnValidThread()); +} void NetworkChangeNotifierProxy::ObserverRepeater::OnIPAddressChanged() { DCHECK(CalledOnValidThread()); - FOR_EACH_OBSERVER(net::NetworkChangeNotifier::Observer, - *observers_, OnIPAddressChanged()); + FOR_EACH_OBSERVER(net::NetworkChangeNotifier::Observer, *observers_, + OnIPAddressChanged()); } } // namespace chrome_common_net diff --git a/chrome/common/net/network_change_notifier_proxy.h b/chrome/common/net/network_change_notifier_proxy.h index 916d5f8..7ed01a8 100644 --- a/chrome/common/net/network_change_notifier_proxy.h +++ b/chrome/common/net/network_change_notifier_proxy.h @@ -21,19 +21,18 @@ namespace chrome_common_net { class NetworkChangeNotifierThread; class NetworkChangeObserverProxy; -class NetworkChangeNotifierProxy : public net::NetworkChangeNotifier { +class NetworkChangeNotifierProxy : public net::NetworkChangeNotifier, + public NonThreadSafe { public: // |source_thread| must be guaranteed to outlive the current thread. // Does not take ownership of any arguments. - NetworkChangeNotifierProxy( + explicit NetworkChangeNotifierProxy( NetworkChangeNotifierThread* source_thread); virtual ~NetworkChangeNotifierProxy(); // net::NetworkChangeNotifier implementation. - virtual void AddObserver(net::NetworkChangeNotifier::Observer* observer); - virtual void RemoveObserver(net::NetworkChangeNotifier::Observer* observer); private: @@ -42,8 +41,8 @@ class NetworkChangeNotifierProxy : public net::NetworkChangeNotifier { // Utility class that routes received notifications to a list of // observers. - class ObserverRepeater : public NonThreadSafe, - public net::NetworkChangeNotifier::Observer { + class ObserverRepeater : public net::NetworkChangeNotifier::Observer, + public NonThreadSafe { public: // Does not take ownership of the given observer list. explicit ObserverRepeater(NetworkObserverList* observers); |