diff options
author | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-21 22:40:35 +0000 |
---|---|---|
committer | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-21 22:40:35 +0000 |
commit | 740e6bdb0b63c45e1e44d73f473f330b69853c1c (patch) | |
tree | 83e2ef11c38fe80cf3666de06cfc6f2a8b9181ef /net | |
parent | 3d8d1c9f38d1f4f26a56ad03d3fa920791bc50ea (diff) | |
download | chromium_src-740e6bdb0b63c45e1e44d73f473f330b69853c1c.zip chromium_src-740e6bdb0b63c45e1e44d73f473f330b69853c1c.tar.gz chromium_src-740e6bdb0b63c45e1e44d73f473f330b69853c1c.tar.bz2 |
Pass in NetLog to NetworkChangeNotifier.
BUG=46822
Review URL: http://codereview.chromium.org/2857009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50402 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/base/net_log_event_type_list.h | 5 | ||||
-rw-r--r-- | net/base/net_log_source_type_list.h | 3 | ||||
-rw-r--r-- | net/base/network_change_notifier.cc | 8 | ||||
-rw-r--r-- | net/base/network_change_notifier.h | 5 | ||||
-rw-r--r-- | net/base/network_change_notifier_linux.cc | 10 | ||||
-rw-r--r-- | net/base/network_change_notifier_linux.h | 6 | ||||
-rw-r--r-- | net/base/network_change_notifier_mac.cc | 10 | ||||
-rw-r--r-- | net/base/network_change_notifier_mac.h | 6 | ||||
-rw-r--r-- | net/base/network_change_notifier_win.cc | 9 | ||||
-rw-r--r-- | net/base/network_change_notifier_win.h | 5 |
10 files changed, 52 insertions, 15 deletions
diff --git a/net/base/net_log_event_type_list.h b/net/base/net_log_event_type_list.h index d129024..db449d3 100644 --- a/net/base/net_log_event_type_list.h +++ b/net/base/net_log_event_type_list.h @@ -567,6 +567,11 @@ EVENT_TYPE(SOCKS5_HANDSHAKE_WRITE) // The time spent waiting for the response to the CONNECT request. EVENT_TYPE(SOCKS5_HANDSHAKE_READ) +// -------------------------------------------------------------------------- +// NetworkChangeNotifier +// -------------------------------------------------------------------------- +EVENT_TYPE(NETWORK_IP_ADDRESS_CHANGED) + // ------------------------------------------------------------------------ // HTTP Authentication // ------------------------------------------------------------------------ diff --git a/net/base/net_log_source_type_list.h b/net/base/net_log_source_type_list.h index 6664c2d..df60083 100644 --- a/net/base/net_log_source_type_list.h +++ b/net/base/net_log_source_type_list.h @@ -13,5 +13,6 @@ SOURCE_TYPE(INIT_PROXY_RESOLVER, 2) SOURCE_TYPE(CONNECT_JOB, 3) SOURCE_TYPE(SOCKET, 4) SOURCE_TYPE(SPDY_SESSION, 5) +SOURCE_TYPE(NETWORK_CHANGE_NOTIFIER, 6) -SOURCE_TYPE(COUNT, 6) // Always keep this as the last entry. +SOURCE_TYPE(COUNT, 7) // Always keep this as the last entry. diff --git a/net/base/network_change_notifier.cc b/net/base/network_change_notifier.cc index aeca2ab..ebc33b3 100644 --- a/net/base/network_change_notifier.cc +++ b/net/base/network_change_notifier.cc @@ -16,13 +16,13 @@ namespace net { // static NetworkChangeNotifier* -NetworkChangeNotifier::CreateDefaultNetworkChangeNotifier() { +NetworkChangeNotifier::CreateDefaultNetworkChangeNotifier(NetLog* net_log) { #if defined(OS_WIN) - return new NetworkChangeNotifierWin(); + return new NetworkChangeNotifierWin(net_log); #elif defined(OS_LINUX) - return new NetworkChangeNotifierLinux(); + return new NetworkChangeNotifierLinux(net_log); #elif defined(OS_MACOSX) - return new NetworkChangeNotifierMac(); + return new NetworkChangeNotifierMac(net_log); #else NOTIMPLEMENTED(); return NULL; diff --git a/net/base/network_change_notifier.h b/net/base/network_change_notifier.h index 70b195d..d15b737 100644 --- a/net/base/network_change_notifier.h +++ b/net/base/network_change_notifier.h @@ -9,6 +9,8 @@ namespace net { +class NetLog; + // NetworkChangeNotifier monitors the system for network changes, and notifies // observers on those events. class NetworkChangeNotifier { @@ -40,7 +42,8 @@ class NetworkChangeNotifier { virtual void RemoveObserver(Observer* observer) = 0; // This will create the platform specific default NetworkChangeNotifier. - static NetworkChangeNotifier* CreateDefaultNetworkChangeNotifier(); + static NetworkChangeNotifier* CreateDefaultNetworkChangeNotifier( + NetLog* net_log); private: DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifier); diff --git a/net/base/network_change_notifier_linux.cc b/net/base/network_change_notifier_linux.cc index 9821be5..e2e2236 100644 --- a/net/base/network_change_notifier_linux.cc +++ b/net/base/network_change_notifier_linux.cc @@ -12,6 +12,7 @@ #include "base/logging.h" #include "base/message_loop.h" #include "net/base/net_errors.h" +#include "net/base/net_log.h" #include "net/base/network_change_notifier_netlink_linux.h" namespace net { @@ -22,12 +23,13 @@ const int kInvalidSocket = -1; } // namespace -NetworkChangeNotifierLinux::NetworkChangeNotifierLinux() +NetworkChangeNotifierLinux::NetworkChangeNotifierLinux(NetLog* net_log) : netlink_fd_(kInvalidSocket), #if defined(OS_CHROMEOS) ALLOW_THIS_IN_INITIALIZER_LIST(factory_(this)), #endif - loop_(MessageLoopForIO::current()) { + loop_(MessageLoopForIO::current()), + net_log_(net_log) { netlink_fd_ = InitializeNetlinkSocket(); if (netlink_fd_ < 0) { netlink_fd_ = kInvalidSocket; @@ -108,6 +110,10 @@ void NetworkChangeNotifierLinux::ListenForNotifications() { } void NetworkChangeNotifierLinux::NotifyObserversIPAddressChanged() { + BoundNetLog net_log = + BoundNetLog::Make(net_log_, NetLog::SOURCE_NETWORK_CHANGE_NOTIFIER); + // TODO(willchan): Add the netlink information into an EventParameter. + net_log.AddEvent(NetLog::TYPE_NETWORK_IP_ADDRESS_CHANGED, NULL); FOR_EACH_OBSERVER(Observer, observers_, OnIPAddressChanged()); } diff --git a/net/base/network_change_notifier_linux.h b/net/base/network_change_notifier_linux.h index dcedbf4..2492dc1 100644 --- a/net/base/network_change_notifier_linux.h +++ b/net/base/network_change_notifier_linux.h @@ -17,13 +17,15 @@ namespace net { +class NetLog; + class NetworkChangeNotifierLinux : public NetworkChangeNotifier, public NonThreadSafe, public MessageLoopForIO::Watcher, public MessageLoop::DestructionObserver { public: - NetworkChangeNotifierLinux(); + explicit NetworkChangeNotifierLinux(NetLog* net_log); // NetworkChangeNotifier methods: virtual void AddObserver(Observer* observer); @@ -65,6 +67,8 @@ class NetworkChangeNotifierLinux MessageLoopForIO* loop_; MessageLoopForIO::FileDescriptorWatcher netlink_watcher_; + NetLog* const net_log_; + DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierLinux); }; diff --git a/net/base/network_change_notifier_mac.cc b/net/base/network_change_notifier_mac.cc index ba38907..40c0808 100644 --- a/net/base/network_change_notifier_mac.cc +++ b/net/base/network_change_notifier_mac.cc @@ -31,6 +31,7 @@ #include "base/message_loop.h" #include "base/scoped_cftyperef.h" #include "base/thread.h" +#include "net/base/net_log.h" namespace net { @@ -218,9 +219,10 @@ void NetworkChangeNotifierThread::Init() { } // namespace -NetworkChangeNotifierMac::NetworkChangeNotifierMac() +NetworkChangeNotifierMac::NetworkChangeNotifierMac(NetLog* net_log) : notifier_thread_(NULL), - method_factory_(this) { + method_factory_(this), + net_log_(net_log) { // TODO(willchan): Look to see if there's a better signal for when it's ok to // initialize this, rather than just delaying it by a fixed time. const int kNotifierThreadInitializationDelayMS = 1000; @@ -234,6 +236,10 @@ NetworkChangeNotifierMac::NetworkChangeNotifierMac() void NetworkChangeNotifierMac::OnIPAddressChanged() { DCHECK(CalledOnValidThread()); + BoundNetLog net_log = + BoundNetLog::Make(net_log_, NetLog::SOURCE_NETWORK_CHANGE_NOTIFIER); + // TODO(willchan): Add the network change information into an EventParameter. + net_log.AddEvent(NetLog::TYPE_NETWORK_IP_ADDRESS_CHANGED, NULL); FOR_EACH_OBSERVER(Observer, observers_, OnIPAddressChanged()); } diff --git a/net/base/network_change_notifier_mac.h b/net/base/network_change_notifier_mac.h index 2ffaaba..096b3bd 100644 --- a/net/base/network_change_notifier_mac.h +++ b/net/base/network_change_notifier_mac.h @@ -20,10 +20,12 @@ class Thread; namespace net { +class NetLog; + class NetworkChangeNotifierMac : public NetworkChangeNotifier, public NonThreadSafe { public: - NetworkChangeNotifierMac(); + explicit NetworkChangeNotifierMac(NetLog* net_log); void OnIPAddressChanged(); @@ -52,6 +54,8 @@ class NetworkChangeNotifierMac : public NetworkChangeNotifier, // Used to initialize the notifier thread. ScopedRunnableMethodFactory<NetworkChangeNotifierMac> method_factory_; + NetLog* const net_log_; + DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierMac); }; diff --git a/net/base/network_change_notifier_win.cc b/net/base/network_change_notifier_win.cc index bed361c..020e160 100644 --- a/net/base/network_change_notifier_win.cc +++ b/net/base/network_change_notifier_win.cc @@ -12,6 +12,7 @@ #include "base/compiler_specific.h" #include "base/logging.h" #include "base/object_watcher.h" +#include "net/base/net_log.h" namespace net { @@ -62,12 +63,16 @@ void NetworkChangeNotifierWin::Impl::OnObjectSignaled(HANDLE object) { WatchForAddressChange(); } -NetworkChangeNotifierWin::NetworkChangeNotifierWin() - : impl_(new Impl(ALLOW_THIS_IN_INITIALIZER_LIST(this))) { +NetworkChangeNotifierWin::NetworkChangeNotifierWin(NetLog* net_log) + : impl_(new Impl(ALLOW_THIS_IN_INITIALIZER_LIST(this))), + net_log_(net_log) { impl_->WatchForAddressChange(); } void NetworkChangeNotifierWin::OnIPAddressChanged() { DCHECK(CalledOnValidThread()); + BoundNetLog net_log = + BoundNetLog::Make(net_log_, NetLog::SOURCE_NETWORK_CHANGE_NOTIFIER); + net_log.AddEvent(NetLog::TYPE_NETWORK_IP_ADDRESS_CHANGED, NULL); FOR_EACH_OBSERVER(Observer, observers_, OnIPAddressChanged()); } diff --git a/net/base/network_change_notifier_win.h b/net/base/network_change_notifier_win.h index ba2f53dc..403377b 100644 --- a/net/base/network_change_notifier_win.h +++ b/net/base/network_change_notifier_win.h @@ -13,10 +13,12 @@ namespace net { +class NetLog; + class NetworkChangeNotifierWin : public NetworkChangeNotifier, public NonThreadSafe { public: - NetworkChangeNotifierWin(); + explicit NetworkChangeNotifierWin(NetLog* net_log); // Called by NetworkChangeNotifierWin::Impl. void OnIPAddressChanged(); @@ -34,6 +36,7 @@ class NetworkChangeNotifierWin : public NetworkChangeNotifier, // true so we assert that all observers have been removed. ObserverList<Observer, false> observers_; scoped_ptr<Impl> impl_; + NetLog* const net_log_; DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierWin); }; |