Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(176)

Side by Side Diff: chrome/browser/io_thread.cc

Issue 11270039: Add NetworkChangeNotifier connectivity events to the NetLog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | net/base/net_log_event_type_list.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/io_thread.h" 5 #include "chrome/browser/io_thread.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 context->set_server_bound_cert_service( 237 context->set_server_bound_cert_service(
238 globals->system_server_bound_cert_service.get()); 238 globals->system_server_bound_cert_service.get());
239 context->set_throttler_manager(globals->throttler_manager.get()); 239 context->set_throttler_manager(globals->throttler_manager.get());
240 context->set_network_delegate(globals->system_network_delegate.get()); 240 context->set_network_delegate(globals->system_network_delegate.get());
241 return context; 241 return context;
242 } 242 }
243 243
244 } // namespace 244 } // namespace
245 245
246 class IOThread::LoggingNetworkChangeObserver 246 class IOThread::LoggingNetworkChangeObserver
247 : public net::NetworkChangeNotifier::IPAddressObserver { 247 : public net::NetworkChangeNotifier::IPAddressObserver,
248 public net::NetworkChangeNotifier::ConnectionTypeObserver {
248 public: 249 public:
249 // |net_log| must remain valid throughout our lifetime. 250 // |net_log| must remain valid throughout our lifetime.
250 explicit LoggingNetworkChangeObserver(net::NetLog* net_log) 251 explicit LoggingNetworkChangeObserver(net::NetLog* net_log)
251 : net_log_(net_log) { 252 : net_log_(net_log) {
252 net::NetworkChangeNotifier::AddIPAddressObserver(this); 253 net::NetworkChangeNotifier::AddIPAddressObserver(this);
254 net::NetworkChangeNotifier::AddConnectionTypeObserver(this);
253 } 255 }
254 256
255 ~LoggingNetworkChangeObserver() { 257 ~LoggingNetworkChangeObserver() {
256 net::NetworkChangeNotifier::RemoveIPAddressObserver(this); 258 net::NetworkChangeNotifier::RemoveIPAddressObserver(this);
259 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this);
257 } 260 }
258 261
259 virtual void OnIPAddressChanged() { 262 virtual void OnIPAddressChanged() OVERRIDE {
260 VLOG(1) << "Observed a change to the network IP addresses"; 263 VLOG(1) << "Observed a change to the network IP addresses";
261 264
262 net_log_->AddGlobalEntry(net::NetLog::TYPE_NETWORK_IP_ADDRESSES_CHANGED); 265 net_log_->AddGlobalEntry(net::NetLog::TYPE_NETWORK_IP_ADDRESSES_CHANGED);
263 } 266 }
264 267
268 virtual void OnConnectionTypeChanged(
269 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE {
270 std::string type_as_string =
271 net::NetworkChangeNotifier::ConnectionTypeToString(type);
272
273 VLOG(1) << "Observed a change to network connectivity state "
274 << type_as_string;
275
276 net_log_->AddGlobalEntry(
277 net::NetLog::TYPE_NETWORK_CONNECTIVITY_CHANGED,
278 net::NetLog::StringCallback("new_connection_type", &type_as_string));
279 }
280
265 private: 281 private:
266 net::NetLog* net_log_; 282 net::NetLog* net_log_;
267 DISALLOW_COPY_AND_ASSIGN(LoggingNetworkChangeObserver); 283 DISALLOW_COPY_AND_ASSIGN(LoggingNetworkChangeObserver);
268 }; 284 };
269 285
270 class SystemURLRequestContextGetter : public net::URLRequestContextGetter { 286 class SystemURLRequestContextGetter : public net::URLRequestContextGetter {
271 public: 287 public:
272 explicit SystemURLRequestContextGetter(IOThread* io_thread); 288 explicit SystemURLRequestContextGetter(IOThread* io_thread);
273 289
274 // Implementation for net::UrlRequestContextGetter. 290 // Implementation for net::UrlRequestContextGetter.
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 new net::HttpNetworkLayer( 736 new net::HttpNetworkLayer(
721 new net::HttpNetworkSession(system_params))); 737 new net::HttpNetworkSession(system_params)));
722 globals_->system_ftp_transaction_factory.reset( 738 globals_->system_ftp_transaction_factory.reset(
723 new net::FtpNetworkLayer(globals_->host_resolver.get())); 739 new net::FtpNetworkLayer(globals_->host_resolver.get()));
724 globals_->system_request_context.reset( 740 globals_->system_request_context.reset(
725 ConstructSystemRequestContext(globals_, net_log_)); 741 ConstructSystemRequestContext(globals_, net_log_));
726 742
727 sdch_manager_->set_sdch_fetcher( 743 sdch_manager_->set_sdch_fetcher(
728 new SdchDictionaryFetcher(system_url_request_context_getter_.get())); 744 new SdchDictionaryFetcher(system_url_request_context_getter_.get()));
729 } 745 }
OLDNEW
« no previous file with comments | « no previous file | net/base/net_log_event_type_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698