summaryrefslogtreecommitdiffstats
path: root/chrome/browser/io_thread.cc
diff options
context:
space:
mode:
authoreroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-07 18:04:14 +0000
committereroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-07 18:04:14 +0000
commit58bc704d01f839bdf798ef747516323d907c5f33 (patch)
tree03b668793e864347005b7e22ff459fed6a305778 /chrome/browser/io_thread.cc
parent9973b94ef09d62aad270494fc1346290130dc9f2 (diff)
downloadchromium_src-58bc704d01f839bdf798ef747516323d907c5f33.zip
chromium_src-58bc704d01f839bdf798ef747516323d907c5f33.tar.gz
chromium_src-58bc704d01f839bdf798ef747516323d907c5f33.tar.bz2
Log whenever the network IP address changes.
This logs to both LOG(INFO), and also to the NetLog (about:net-internals). BUG=46822 Review URL: http://codereview.chromium.org/2815046 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51740 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/io_thread.cc')
-rw-r--r--chrome/browser/io_thread.cc46
1 files changed, 46 insertions, 0 deletions
diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc
index c451b25..90af284 100644
--- a/chrome/browser/io_thread.cc
+++ b/chrome/browser/io_thread.cc
@@ -74,6 +74,42 @@ net::HostResolver* CreateGlobalHostResolver() {
return remapped_resolver;
}
+class LoggingNetworkChangeObserver
+ : public net::NetworkChangeNotifier::Observer {
+ public:
+ // |net_log| must remain valid throughout our lifetime.
+ explicit LoggingNetworkChangeObserver(net::NetLog* net_log)
+ : net_log_(net_log) {
+ net::NetworkChangeNotifier::AddObserver(this);
+ }
+
+ ~LoggingNetworkChangeObserver() {
+ net::NetworkChangeNotifier::RemoveObserver(this);
+ }
+
+ virtual void OnIPAddressChanged() {
+ LOG(INFO) << "Observed a change to the network IP addresses";
+
+ net::NetLog::Source global_source;
+
+ // TODO(eroman): We shouldn't need to assign an ID to this source, since
+ // conceptually it is the "global event stream". However
+ // currently the javascript does a grouping on source id, so
+ // the display will look weird if we don't give it one.
+ global_source.id = net_log_->NextID();
+
+ net_log_->AddEntry(net::NetLog::TYPE_NETWORK_IP_ADDRESSSES_CHANGED,
+ base::TimeTicks::Now(),
+ global_source,
+ net::NetLog::PHASE_NONE,
+ NULL);
+ }
+
+ private:
+ net::NetLog* net_log_;
+ DISALLOW_COPY_AND_ASSIGN(LoggingNetworkChangeObserver);
+};
+
} // namespace
// The IOThread object must outlive any tasks posted to the IO thread before the
@@ -132,12 +168,22 @@ void IOThread::Init() {
globals_ = new Globals;
globals_->net_log.reset(new ChromeNetLog());
+
+ // Add an observer that will emit network change events to the ChromeNetLog.
+ // Assuming NetworkChangeNotifier dispatches in FIFO order, we should be
+ // logging the network change before other IO thread consumers respond to it.
+ network_change_observer_.reset(
+ new LoggingNetworkChangeObserver(globals_->net_log.get()));
+
globals_->host_resolver = CreateGlobalHostResolver();
globals_->http_auth_handler_factory.reset(CreateDefaultAuthHandlerFactory(
globals_->host_resolver));
}
void IOThread::CleanUp() {
+ // This must be reset before the ChromeNetLog is destroyed.
+ network_change_observer_.reset();
+
// If any child processes are still running, terminate them and
// and delete the BrowserChildProcessHost instances to release whatever
// IO thread only resources they are referencing.