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

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

Issue 11270039: Add NetworkChangeNotifier connectivity events to the NetLog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 8 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « net/base/network_change_notifier.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 // static 245 // static
246 void NetworkChangeNotifier::GetDnsConfig(DnsConfig* config) { 246 void NetworkChangeNotifier::GetDnsConfig(DnsConfig* config) {
247 if (!g_network_change_notifier) { 247 if (!g_network_change_notifier) {
248 *config = DnsConfig(); 248 *config = DnsConfig();
249 } else { 249 } else {
250 g_network_change_notifier->network_state_->GetDnsConfig(config); 250 g_network_change_notifier->network_state_->GetDnsConfig(config);
251 } 251 }
252 } 252 }
253 253
254 // static 254 // static
255 const char* NetworkChangeNotifier::ConnectionTypeToString(
256 ConnectionType type) {
257 static const char* kConnectionTypeNames[] = {
258 "CONNECTION_UNKNOWN",
259 "CONNECTION_ETHERNET",
260 "CONNECTION_WIFI",
261 "CONNECTION_2G",
262 "CONNECTION_3G",
263 "CONNECTION_4G",
264 "CONNECTION_NONE"
265 };
266 COMPILE_ASSERT(
267 arraysize(kConnectionTypeNames) ==
268 NetworkChangeNotifier::CONNECTION_NONE + 1,
269 ConnectionType_name_count_mismatch);
270 if (type < CONNECTION_UNKNOWN || type > CONNECTION_NONE) {
271 NOTREACHED();
272 return "CONNECTION_INVALID";
273 }
274 return kConnectionTypeNames[type];
275 }
276
277 // static
255 void NetworkChangeNotifier::NotifyDataReceived(const GURL& source) { 278 void NetworkChangeNotifier::NotifyDataReceived(const GURL& source) {
256 if (!g_network_change_notifier) 279 if (!g_network_change_notifier)
257 return; 280 return;
258 g_network_change_notifier->histogram_watcher_->NotifyDataReceived(source); 281 g_network_change_notifier->histogram_watcher_->NotifyDataReceived(source);
259 } 282 }
260 283
261 // static 284 // static
262 void NetworkChangeNotifier::InitHistogramWatcher() { 285 void NetworkChangeNotifier::InitHistogramWatcher() {
263 if (!g_network_change_notifier) 286 if (!g_network_change_notifier)
264 return; 287 return;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 DCHECK(g_network_change_notifier); 405 DCHECK(g_network_change_notifier);
383 g_network_change_notifier = NULL; 406 g_network_change_notifier = NULL;
384 } 407 }
385 408
386 NetworkChangeNotifier::DisableForTest::~DisableForTest() { 409 NetworkChangeNotifier::DisableForTest::~DisableForTest() {
387 DCHECK(!g_network_change_notifier); 410 DCHECK(!g_network_change_notifier);
388 g_network_change_notifier = network_change_notifier_; 411 g_network_change_notifier = network_change_notifier_;
389 } 412 }
390 413
391 } // namespace net 414 } // namespace net
OLDNEW
« no previous file with comments | « net/base/network_change_notifier.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698