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

Side by Side Diff: net/base/network_change_notifier.cc

Issue 11115009: Helper functions in NetworkChangeNotifier related to WWAN use (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Remove whitespace Created 8 years, 2 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
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 "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
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::IsConnectionCellular(ConnectionType type) {
284 bool is_cellular = false;
285 switch (type) {
286 case CONNECTION_2G:
287 case CONNECTION_3G:
288 case CONNECTION_4G:
289 is_cellular = true;
290 break;
291 case CONNECTION_UNKNOWN:
292 case CONNECTION_ETHERNET:
293 case CONNECTION_WIFI:
294 case CONNECTION_NONE:
295 is_cellular = false;
296 break;
297 }
298 return is_cellular;
299 }
300
301 // static
278 NetworkChangeNotifier* NetworkChangeNotifier::CreateMock() { 302 NetworkChangeNotifier* NetworkChangeNotifier::CreateMock() {
279 return new MockNetworkChangeNotifier(); 303 return new MockNetworkChangeNotifier();
280 } 304 }
281 305
282 void NetworkChangeNotifier::AddIPAddressObserver(IPAddressObserver* observer) { 306 void NetworkChangeNotifier::AddIPAddressObserver(IPAddressObserver* observer) {
283 if (g_network_change_notifier) 307 if (g_network_change_notifier)
284 g_network_change_notifier->ip_address_observer_list_->AddObserver(observer); 308 g_network_change_notifier->ip_address_observer_list_->AddObserver(observer);
285 } 309 }
286 310
287 void NetworkChangeNotifier::AddConnectionTypeObserver( 311 void NetworkChangeNotifier::AddConnectionTypeObserver(
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 DCHECK(g_network_change_notifier); 406 DCHECK(g_network_change_notifier);
383 g_network_change_notifier = NULL; 407 g_network_change_notifier = NULL;
384 } 408 }
385 409
386 NetworkChangeNotifier::DisableForTest::~DisableForTest() { 410 NetworkChangeNotifier::DisableForTest::~DisableForTest() {
387 DCHECK(!g_network_change_notifier); 411 DCHECK(!g_network_change_notifier);
388 g_network_change_notifier = network_change_notifier_; 412 g_network_change_notifier = network_change_notifier_;
389 } 413 }
390 414
391 } // namespace net 415 } // namespace net
OLDNEW
« net/base/network_change_notifier.h ('K') | « net/base/network_change_notifier.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698