Chromium Code Reviews| 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 "net/base/network_change_notifier.h" | 5 #include "net/base/network_change_notifier.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 #include "base/synchronization/lock.h" | 8 #include "base/synchronization/lock.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 268 #if defined(OS_LINUX) | 268 #if defined(OS_LINUX) |
| 269 // static | 269 // static |
| 270 const internal::AddressTrackerLinux* | 270 const internal::AddressTrackerLinux* |
| 271 NetworkChangeNotifier::GetAddressTracker() { | 271 NetworkChangeNotifier::GetAddressTracker() { |
| 272 return g_network_change_notifier ? | 272 return g_network_change_notifier ? |
| 273 g_network_change_notifier->GetAddressTrackerInternal() : NULL; | 273 g_network_change_notifier->GetAddressTrackerInternal() : NULL; |
| 274 } | 274 } |
| 275 #endif | 275 #endif |
| 276 | 276 |
| 277 // static | 277 // static |
| 278 bool NetworkChangeNotifier::IsOffline() { | |
| 279 return GetConnectionType() == CONNECTION_NONE; | |
| 280 } | |
| 281 | |
| 282 // static | |
| 283 bool NetworkChangeNotifier::IsOverWWAN() { | |
| 284 return IsOverWWAN(GetConnectionType()); | |
| 285 } | |
| 286 | |
| 287 // static | |
| 288 bool NetworkChangeNotifier::IsOverWWAN(ConnectionType type) { | |
| 289 return type >= CONNECTION_2G && type <= CONNECTION_4G; | |
|
pauljensen
2012/10/12 14:01:15
I'd prefer a switch statement. If you want to sti
| |
| 290 } | |
| 291 | |
| 292 // static | |
| 278 NetworkChangeNotifier* NetworkChangeNotifier::CreateMock() { | 293 NetworkChangeNotifier* NetworkChangeNotifier::CreateMock() { |
| 279 return new MockNetworkChangeNotifier(); | 294 return new MockNetworkChangeNotifier(); |
| 280 } | 295 } |
| 281 | 296 |
| 282 void NetworkChangeNotifier::AddIPAddressObserver(IPAddressObserver* observer) { | 297 void NetworkChangeNotifier::AddIPAddressObserver(IPAddressObserver* observer) { |
| 283 if (g_network_change_notifier) | 298 if (g_network_change_notifier) |
| 284 g_network_change_notifier->ip_address_observer_list_->AddObserver(observer); | 299 g_network_change_notifier->ip_address_observer_list_->AddObserver(observer); |
| 285 } | 300 } |
| 286 | 301 |
| 287 void NetworkChangeNotifier::AddConnectionTypeObserver( | 302 void NetworkChangeNotifier::AddConnectionTypeObserver( |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 382 DCHECK(g_network_change_notifier); | 397 DCHECK(g_network_change_notifier); |
| 383 g_network_change_notifier = NULL; | 398 g_network_change_notifier = NULL; |
| 384 } | 399 } |
| 385 | 400 |
| 386 NetworkChangeNotifier::DisableForTest::~DisableForTest() { | 401 NetworkChangeNotifier::DisableForTest::~DisableForTest() { |
| 387 DCHECK(!g_network_change_notifier); | 402 DCHECK(!g_network_change_notifier); |
| 388 g_network_change_notifier = network_change_notifier_; | 403 g_network_change_notifier = network_change_notifier_; |
| 389 } | 404 } |
| 390 | 405 |
| 391 } // namespace net | 406 } // namespace net |
| OLD | NEW |