OLD | NEW |
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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 IOThread::LoggingNetworkChangeObserver |
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: | 240 public: |
240 // |net_log| must remain valid throughout our lifetime. | 241 // |net_log| must remain valid throughout our lifetime. |
241 explicit LoggingNetworkChangeObserver(net::NetLog* net_log) | 242 explicit LoggingNetworkChangeObserver(net::NetLog* net_log) |
242 : net_log_(net_log) { | 243 : net_log_(net_log) { |
243 net::NetworkChangeNotifier::AddIPAddressObserver(this); | 244 net::NetworkChangeNotifier::AddIPAddressObserver(this); |
244 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); | 245 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); |
| 246 net::NetworkChangeNotifier::AddNetworkChangeObserver(this); |
245 } | 247 } |
246 | 248 |
247 ~LoggingNetworkChangeObserver() { | 249 ~LoggingNetworkChangeObserver() { |
248 net::NetworkChangeNotifier::RemoveIPAddressObserver(this); | 250 net::NetworkChangeNotifier::RemoveIPAddressObserver(this); |
249 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this); | 251 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this); |
| 252 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this); |
250 } | 253 } |
251 | 254 |
| 255 // NetworkChangeNotifier::IPAddressObserver implementation. |
252 virtual void OnIPAddressChanged() OVERRIDE { | 256 virtual void OnIPAddressChanged() OVERRIDE { |
253 VLOG(1) << "Observed a change to the network IP addresses"; | 257 VLOG(1) << "Observed a change to the network IP addresses"; |
254 | 258 |
255 net_log_->AddGlobalEntry(net::NetLog::TYPE_NETWORK_IP_ADDRESSES_CHANGED); | 259 net_log_->AddGlobalEntry(net::NetLog::TYPE_NETWORK_IP_ADDRESSES_CHANGED); |
256 } | 260 } |
257 | 261 |
| 262 // NetworkChangeNotifier::ConnectionTypeObserver implementation. |
258 virtual void OnConnectionTypeChanged( | 263 virtual void OnConnectionTypeChanged( |
259 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE { | 264 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE { |
260 std::string type_as_string = | 265 std::string type_as_string = |
261 net::NetworkChangeNotifier::ConnectionTypeToString(type); | 266 net::NetworkChangeNotifier::ConnectionTypeToString(type); |
262 | 267 |
263 VLOG(1) << "Observed a change to network connectivity state " | 268 VLOG(1) << "Observed a change to network connectivity state " |
264 << type_as_string; | 269 << type_as_string; |
265 | 270 |
266 net_log_->AddGlobalEntry( | 271 net_log_->AddGlobalEntry( |
267 net::NetLog::TYPE_NETWORK_CONNECTIVITY_CHANGED, | 272 net::NetLog::TYPE_NETWORK_CONNECTIVITY_CHANGED, |
268 net::NetLog::StringCallback("new_connection_type", &type_as_string)); | 273 net::NetLog::StringCallback("new_connection_type", &type_as_string)); |
269 } | 274 } |
270 | 275 |
| 276 // NetworkChangeNotifier::NetworkChangeObserver implementation. |
| 277 virtual void OnNetworkChanged( |
| 278 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE { |
| 279 std::string type_as_string = |
| 280 net::NetworkChangeNotifier::ConnectionTypeToString(type); |
| 281 |
| 282 VLOG(1) << "Observed a network change to state " << type_as_string; |
| 283 |
| 284 net_log_->AddGlobalEntry( |
| 285 net::NetLog::TYPE_NETWORK_CHANGED, |
| 286 net::NetLog::StringCallback("new_connection_type", &type_as_string)); |
| 287 } |
| 288 |
271 private: | 289 private: |
272 net::NetLog* net_log_; | 290 net::NetLog* net_log_; |
273 DISALLOW_COPY_AND_ASSIGN(LoggingNetworkChangeObserver); | 291 DISALLOW_COPY_AND_ASSIGN(LoggingNetworkChangeObserver); |
274 }; | 292 }; |
275 | 293 |
276 class SystemURLRequestContextGetter : public net::URLRequestContextGetter { | 294 class SystemURLRequestContextGetter : public net::URLRequestContextGetter { |
277 public: | 295 public: |
278 explicit SystemURLRequestContextGetter(IOThread* io_thread); | 296 explicit SystemURLRequestContextGetter(IOThread* io_thread); |
279 | 297 |
280 // Implementation for net::UrlRequestContextGetter. | 298 // Implementation for net::UrlRequestContextGetter. |
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
862 globals_->system_request_context.reset( | 880 globals_->system_request_context.reset( |
863 ConstructSystemRequestContext(globals_, net_log_)); | 881 ConstructSystemRequestContext(globals_, net_log_)); |
864 | 882 |
865 sdch_manager_->set_sdch_fetcher( | 883 sdch_manager_->set_sdch_fetcher( |
866 new SdchDictionaryFetcher(system_url_request_context_getter_.get())); | 884 new SdchDictionaryFetcher(system_url_request_context_getter_.get())); |
867 } | 885 } |
868 | 886 |
869 void IOThread::UpdateDnsClientEnabled() { | 887 void IOThread::UpdateDnsClientEnabled() { |
870 globals()->host_resolver->SetDnsClientEnabled(*dns_client_enabled_); | 888 globals()->host_resolver->SetDnsClientEnabled(*dns_client_enabled_); |
871 } | 889 } |
OLD | NEW |