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

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

Issue 11620007: Switch from OnIPAddressChanged and OnConnectionTypeChange to OnNetworkChanged Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 months 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
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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 int value; 226 int value;
227 if (!base::StringToInt(command_line.GetSwitchValueASCII(switch_name), 227 if (!base::StringToInt(command_line.GetSwitchValueASCII(switch_name),
228 &value)) { 228 &value)) {
229 return 0; 229 return 0;
230 } 230 }
231 return value; 231 return value;
232 } 232 }
233 233
234 } // namespace 234 } // namespace
235 235
236 class IOThread::LoggingNetworkChangeObserver 236 class IOThreadLoggingNetworkChangeObserver
237 : public net::NetworkChangeNotifier::IPAddressObserver, 237 : public net::NetworkChangeNotifier::IPAddressObserver,
238 public net::NetworkChangeNotifier::ConnectionTypeObserver, 238 public net::NetworkChangeNotifier::ConnectionTypeObserver,
239 public net::NetworkChangeNotifier::NetworkChangeObserver { 239 public net::NetworkChangeNotifier::NetworkChangeObserver {
240 public: 240 public:
241 // |net_log| must remain valid throughout our lifetime. 241 // |net_log| must remain valid throughout our lifetime.
242 explicit LoggingNetworkChangeObserver(net::NetLog* net_log) 242 explicit IOThreadLoggingNetworkChangeObserver(net::NetLog* net_log)
243 : net_log_(net_log) { 243 : net_log_(net_log) {
244 net::NetworkChangeNotifier::AddIPAddressObserver(this); 244 net::NetworkChangeNotifier::Deprecated::AddIPAddressObserver(this);
245 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); 245 net::NetworkChangeNotifier::Deprecated::AddConnectionTypeObserver(this);
246 net::NetworkChangeNotifier::AddNetworkChangeObserver(this); 246 net::NetworkChangeNotifier::AddNetworkChangeObserver(this);
247 } 247 }
248 248
249 ~LoggingNetworkChangeObserver() { 249 ~IOThreadLoggingNetworkChangeObserver() {
250 net::NetworkChangeNotifier::RemoveIPAddressObserver(this); 250 net::NetworkChangeNotifier::RemoveIPAddressObserver(this);
251 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this); 251 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this);
252 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this); 252 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this);
253 } 253 }
254 254
255 // NetworkChangeNotifier::IPAddressObserver implementation. 255 // NetworkChangeNotifier::IPAddressObserver implementation.
256 virtual void OnIPAddressChanged() OVERRIDE { 256 virtual void OnIPAddressChanged() OVERRIDE {
257 VLOG(1) << "Observed a change to the network IP addresses"; 257 VLOG(1) << "Observed a change to the network IP addresses";
258 258
259 net_log_->AddGlobalEntry(net::NetLog::TYPE_NETWORK_IP_ADDRESSES_CHANGED); 259 net_log_->AddGlobalEntry(net::NetLog::TYPE_NETWORK_IP_ADDRESSES_CHANGED);
(...skipping 21 matching lines...) Expand all
281 281
282 VLOG(1) << "Observed a network change to state " << type_as_string; 282 VLOG(1) << "Observed a network change to state " << type_as_string;
283 283
284 net_log_->AddGlobalEntry( 284 net_log_->AddGlobalEntry(
285 net::NetLog::TYPE_NETWORK_CHANGED, 285 net::NetLog::TYPE_NETWORK_CHANGED,
286 net::NetLog::StringCallback("new_connection_type", &type_as_string)); 286 net::NetLog::StringCallback("new_connection_type", &type_as_string));
287 } 287 }
288 288
289 private: 289 private:
290 net::NetLog* net_log_; 290 net::NetLog* net_log_;
291 DISALLOW_COPY_AND_ASSIGN(LoggingNetworkChangeObserver); 291 DISALLOW_COPY_AND_ASSIGN(IOThreadLoggingNetworkChangeObserver);
292 }; 292 };
293 293
294 class SystemURLRequestContextGetter : public net::URLRequestContextGetter { 294 class SystemURLRequestContextGetter : public net::URLRequestContextGetter {
295 public: 295 public:
296 explicit SystemURLRequestContextGetter(IOThread* io_thread); 296 explicit SystemURLRequestContextGetter(IOThread* io_thread);
297 297
298 // Implementation for net::UrlRequestContextGetter. 298 // Implementation for net::UrlRequestContextGetter.
299 virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE; 299 virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE;
300 virtual scoped_refptr<base::SingleThreadTaskRunner> 300 virtual scoped_refptr<base::SingleThreadTaskRunner>
301 GetNetworkTaskRunner() const OVERRIDE; 301 GetNetworkTaskRunner() const OVERRIDE;
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 453
454 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 454 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
455 455
456 DCHECK(!globals_); 456 DCHECK(!globals_);
457 globals_ = new Globals; 457 globals_ = new Globals;
458 458
459 // Add an observer that will emit network change events to the ChromeNetLog. 459 // Add an observer that will emit network change events to the ChromeNetLog.
460 // Assuming NetworkChangeNotifier dispatches in FIFO order, we should be 460 // Assuming NetworkChangeNotifier dispatches in FIFO order, we should be
461 // logging the network change before other IO thread consumers respond to it. 461 // logging the network change before other IO thread consumers respond to it.
462 network_change_observer_.reset( 462 network_change_observer_.reset(
463 new LoggingNetworkChangeObserver(net_log_)); 463 new IOThreadLoggingNetworkChangeObserver(net_log_));
464 464
465 // Setup the HistogramWatcher to run on the IO thread. 465 // Setup the HistogramWatcher to run on the IO thread.
466 net::NetworkChangeNotifier::InitHistogramWatcher(); 466 net::NetworkChangeNotifier::InitHistogramWatcher();
467 467
468 globals_->extension_event_router_forwarder = 468 globals_->extension_event_router_forwarder =
469 extension_event_router_forwarder_; 469 extension_event_router_forwarder_;
470 ChromeNetworkDelegate* network_delegate = 470 ChromeNetworkDelegate* network_delegate =
471 new ChromeNetworkDelegate(extension_event_router_forwarder_, 471 new ChromeNetworkDelegate(extension_event_router_forwarder_,
472 &system_enable_referrers_); 472 &system_enable_referrers_);
473 if (command_line.HasSwitch(switches::kDisableExtensionsHttpThrottling)) 473 if (command_line.HasSwitch(switches::kDisableExtensionsHttpThrottling))
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 globals_->system_request_context.reset( 890 globals_->system_request_context.reset(
891 ConstructSystemRequestContext(globals_, net_log_)); 891 ConstructSystemRequestContext(globals_, net_log_));
892 892
893 sdch_manager_->set_sdch_fetcher( 893 sdch_manager_->set_sdch_fetcher(
894 new SdchDictionaryFetcher(system_url_request_context_getter_.get())); 894 new SdchDictionaryFetcher(system_url_request_context_getter_.get()));
895 } 895 }
896 896
897 void IOThread::UpdateDnsClientEnabled() { 897 void IOThread::UpdateDnsClientEnabled() {
898 globals()->host_resolver->SetDnsClientEnabled(*dns_client_enabled_); 898 globals()->host_resolver->SetDnsClientEnabled(*dns_client_enabled_);
899 } 899 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698