summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-30 01:49:25 +0000
committermmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-30 01:49:25 +0000
commit9be87ba466fa2259e27974b43633414e5e1293ab (patch)
tree7ce56f70f6f5d0f2e6eb77a5ccdcc3ff15767382
parentc7b7610da317994ddbf52676be965f9a486f582a (diff)
downloadchromium_src-9be87ba466fa2259e27974b43633414e5e1293ab.zip
chromium_src-9be87ba466fa2259e27974b43633414e5e1293ab.tar.gz
chromium_src-9be87ba466fa2259e27974b43633414e5e1293ab.tar.bz2
Minor cleanup of Mac/Linux network change notifier code:
Add OVERRIDE, replace NewRunnableMethod with Bind, fix a couple includes. BUG=none TEST=compiles Review URL: http://codereview.chromium.org/8073027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103402 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--net/base/network_change_notifier_linux.h3
-rw-r--r--net/base/network_change_notifier_mac.h10
-rw-r--r--net/base/network_config_watcher_mac.cc16
-rw-r--r--net/base/network_config_watcher_mac.h5
-rw-r--r--net/proxy/proxy_config_service_mac.cc1
-rw-r--r--net/proxy/proxy_config_service_mac.h2
6 files changed, 22 insertions, 15 deletions
diff --git a/net/base/network_change_notifier_linux.h b/net/base/network_change_notifier_linux.h
index 2a4b20b..89b0545 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 0f68e86..54ca27d 100644
--- a/net/base/network_change_notifier_mac.h
+++ b/net/base/network_change_notifier_mac.h
@@ -9,6 +9,7 @@
#include <SystemConfiguration/SystemConfiguration.h>
#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 be399f9..7c63240 100644
--- a/net/base/network_config_watcher_mac.cc
+++ b/net/base/network_config_watcher_mac.cc
@@ -6,10 +6,12 @@
#include <algorithm>
+#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<CFRunLoopSourceRef> run_loop_source_;
NetworkConfigWatcherMac::Delegate* const delegate_;
- ScopedRunnableMethodFactory<NetworkConfigWatcherMacThread> method_factory_;
+ base::WeakPtrFactory<NetworkConfigWatcherMacThread> 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 7658438..5066e65 100644
--- a/net/base/network_config_watcher_mac.h
+++ b/net/base/network_config_watcher_mac.h
@@ -8,7 +8,6 @@
#include <SystemConfiguration/SCDynamicStore.h>
#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 df26466..2fd6ee0 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 493e6a2..a38a0b6 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 {