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

Unified Diff: net/base/network_change_notifier.cc

Issue 649763002: git cl format the second third of the net/base directory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
Index: net/base/network_change_notifier.cc
diff --git a/net/base/network_change_notifier.cc b/net/base/network_change_notifier.cc
index bea6759c93d8ced597a1fd5707b50ad5baea03e8..5624d3725a6bc20bea9c9b94478cd9c97f4fe060 100644
--- a/net/base/network_change_notifier.cc
+++ b/net/base/network_change_notifier.cc
@@ -53,11 +53,10 @@ class MockNetworkChangeNotifier : public NetworkChangeNotifier {
} // namespace
// The main observer class that records UMAs for network events.
-class HistogramWatcher
- : public NetworkChangeNotifier::ConnectionTypeObserver,
- public NetworkChangeNotifier::IPAddressObserver,
- public NetworkChangeNotifier::DNSObserver,
- public NetworkChangeNotifier::NetworkChangeObserver {
+class HistogramWatcher : public NetworkChangeNotifier::ConnectionTypeObserver,
+ public NetworkChangeNotifier::IPAddressObserver,
+ public NetworkChangeNotifier::DNSObserver,
+ public NetworkChangeNotifier::NetworkChangeObserver {
public:
HistogramWatcher()
: last_ip_address_change_(base::TimeTicks::Now()),
@@ -238,9 +237,8 @@ class HistogramWatcher
if ((now - last_offline_packet_received_) <
base::TimeDelta::FromSeconds(5)) {
// We can compare this sum with the sum of NCN.OfflineDataRecv.
- UMA_HISTOGRAM_COUNTS_10000(
- "NCN.OfflineDataRecvAny5sBeforeOnline",
- offline_packets_received_);
+ UMA_HISTOGRAM_COUNTS_10000("NCN.OfflineDataRecvAny5sBeforeOnline",
+ offline_packets_received_);
}
UMA_HISTOGRAM_MEDIUM_TIMES("NCN.OfflineDataRecvUntilOnline",
@@ -252,9 +250,8 @@ class HistogramWatcher
NetworkChangeNotifier::LogOperatorCodeHistogram(type);
- UMA_HISTOGRAM_MEDIUM_TIMES(
- "NCN.IPAddressChangeToConnectionTypeChange",
- now - last_ip_address_change_);
+ UMA_HISTOGRAM_MEDIUM_TIMES("NCN.IPAddressChangeToConnectionTypeChange",
+ now - last_ip_address_change_);
offline_packets_received_ = 0;
bytes_read_since_last_connection_change_ = 0;
@@ -322,8 +319,7 @@ class HistogramWatcher
if ((now - last_polled_connection_) > polling_interval_) {
polling_interval_ *= 2;
last_polled_connection_ = now;
- last_polled_connection_type_ =
- NetworkChangeNotifier::GetConnectionType();
+ last_polled_connection_type_ = NetworkChangeNotifier::GetConnectionType();
}
if (last_polled_connection_type_ ==
NetworkChangeNotifier::CONNECTION_NONE) {
@@ -333,7 +329,7 @@ class HistogramWatcher
}
private:
- static base::TimeDelta SinceLast(base::TimeTicks *last_time) {
+ static base::TimeDelta SinceLast(base::TimeTicks* last_time) {
base::TimeTicks current_time = base::TimeTicks::Now();
base::TimeDelta delta = current_time - *last_time;
*last_time = current_time;
@@ -435,7 +431,8 @@ class NetworkChangeNotifier::NetworkChangeCalculator
virtual void OnIPAddressChanged() override {
DCHECK(thread_checker_.CalledOnValidThread());
base::TimeDelta delay = last_announced_connection_type_ == CONNECTION_NONE
- ? params_.ip_address_offline_delay_ : params_.ip_address_online_delay_;
+ ? params_.ip_address_offline_delay_
+ : params_.ip_address_online_delay_;
// Cancels any previous timer.
timer_.Start(FROM_HERE, delay, this, &NetworkChangeCalculator::Notify);
}
@@ -445,8 +442,8 @@ class NetworkChangeNotifier::NetworkChangeCalculator
DCHECK(thread_checker_.CalledOnValidThread());
pending_connection_type_ = type;
base::TimeDelta delay = last_announced_connection_type_ == CONNECTION_NONE
- ? params_.connection_type_offline_delay_
- : params_.connection_type_online_delay_;
+ ? params_.connection_type_offline_delay_
+ : params_.connection_type_online_delay_;
// Cancels any previous timer.
timer_.Start(FROM_HERE, delay, this, &NetworkChangeCalculator::Notify);
}
@@ -493,8 +490,7 @@ NetworkChangeNotifier::~NetworkChangeNotifier() {
}
// static
-void NetworkChangeNotifier::SetFactory(
- NetworkChangeNotifierFactory* factory) {
+void NetworkChangeNotifier::SetFactory(NetworkChangeNotifierFactory* factory) {
CHECK(!g_network_change_notifier_factory);
g_network_change_notifier_factory = factory;
}
@@ -510,7 +506,7 @@ NetworkChangeNotifier* NetworkChangeNotifier::Create() {
network_change_notifier->WatchForAddressChange();
return network_change_notifier;
#elif defined(OS_CHROMEOS) || defined(OS_ANDROID)
- // ChromeOS and Android builds MUST use their own class factory.
+// ChromeOS and Android builds MUST use their own class factory.
#if !defined(OS_CHROMEOS)
// TODO(oshima): ash_shell do not have access to chromeos'es
// notifier yet. Re-enable this when chromeos'es notifier moved to
@@ -531,16 +527,16 @@ NetworkChangeNotifier* NetworkChangeNotifier::Create() {
// static
NetworkChangeNotifier::ConnectionType
NetworkChangeNotifier::GetConnectionType() {
- return g_network_change_notifier ?
- g_network_change_notifier->GetCurrentConnectionType() :
- CONNECTION_UNKNOWN;
+ return g_network_change_notifier
+ ? g_network_change_notifier->GetCurrentConnectionType()
+ : CONNECTION_UNKNOWN;
}
// static
double NetworkChangeNotifier::GetMaxBandwidth() {
- return g_network_change_notifier ?
- g_network_change_notifier->GetCurrentMaxBandwidth() :
- std::numeric_limits<double>::infinity();
+ return g_network_change_notifier
+ ? g_network_change_notifier->GetCurrentMaxBandwidth()
+ : std::numeric_limits<double>::infinity();
}
// static
@@ -553,22 +549,18 @@ void NetworkChangeNotifier::GetDnsConfig(DnsConfig* config) {
}
// static
-const char* NetworkChangeNotifier::ConnectionTypeToString(
- ConnectionType type) {
- static const char* kConnectionTypeNames[] = {
- "CONNECTION_UNKNOWN",
- "CONNECTION_ETHERNET",
- "CONNECTION_WIFI",
- "CONNECTION_2G",
- "CONNECTION_3G",
- "CONNECTION_4G",
- "CONNECTION_NONE",
- "CONNECTION_BLUETOOTH"
- };
- COMPILE_ASSERT(
- arraysize(kConnectionTypeNames) ==
- NetworkChangeNotifier::CONNECTION_LAST + 1,
- ConnectionType_name_count_mismatch);
+const char* NetworkChangeNotifier::ConnectionTypeToString(ConnectionType type) {
+ static const char* kConnectionTypeNames[] = {"CONNECTION_UNKNOWN",
+ "CONNECTION_ETHERNET",
+ "CONNECTION_WIFI",
+ "CONNECTION_2G",
+ "CONNECTION_3G",
+ "CONNECTION_4G",
+ "CONNECTION_NONE",
+ "CONNECTION_BLUETOOTH"};
davidben 2014/10/10 20:24:16 This is probably also better as before, but no str
+ COMPILE_ASSERT(arraysize(kConnectionTypeNames) ==
+ NetworkChangeNotifier::CONNECTION_LAST + 1,
+ ConnectionType_name_count_mismatch);
if (type < CONNECTION_UNKNOWN || type > CONNECTION_LAST) {
NOTREACHED();
return "CONNECTION_INVALID";
@@ -612,8 +604,8 @@ void NetworkChangeNotifier::LogOperatorCodeHistogram(ConnectionType type) {
type == NetworkChangeNotifier::CONNECTION_3G ||
type == NetworkChangeNotifier::CONNECTION_4G) {
// Log zero if not perfectly converted.
- if (!base::StringToUint(
- net::android::GetTelephonyNetworkOperator(), &mcc_mnc)) {
+ if (!base::StringToUint(net::android::GetTelephonyNetworkOperator(),
+ &mcc_mnc)) {
mcc_mnc = 0;
}
}
@@ -625,14 +617,15 @@ void NetworkChangeNotifier::LogOperatorCodeHistogram(ConnectionType type) {
// static
const internal::AddressTrackerLinux*
NetworkChangeNotifier::GetAddressTracker() {
- return g_network_change_notifier ?
- g_network_change_notifier->GetAddressTrackerInternal() : NULL;
+ return g_network_change_notifier
+ ? g_network_change_notifier->GetAddressTrackerInternal()
+ : NULL;
}
#endif
// static
bool NetworkChangeNotifier::IsOffline() {
- return GetConnectionType() == CONNECTION_NONE;
+ return GetConnectionType() == CONNECTION_NONE;
}
// static
@@ -642,7 +635,7 @@ bool NetworkChangeNotifier::IsConnectionCellular(ConnectionType type) {
case CONNECTION_2G:
case CONNECTION_3G:
case CONNECTION_4G:
- is_cellular = true;
+ is_cellular = true;
break;
case CONNECTION_UNKNOWN:
case CONNECTION_ETHERNET:
@@ -747,19 +740,17 @@ void NetworkChangeNotifier::SetTestNotificationsOnly(bool test_only) {
NetworkChangeNotifier::NetworkChangeNotifier(
const NetworkChangeCalculatorParams& params
- /*= NetworkChangeCalculatorParams()*/)
- : ip_address_observer_list_(
- new ObserverListThreadSafe<IPAddressObserver>(
- ObserverListBase<IPAddressObserver>::NOTIFY_EXISTING_ONLY)),
+ /*= NetworkChangeCalculatorParams()*/)
davidben 2014/10/10 20:24:16 This comment should probably have stayed indented,
+ : ip_address_observer_list_(new ObserverListThreadSafe<IPAddressObserver>(
+ ObserverListBase<IPAddressObserver>::NOTIFY_EXISTING_ONLY)),
connection_type_observer_list_(
- new ObserverListThreadSafe<ConnectionTypeObserver>(
- ObserverListBase<ConnectionTypeObserver>::NOTIFY_EXISTING_ONLY)),
- resolver_state_observer_list_(
- new ObserverListThreadSafe<DNSObserver>(
- ObserverListBase<DNSObserver>::NOTIFY_EXISTING_ONLY)),
+ new ObserverListThreadSafe<ConnectionTypeObserver>(
+ ObserverListBase<ConnectionTypeObserver>::NOTIFY_EXISTING_ONLY)),
+ resolver_state_observer_list_(new ObserverListThreadSafe<DNSObserver>(
+ ObserverListBase<DNSObserver>::NOTIFY_EXISTING_ONLY)),
network_change_observer_list_(
- new ObserverListThreadSafe<NetworkChangeObserver>(
- ObserverListBase<NetworkChangeObserver>::NOTIFY_EXISTING_ONLY)),
+ new ObserverListThreadSafe<NetworkChangeObserver>(
+ ObserverListBase<NetworkChangeObserver>::NOTIFY_EXISTING_ONLY)),
network_state_(new NetworkState()),
network_change_calculator_(new NetworkChangeCalculator(params)),
test_notifications_only_(false) {

Powered by Google App Engine
This is Rietveld 408576698