| 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 <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 static const char* kConnectionTypeNames[] = { | 558 static const char* kConnectionTypeNames[] = { |
| 559 "CONNECTION_UNKNOWN", | 559 "CONNECTION_UNKNOWN", |
| 560 "CONNECTION_ETHERNET", | 560 "CONNECTION_ETHERNET", |
| 561 "CONNECTION_WIFI", | 561 "CONNECTION_WIFI", |
| 562 "CONNECTION_2G", | 562 "CONNECTION_2G", |
| 563 "CONNECTION_3G", | 563 "CONNECTION_3G", |
| 564 "CONNECTION_4G", | 564 "CONNECTION_4G", |
| 565 "CONNECTION_NONE", | 565 "CONNECTION_NONE", |
| 566 "CONNECTION_BLUETOOTH" | 566 "CONNECTION_BLUETOOTH" |
| 567 }; | 567 }; |
| 568 COMPILE_ASSERT( | 568 static_assert(arraysize(kConnectionTypeNames) == |
| 569 arraysize(kConnectionTypeNames) == | 569 NetworkChangeNotifier::CONNECTION_LAST + 1, |
| 570 NetworkChangeNotifier::CONNECTION_LAST + 1, | 570 "ConnectionType name count should match"); |
| 571 ConnectionType_name_count_mismatch); | |
| 572 if (type < CONNECTION_UNKNOWN || type > CONNECTION_LAST) { | 571 if (type < CONNECTION_UNKNOWN || type > CONNECTION_LAST) { |
| 573 NOTREACHED(); | 572 NOTREACHED(); |
| 574 return "CONNECTION_INVALID"; | 573 return "CONNECTION_INVALID"; |
| 575 } | 574 } |
| 576 return kConnectionTypeNames[type]; | 575 return kConnectionTypeNames[type]; |
| 577 } | 576 } |
| 578 | 577 |
| 579 // static | 578 // static |
| 580 void NetworkChangeNotifier::NotifyDataReceived(const URLRequest& request, | 579 void NetworkChangeNotifier::NotifyDataReceived(const URLRequest& request, |
| 581 int bytes_read) { | 580 int bytes_read) { |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 959 DCHECK(g_network_change_notifier); | 958 DCHECK(g_network_change_notifier); |
| 960 g_network_change_notifier = NULL; | 959 g_network_change_notifier = NULL; |
| 961 } | 960 } |
| 962 | 961 |
| 963 NetworkChangeNotifier::DisableForTest::~DisableForTest() { | 962 NetworkChangeNotifier::DisableForTest::~DisableForTest() { |
| 964 DCHECK(!g_network_change_notifier); | 963 DCHECK(!g_network_change_notifier); |
| 965 g_network_change_notifier = network_change_notifier_; | 964 g_network_change_notifier = network_change_notifier_; |
| 966 } | 965 } |
| 967 | 966 |
| 968 } // namespace net | 967 } // namespace net |
| OLD | NEW |