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

Unified Diff: net/base/network_change_notifier.cc

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 638964a25d29ad12016b9d20ad64cf82df7ef222..8aa10df4913a2af66c29f461338f1c386e419246 100644
--- a/net/base/network_change_notifier.cc
+++ b/net/base/network_change_notifier.cc
@@ -45,11 +45,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()),
@@ -217,9 +216,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",
@@ -228,9 +226,8 @@ class HistogramWatcher
} else {
UMA_HISTOGRAM_MEDIUM_TIMES("NCN.OfflineChange", state_duration);
}
- 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;
@@ -298,8 +295,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) {
@@ -309,7 +305,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;
@@ -411,7 +407,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);
}
@@ -421,8 +418,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);
}
@@ -469,8 +466,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;
}
@@ -486,7 +482,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
@@ -507,9 +503,9 @@ 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
@@ -522,21 +518,14 @@ void NetworkChangeNotifier::GetDnsConfig(DnsConfig* config) {
}
// static
-const char* NetworkChangeNotifier::ConnectionTypeToString(
- ConnectionType type) {
+const char* NetworkChangeNotifier::ConnectionTypeToString(ConnectionType type) {
static const char* kConnectionTypeNames[] = {
- "CONNECTION_UNKNOWN",
- "CONNECTION_ETHERNET",
- "CONNECTION_WIFI",
- "CONNECTION_2G",
- "CONNECTION_3G",
- "CONNECTION_4G",
- "CONNECTION_NONE"
- };
- COMPILE_ASSERT(
- arraysize(kConnectionTypeNames) ==
- NetworkChangeNotifier::CONNECTION_NONE + 1,
- ConnectionType_name_count_mismatch);
+ "CONNECTION_UNKNOWN", "CONNECTION_ETHERNET", "CONNECTION_WIFI",
+ "CONNECTION_2G", "CONNECTION_3G", "CONNECTION_4G",
+ "CONNECTION_NONE"};
+ COMPILE_ASSERT(arraysize(kConnectionTypeNames) ==
+ NetworkChangeNotifier::CONNECTION_NONE + 1,
+ ConnectionType_name_count_mismatch);
if (type < CONNECTION_UNKNOWN || type > CONNECTION_NONE) {
NOTREACHED();
return "CONNECTION_INVALID";
@@ -574,14 +563,15 @@ void NetworkChangeNotifier::ShutdownHistogramWatcher() {
// 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
@@ -591,7 +581,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:
@@ -669,19 +659,17 @@ void NetworkChangeNotifier::RemoveNetworkChangeObserver(
NetworkChangeNotifier::NetworkChangeNotifier(
const NetworkChangeCalculatorParams& params
- /*= NetworkChangeCalculatorParams()*/)
- : ip_address_observer_list_(
- new ObserverListThreadSafe<IPAddressObserver>(
- ObserverListBase<IPAddressObserver>::NOTIFY_EXISTING_ONLY)),
+ /*= NetworkChangeCalculatorParams()*/)
+ : 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)) {
DCHECK(!g_network_change_notifier);
@@ -723,8 +711,7 @@ void NetworkChangeNotifier::SetDnsConfig(const DnsConfig& config) {
void NetworkChangeNotifier::NotifyObserversOfConnectionTypeChange() {
if (g_network_change_notifier) {
g_network_change_notifier->connection_type_observer_list_->Notify(
- &ConnectionTypeObserver::OnConnectionTypeChanged,
- GetConnectionType());
+ &ConnectionTypeObserver::OnConnectionTypeChanged, GetConnectionType());
}
}
@@ -732,8 +719,7 @@ void NetworkChangeNotifier::NotifyObserversOfNetworkChange(
ConnectionType type) {
if (g_network_change_notifier) {
g_network_change_notifier->network_change_observer_list_->Notify(
- &NetworkChangeObserver::OnNetworkChanged,
- type);
+ &NetworkChangeObserver::OnNetworkChanged, type);
}
}

Powered by Google App Engine
This is Rietveld 408576698