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

Side by Side Diff: chrome/browser/chromeos/net/network_portal_detector_impl.cc

Issue 99223009: Fixed current OOBE captive portal metrics. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix. Created 6 years, 12 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "chrome/browser/chromeos/net/network_portal_detector_impl.h" 5 #include "chrome/browser/chromeos/net/network_portal_detector_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 21 matching lines...) Expand all
32 // Minimum timeout between consecutive portal checks for the same 32 // Minimum timeout between consecutive portal checks for the same
33 // network. 33 // network.
34 const int kMinTimeBetweenAttemptsSec = 3; 34 const int kMinTimeBetweenAttemptsSec = 3;
35 35
36 // Delay before portal detection caused by changes in proxy settings. 36 // Delay before portal detection caused by changes in proxy settings.
37 const int kProxyChangeDelaySec = 1; 37 const int kProxyChangeDelaySec = 1;
38 38
39 // Delay between consecutive portal checks for a network in lazy mode. 39 // Delay between consecutive portal checks for a network in lazy mode.
40 const int kLazyCheckIntervalSec = 5; 40 const int kLazyCheckIntervalSec = 5;
41 41
42 const char kCaptivePortalStatusUnknown[] = "Unknown"; 42 void RecordDiscrepancyWithShill(
43 const char kCaptivePortalStatusOffline[] = "Offline"; 43 const NetworkState* network,
44 const char kCaptivePortalStatusOnline[] = "Online"; 44 const NetworkPortalDetector::CaptivePortalStatus status) {
45 const char kCaptivePortalStatusPortal[] = "Portal"; 45 if (network->connection_state() == shill::kStateOnline) {
46 const char kCaptivePortalStatusProxyAuthRequired[] = 46 UMA_HISTOGRAM_ENUMERATION(
47 "Proxy authentication required"; 47 "CaptivePortal.OOBE.DiscrepancyWithShill_Online",
48 const char kCaptivePortalStatusUnrecognized[] = "Unrecognized"; 48 status,
49 49 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_COUNT);
50 std::string CaptivePortalStatusString( 50 } else if (network->connection_state() == shill::kStatePortal) {
51 NetworkPortalDetectorImpl::CaptivePortalStatus status) { 51 UMA_HISTOGRAM_ENUMERATION(
52 switch (status) { 52 "CaptivePortal.OOBE.DiscrepancyWithShill_RestrictedPool",
53 case NetworkPortalDetectorImpl::CAPTIVE_PORTAL_STATUS_UNKNOWN: 53 status,
54 return kCaptivePortalStatusUnknown; 54 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_COUNT);
55 case NetworkPortalDetectorImpl::CAPTIVE_PORTAL_STATUS_OFFLINE: 55 } else if (network->connection_state() == shill::kStateOffline) {
56 return kCaptivePortalStatusOffline; 56 UMA_HISTOGRAM_ENUMERATION(
57 case NetworkPortalDetectorImpl::CAPTIVE_PORTAL_STATUS_ONLINE: 57 "CaptivePortal.OOBE.DiscrepancyWithShill_Offline",
58 return kCaptivePortalStatusOnline; 58 status,
59 case NetworkPortalDetectorImpl::CAPTIVE_PORTAL_STATUS_PORTAL: 59 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_COUNT);
60 return kCaptivePortalStatusPortal;
61 case NetworkPortalDetectorImpl::CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED:
62 return kCaptivePortalStatusProxyAuthRequired;
63 case NetworkPortalDetectorImpl::CAPTIVE_PORTAL_STATUS_COUNT:
64 NOTREACHED();
65 } 60 }
66 return kCaptivePortalStatusUnrecognized;
67 } 61 }
68 62
69 } // namespace 63 } // namespace
70 64
71 //////////////////////////////////////////////////////////////////////////////// 65 ////////////////////////////////////////////////////////////////////////////////
72 // NetworkPortalDetectorImpl, public: 66 // NetworkPortalDetectorImpl, public:
73 67
74 NetworkPortalDetectorImpl::NetworkPortalDetectorImpl( 68 NetworkPortalDetectorImpl::NetworkPortalDetectorImpl(
75 const scoped_refptr<net::URLRequestContextGetter>& request_context) 69 const scoped_refptr<net::URLRequestContextGetter>& request_context)
76 : state_(STATE_IDLE), 70 : state_(STATE_IDLE),
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 return state_ == STATE_PORTAL_CHECK_PENDING; 439 return state_ == STATE_PORTAL_CHECK_PENDING;
446 } 440 }
447 441
448 bool NetworkPortalDetectorImpl::IsCheckingForPortal() const { 442 bool NetworkPortalDetectorImpl::IsCheckingForPortal() const {
449 return state_ == STATE_CHECKING_FOR_PORTAL; 443 return state_ == STATE_CHECKING_FOR_PORTAL;
450 } 444 }
451 445
452 void NetworkPortalDetectorImpl::SetCaptivePortalState( 446 void NetworkPortalDetectorImpl::SetCaptivePortalState(
453 const NetworkState* network, 447 const NetworkState* network,
454 const CaptivePortalState& state) { 448 const CaptivePortalState& state) {
455 if (!detection_start_time_.is_null()) {
456 UMA_HISTOGRAM_TIMES("CaptivePortal.OOBE.DetectionDuration",
457 GetCurrentTimeTicks() - detection_start_time_);
458 }
459
460 if (!network) { 449 if (!network) {
461 NotifyPortalDetectionCompleted(network, state); 450 NotifyPortalDetectionCompleted(network, state);
462 return; 451 return;
463 } 452 }
464 453
465 CaptivePortalStateMap::const_iterator it = 454 CaptivePortalStateMap::const_iterator it =
466 portal_state_map_.find(network->path()); 455 portal_state_map_.find(network->path());
467 if (it == portal_state_map_.end() || 456 if (it == portal_state_map_.end() ||
468 it->second.status != state.status || 457 it->second.status != state.status ||
469 it->second.response_code != state.response_code) { 458 it->second.response_code != state.response_code) {
470 VLOG(1) << "Updating Chrome Captive Portal state: " 459 VLOG(1) << "Updating Chrome Captive Portal state: "
471 << "name=" << network->name() << ", " 460 << "name=" << network->name() << ", "
472 << "id=" << network->guid() << ", " 461 << "id=" << network->guid() << ", "
473 << "status=" << CaptivePortalStatusString(state.status) << ", " 462 << "status=" << CaptivePortalStatusString(state.status) << ", "
474 << "response_code=" << state.response_code; 463 << "response_code=" << state.response_code;
464
465 // Record detection duration iff detection result differs from the
466 // previous one for this network. The reason is to record only
467 // detection duration when network changes it's state, as we're
468 // interested only on distribution of detection duration, not
Nikita (slow) 2014/01/09 13:48:56 nit: update comment, all stats are reported only o
ygorshenin1 2014/01/09 14:59:35 Done.
469 // distribution of detection duration multiplied by number of
470 // checks.
471 RecordDetectionStats(network, state.status);
472
475 portal_state_map_[network->path()] = state; 473 portal_state_map_[network->path()] = state;
476 } 474 }
477 NotifyPortalDetectionCompleted(network, state); 475 NotifyPortalDetectionCompleted(network, state);
478 } 476 }
479 477
480 void NetworkPortalDetectorImpl::NotifyPortalDetectionCompleted( 478 void NetworkPortalDetectorImpl::NotifyPortalDetectionCompleted(
481 const NetworkState* network, 479 const NetworkState* network,
482 const CaptivePortalState& state) { 480 const CaptivePortalState& state) {
483 FOR_EACH_OBSERVER(Observer, observers_, 481 FOR_EACH_OBSERVER(Observer, observers_,
484 OnPortalDetectionCompleted(network, state)); 482 OnPortalDetectionCompleted(network, state));
(...skipping 13 matching lines...) Expand all
498 DCHECK_LE(0, attempt_count_); 496 DCHECK_LE(0, attempt_count_);
499 const NetworkState* network = 497 const NetworkState* network =
500 NetworkHandler::Get()->network_state_handler()->DefaultNetwork(); 498 NetworkHandler::Get()->network_state_handler()->DefaultNetwork();
501 if (!network) 499 if (!network)
502 return kBaseRequestTimeoutSec; 500 return kBaseRequestTimeoutSec;
503 if (lazy_detection_enabled_) 501 if (lazy_detection_enabled_)
504 return kLazyRequestTimeoutSec; 502 return kLazyRequestTimeoutSec;
505 return attempt_count_ * kBaseRequestTimeoutSec; 503 return attempt_count_ * kBaseRequestTimeoutSec;
506 } 504 }
507 505
506 void NetworkPortalDetectorImpl::RecordDetectionStats(
507 const NetworkState* network,
508 CaptivePortalStatus status) {
509 // Don't record stats for offline state.
510 if (!network)
511 return;
512
513 if (!detection_start_time_.is_null()) {
514 UMA_HISTOGRAM_MEDIUM_TIMES("CaptivePortal.OOBE.DetectionDuration",
515 GetCurrentTimeTicks() - detection_start_time_);
516 }
517 UMA_HISTOGRAM_ENUMERATION("CaptivePortal.OOBE.DetectionResult", status,
Nikita (slow) 2014/01/09 13:48:56 nit: status on a separate line.
ygorshenin1 2014/01/09 14:59:35 Done.
518 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_COUNT);
519 switch (status) {
520 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN:
521 NOTREACHED();
522 break;
523 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_OFFLINE:
524 if (network->connection_state() == shill::kStateOnline ||
525 network->connection_state() == shill::kStatePortal)
526 RecordDiscrepancyWithShill(network, status);
Nikita (slow) 2014/01/09 13:48:56 nit: {}
ygorshenin1 2014/01/09 14:59:35 Done.
527 break;
528 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE:
529 if (network->connection_state() != shill::kStateOnline)
530 RecordDiscrepancyWithShill(network, status);
531 break;
532 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL:
533 if (network->connection_state() != shill::kStatePortal)
534 RecordDiscrepancyWithShill(network, status);
535 break;
536 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED:
537 if (network->connection_state() != shill::kStateOnline)
538 RecordDiscrepancyWithShill(network, status);
539 break;
540 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_COUNT:
541 NOTREACHED();
542 break;
543 }
544 }
545
508 } // namespace chromeos 546 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698