diff options
-rw-r--r-- | chrome/browser/io_thread.cc | 5 | ||||
-rw-r--r-- | chrome/browser/net/passive_log_collector.cc | 25 | ||||
-rw-r--r-- | chrome/browser/net/passive_log_collector.h | 30 | ||||
-rw-r--r-- | chrome/service/net/service_network_change_notifier_thread.cc | 13 | ||||
-rw-r--r-- | chrome/service/net/service_network_change_notifier_thread.h | 11 | ||||
-rw-r--r-- | chrome/service/net/service_network_change_notifier_thread_unittest.cc | 5 | ||||
-rw-r--r-- | chrome/service/service_process.cc | 3 | ||||
-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 |
17 files changed, 117 insertions, 42 deletions
diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc index 5fcdb3d..4e0ed4b 100644 --- a/chrome/browser/io_thread.cc +++ b/chrome/browser/io_thread.cc @@ -133,9 +133,10 @@ void IOThread::Init() { DCHECK(!globals_); globals_ = new Globals; - globals_->net_log.reset(new ChromeNetLog()); + ChromeNetLog* net_log = new ChromeNetLog(); + globals_->net_log.reset(net_log); globals_->network_change_notifier.reset( - net::NetworkChangeNotifier::CreateDefaultNetworkChangeNotifier()); + net::NetworkChangeNotifier::CreateDefaultNetworkChangeNotifier(net_log)); globals_->host_resolver = CreateGlobalHostResolver(globals_->network_change_notifier.get()); globals_->http_auth_handler_factory.reset(CreateDefaultAuthHandlerFactory()); diff --git a/chrome/browser/net/passive_log_collector.cc b/chrome/browser/net/passive_log_collector.cc index 165cabf..1e73abb 100644 --- a/chrome/browser/net/passive_log_collector.cc +++ b/chrome/browser/net/passive_log_collector.cc @@ -56,6 +56,8 @@ PassiveLogCollector::PassiveLogCollector() trackers_[net::NetLog::SOURCE_INIT_PROXY_RESOLVER] = &init_proxy_resolver_tracker_; trackers_[net::NetLog::SOURCE_SPDY_SESSION] = &spdy_session_tracker_; + trackers_[net::NetLog::SOURCE_NETWORK_CHANGE_NOTIFIER] = + &network_change_notifier_tracker_; // Make sure our mapping is up-to-date. for (size_t i = 0; i < arraysize(trackers_); ++i) @@ -459,3 +461,26 @@ PassiveLogCollector::SpdySessionTracker::DoAddEntry(const Entry& entry, return ACTION_NONE; } } + +//---------------------------------------------------------------------------- +// NetworkChangeNotifierTracker +//---------------------------------------------------------------------------- + +typedef PassiveLogCollector::NetworkChangeNotifierTracker + NetworkChangeNotifierTracker; + +const size_t +NetworkChangeNotifierTracker::kMaxNumSources = 50; +const size_t +NetworkChangeNotifierTracker::kMaxGraveyardSize = 10; + +NetworkChangeNotifierTracker::NetworkChangeNotifierTracker() + : SourceTracker(kMaxNumSources, kMaxGraveyardSize, NULL) { +} + +PassiveLogCollector::SourceTracker::Action +NetworkChangeNotifierTracker::DoAddEntry( + const Entry& entry, SourceInfo* out_info) { + AddEntryToSourceInfo(entry, out_info); + return ACTION_MOVE_TO_GRAVEYARD; +} diff --git a/chrome/browser/net/passive_log_collector.h b/chrome/browser/net/passive_log_collector.h index b927c0c..61d8415 100644 --- a/chrome/browser/net/passive_log_collector.h +++ b/chrome/browser/net/passive_log_collector.h @@ -186,9 +186,9 @@ class PassiveLogCollector : public ChromeNetLog::Observer { explicit ConnectJobTracker(PassiveLogCollector* parent); - protected: - virtual Action DoAddEntry(const Entry& entry, SourceInfo* out_info); private: + virtual Action DoAddEntry(const Entry& entry, SourceInfo* out_info); + DISALLOW_COPY_AND_ASSIGN(ConnectJobTracker); }; @@ -200,10 +200,9 @@ class PassiveLogCollector : public ChromeNetLog::Observer { SocketTracker(); - protected: + private: virtual Action DoAddEntry(const Entry& entry, SourceInfo* out_info); - private: DISALLOW_COPY_AND_ASSIGN(SocketTracker); }; @@ -215,10 +214,9 @@ class PassiveLogCollector : public ChromeNetLog::Observer { explicit RequestTracker(PassiveLogCollector* parent); - protected: + private: virtual Action DoAddEntry(const Entry& entry, SourceInfo* out_info); - private: DISALLOW_COPY_AND_ASSIGN(RequestTracker); }; @@ -231,10 +229,9 @@ class PassiveLogCollector : public ChromeNetLog::Observer { InitProxyResolverTracker(); - protected: + private: virtual Action DoAddEntry(const Entry& entry, SourceInfo* out_info); - private: DISALLOW_COPY_AND_ASSIGN(InitProxyResolverTracker); }; @@ -246,13 +243,25 @@ class PassiveLogCollector : public ChromeNetLog::Observer { SpdySessionTracker(); - protected: + private: virtual Action DoAddEntry(const Entry& entry, SourceInfo* out_info); - private: DISALLOW_COPY_AND_ASSIGN(SpdySessionTracker); }; + class NetworkChangeNotifierTracker : public SourceTracker { + public: + static const size_t kMaxNumSources; + static const size_t kMaxGraveyardSize; + + NetworkChangeNotifierTracker(); + + private: + virtual Action DoAddEntry(const Entry& entry, SourceInfo* out_info); + + DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierTracker); + }; + PassiveLogCollector(); ~PassiveLogCollector(); @@ -286,6 +295,7 @@ class PassiveLogCollector : public ChromeNetLog::Observer { RequestTracker socket_stream_tracker_; InitProxyResolverTracker init_proxy_resolver_tracker_; SpdySessionTracker spdy_session_tracker_; + NetworkChangeNotifierTracker network_change_notifier_tracker_; // This array maps each NetLog::SourceType to one of the tracker instances // defined above. Use of this array avoid duplicating the list of trackers diff --git a/chrome/service/net/service_network_change_notifier_thread.cc b/chrome/service/net/service_network_change_notifier_thread.cc index 3ccd146..227b2ca 100644 --- a/chrome/service/net/service_network_change_notifier_thread.cc +++ b/chrome/service/net/service_network_change_notifier_thread.cc @@ -9,8 +9,10 @@ #include "net/base/network_change_notifier.h" ServiceNetworkChangeNotifierThread::ServiceNetworkChangeNotifierThread( - MessageLoop* io_thread_message_loop) - : io_thread_message_loop_(io_thread_message_loop) { + MessageLoop* io_thread_message_loop, + net::NetLog* net_log) + : io_thread_message_loop_(io_thread_message_loop), + net_log_(net_log) { DCHECK(io_thread_message_loop_); } @@ -34,13 +36,12 @@ MessageLoop* ServiceNetworkChangeNotifierThread::GetMessageLoop() const { net::NetworkChangeNotifier* ServiceNetworkChangeNotifierThread::GetNetworkChangeNotifier() const { - DCHECK(MessageLoop::current() == io_thread_message_loop_); + DCHECK_EQ(MessageLoop::current(), io_thread_message_loop_); return network_change_notifier_.get(); } void ServiceNetworkChangeNotifierThread::CreateNetworkChangeNotifier() { - DCHECK(MessageLoop::current() == io_thread_message_loop_); + DCHECK_EQ(MessageLoop::current(), io_thread_message_loop_); network_change_notifier_.reset( - net::NetworkChangeNotifier::CreateDefaultNetworkChangeNotifier()); + net::NetworkChangeNotifier::CreateDefaultNetworkChangeNotifier(net_log_)); } - diff --git a/chrome/service/net/service_network_change_notifier_thread.h b/chrome/service/net/service_network_change_notifier_thread.h index 14975a6..cb73f31 100644 --- a/chrome/service/net/service_network_change_notifier_thread.h +++ b/chrome/service/net/service_network_change_notifier_thread.h @@ -13,6 +13,7 @@ class MessageLoop; namespace net { +class NetLog; class NetworkChangeNotifier; } // namespace net @@ -25,8 +26,9 @@ class ServiceNetworkChangeNotifierThread // Does not take ownership of |io_thread_message_loop|. This instance must // live no longer than |io_thread_message_loop|. // TODO(sanjeevr): Change NetworkChangeNotifierThread to use MessageLoopProxy - explicit ServiceNetworkChangeNotifierThread( - MessageLoop* io_thread_message_loop); + ServiceNetworkChangeNotifierThread( + MessageLoop* io_thread_message_loop, + net::NetLog* net_log); virtual ~ServiceNetworkChangeNotifierThread(); // Initialize MUST be called before this class can be used. @@ -39,12 +41,13 @@ class ServiceNetworkChangeNotifierThread virtual net::NetworkChangeNotifier* GetNetworkChangeNotifier() const; private: + void CreateNetworkChangeNotifier(); + MessageLoop* const io_thread_message_loop_; + net::NetLog* const net_log_; scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; - void CreateNetworkChangeNotifier(); DISALLOW_COPY_AND_ASSIGN(ServiceNetworkChangeNotifierThread); }; #endif // CHROME_SERVICE_NET_SERVICE_NETWORK_CHANGE_NOTIFIER_THREAD_H_ - diff --git a/chrome/service/net/service_network_change_notifier_thread_unittest.cc b/chrome/service/net/service_network_change_notifier_thread_unittest.cc index 917d51a..9cf544a 100644 --- a/chrome/service/net/service_network_change_notifier_thread_unittest.cc +++ b/chrome/service/net/service_network_change_notifier_thread_unittest.cc @@ -65,7 +65,7 @@ void CheckNullNetworkChangeNotifier( TEST_F(ServiceNetworkChangeNotifierThreadTest, Basic) { scoped_refptr<ServiceNetworkChangeNotifierThread> change_notifier_thread = - new ServiceNetworkChangeNotifierThread(io_thread_.message_loop()); + new ServiceNetworkChangeNotifierThread(io_thread_.message_loop(), NULL); EXPECT_EQ(io_thread_.message_loop(), change_notifier_thread->GetMessageLoop()); change_notifier_thread->Initialize(); @@ -81,7 +81,7 @@ TEST_F(ServiceNetworkChangeNotifierThreadTest, Basic) { TEST_F(ServiceNetworkChangeNotifierThreadTest, Uninitialized) { scoped_refptr<ServiceNetworkChangeNotifierThread> change_notifier_thread = - new ServiceNetworkChangeNotifierThread(io_thread_.message_loop()); + new ServiceNetworkChangeNotifierThread(io_thread_.message_loop(), NULL); EXPECT_EQ(io_thread_.message_loop(), change_notifier_thread->GetMessageLoop()); // We have not called Initialize. Expect the GetNetworkChangeNotifier() call @@ -97,4 +97,3 @@ TEST_F(ServiceNetworkChangeNotifierThreadTest, Uninitialized) { } } // namespace - diff --git a/chrome/service/service_process.cc b/chrome/service/service_process.cc index 6e9baf2..a74af52 100644 --- a/chrome/service/service_process.cc +++ b/chrome/service/service_process.cc @@ -27,7 +27,7 @@ bool ServiceProcess::Initialize() { return false; } network_change_notifier_thread_ = - new ServiceNetworkChangeNotifierThread(io_thread_->message_loop()); + new ServiceNetworkChangeNotifierThread(io_thread_->message_loop(), NULL); network_change_notifier_thread_->Initialize(); return true; } @@ -53,4 +53,3 @@ ServiceProcess::~ServiceProcess() { DCHECK(cloud_print_proxy_list_.size() == 0); g_service_process = NULL; } - 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); }; |