diff --git a/net/base/network_change_notifier_linux.h b/net/base/network_change_notifier_linux.h index 2a4b20b07d22..89b054559d23 100644 --- a/net/base/network_change_notifier_linux.h +++ b/net/base/network_change_notifier_linux.h @@ -7,6 +7,7 @@ #pragma once #include "base/basictypes.h" +#include "base/compiler_specific.h" #include "base/memory/scoped_ptr.h" #include "net/base/network_change_notifier.h" @@ -22,7 +23,7 @@ class NetworkChangeNotifierLinux : public NetworkChangeNotifier { virtual ~NetworkChangeNotifierLinux(); // NetworkChangeNotifier: - virtual bool IsCurrentlyOffline() const; + virtual bool IsCurrentlyOffline() const OVERRIDE; // The thread used to listen for notifications. This relays the notification // to the registered observers without posting back to the thread the object diff --git a/net/base/network_change_notifier_mac.h b/net/base/network_change_notifier_mac.h index 0f68e86e2275..54ca27d0797f 100644 --- a/net/base/network_change_notifier_mac.h +++ b/net/base/network_change_notifier_mac.h @@ -9,6 +9,7 @@ #include #include "base/basictypes.h" +#include "base/compiler_specific.h" #include "base/mac/scoped_cftyperef.h" #include "base/memory/scoped_ptr.h" #include "base/synchronization/condition_variable.h" @@ -24,7 +25,7 @@ class NetworkChangeNotifierMac: public NetworkChangeNotifier { virtual ~NetworkChangeNotifierMac(); // NetworkChangeNotifier implementation: - virtual bool IsCurrentlyOffline() const; + virtual bool IsCurrentlyOffline() const OVERRIDE; private: enum OnlineState { @@ -41,13 +42,14 @@ class NetworkChangeNotifierMac: public NetworkChangeNotifier { : net_config_watcher_(net_config_watcher) {} // NetworkConfigWatcherMac::Delegate implementation: - virtual void Init() { + virtual void Init() OVERRIDE { net_config_watcher_->SetInitialState(); } - virtual void SetDynamicStoreNotificationKeys(SCDynamicStoreRef store) { + virtual void SetDynamicStoreNotificationKeys( + SCDynamicStoreRef store) OVERRIDE { net_config_watcher_->SetDynamicStoreNotificationKeys(store); } - virtual void OnNetworkConfigChange(CFArrayRef changed_keys) { + virtual void OnNetworkConfigChange(CFArrayRef changed_keys) OVERRIDE { net_config_watcher_->OnNetworkConfigChange(changed_keys); } diff --git a/net/base/network_config_watcher_mac.cc b/net/base/network_config_watcher_mac.cc index be399f9ef235..7c6324069432 100644 --- a/net/base/network_config_watcher_mac.cc +++ b/net/base/network_config_watcher_mac.cc @@ -6,10 +6,12 @@ #include +#include "base/bind.h" #include "base/compiler_specific.h" +#include "base/memory/weak_ptr.h" +#include "base/message_loop.h" #include "base/threading/thread.h" #include "base/threading/thread_restrictions.h" -#include "base/mac/scoped_cftyperef.h" namespace net { @@ -31,8 +33,8 @@ class NetworkConfigWatcherMacThread : public base::Thread { protected: // base::Thread - virtual void Init(); - virtual void CleanUp(); + virtual void Init() OVERRIDE; + virtual void CleanUp() OVERRIDE; private: // The SystemConfiguration calls in this function can lead to contention early @@ -41,7 +43,7 @@ class NetworkConfigWatcherMacThread : public base::Thread { base::mac::ScopedCFTypeRef run_loop_source_; NetworkConfigWatcherMac::Delegate* const delegate_; - ScopedRunnableMethodFactory method_factory_; + base::WeakPtrFactory weak_factory_; DISALLOW_COPY_AND_ASSIGN(NetworkConfigWatcherMacThread); }; @@ -50,7 +52,7 @@ NetworkConfigWatcherMacThread::NetworkConfigWatcherMacThread( NetworkConfigWatcherMac::Delegate* delegate) : base::Thread("NetworkConfigWatcher"), delegate_(delegate), - ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {} + ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {} NetworkConfigWatcherMacThread::~NetworkConfigWatcherMacThread() { // Allow IO because Stop() calls PlatformThread::Join(), which is a blocking @@ -72,8 +74,8 @@ void NetworkConfigWatcherMacThread::Init() { const int kInitializationDelayMS = 1000; message_loop()->PostDelayedTask( FROM_HERE, - method_factory_.NewRunnableMethod( - &NetworkConfigWatcherMacThread::InitNotifications), + base::Bind(&NetworkConfigWatcherMacThread::InitNotifications, + weak_factory_.GetWeakPtr()), kInitializationDelayMS); } diff --git a/net/base/network_config_watcher_mac.h b/net/base/network_config_watcher_mac.h index 7658438a0fe3..5066e65aff6d 100644 --- a/net/base/network_config_watcher_mac.h +++ b/net/base/network_config_watcher_mac.h @@ -8,7 +8,6 @@ #include #include "base/basictypes.h" -#include "base/message_loop.h" #include "base/mac/scoped_cftyperef.h" #include "base/memory/scoped_ptr.h" @@ -18,7 +17,7 @@ class Thread; namespace net { -// Base class for watching the Mac OS system network settings. +// Helper class for watching the Mac OS system network settings. class NetworkConfigWatcherMac { public: // NOTE: The lifetime of Delegate is expected to exceed the lifetime of @@ -42,7 +41,7 @@ class NetworkConfigWatcherMac { }; explicit NetworkConfigWatcherMac(Delegate* delegate); - virtual ~NetworkConfigWatcherMac(); + ~NetworkConfigWatcherMac(); private: // The thread used to listen for notifications. This relays the notification diff --git a/net/proxy/proxy_config_service_mac.cc b/net/proxy/proxy_config_service_mac.cc index df26466a6d21..2fd6ee00af68 100644 --- a/net/proxy/proxy_config_service_mac.cc +++ b/net/proxy/proxy_config_service_mac.cc @@ -10,6 +10,7 @@ #include "base/logging.h" #include "base/mac/mac_util.h" #include "base/mac/scoped_cftyperef.h" +#include "base/message_loop.h" #include "base/sys_string_conversions.h" #include "net/base/net_errors.h" #include "net/proxy/proxy_config.h" diff --git a/net/proxy/proxy_config_service_mac.h b/net/proxy/proxy_config_service_mac.h index 493e6a2f411c..a38a0b6ee3e3 100644 --- a/net/proxy/proxy_config_service_mac.h +++ b/net/proxy/proxy_config_service_mac.h @@ -15,6 +15,8 @@ #include "net/proxy/proxy_config.h" #include "net/proxy/proxy_config_service.h" +class MessageLoop; + namespace net { class ProxyConfigServiceMac : public ProxyConfigService {