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

Side by Side Diff: chrome/browser/ssl/captive_portal_metrics_recorder.cc

Issue 2063863002: Use DCHECKs when observing only a single notification. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/ssl/captive_portal_metrics_recorder.h" 5 #include "chrome/browser/ssl/captive_portal_metrics_recorder.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 else if (captive_portal_no_response_) 74 else if (captive_portal_no_response_)
75 RecordCaptivePortalEventStats(overridable_ 75 RecordCaptivePortalEventStats(overridable_
76 ? CAPTIVE_PORTAL_NO_RESPONSE_OVERRIDABLE 76 ? CAPTIVE_PORTAL_NO_RESPONSE_OVERRIDABLE
77 : CAPTIVE_PORTAL_NO_RESPONSE); 77 : CAPTIVE_PORTAL_NO_RESPONSE);
78 } 78 }
79 79
80 void CaptivePortalMetricsRecorder::Observe( 80 void CaptivePortalMetricsRecorder::Observe(
81 int type, 81 int type,
82 const content::NotificationSource& source, 82 const content::NotificationSource& source,
83 const content::NotificationDetails& details) { 83 const content::NotificationDetails& details) {
84 DCHECK_EQ(chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT, type);
85
84 // When detection is disabled, captive portal service always sends 86 // When detection is disabled, captive portal service always sends
85 // RESULT_INTERNET_CONNECTED. Ignore any probe results in that case. 87 // RESULT_INTERNET_CONNECTED. Ignore any probe results in that case.
86 if (!captive_portal_detection_enabled_) 88 if (!captive_portal_detection_enabled_)
87 return; 89 return;
88 if (type == chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT) { 90
89 captive_portal_probe_completed_ = true; 91 captive_portal_probe_completed_ = true;
90 CaptivePortalService::Results* results = 92 CaptivePortalService::Results* results =
91 content::Details<CaptivePortalService::Results>(details).ptr(); 93 content::Details<CaptivePortalService::Results>(details).ptr();
92 // If a captive portal was detected at any point when the interstitial was 94 // If a captive portal was detected at any point when the interstitial was
93 // displayed, assume that the interstitial was caused by a captive portal. 95 // displayed, assume that the interstitial was caused by a captive portal.
94 // Example scenario: 96 // Example scenario:
95 // 1- Interstitial displayed and captive portal detected, setting the flag. 97 // 1- Interstitial displayed and captive portal detected, setting the flag.
96 // 2- Captive portal detection automatically opens portal login page. 98 // 2- Captive portal detection automatically opens portal login page.
97 // 3- User logs in on the portal login page. 99 // 3- User logs in on the portal login page.
98 // A notification will be received here for RESULT_INTERNET_CONNECTED. Make 100 // A notification will be received here for RESULT_INTERNET_CONNECTED. Make
99 // sure we don't clear the captive protal flag, since the interstitial was 101 // sure we don't clear the captive protal flag, since the interstitial was
100 // potentially caused by the captive portal. 102 // potentially caused by the captive portal.
101 captive_portal_detected_ = 103 captive_portal_detected_ =
102 captive_portal_detected_ || 104 captive_portal_detected_ ||
103 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); 105 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL);
104 // Also keep track of non-HTTP portals and error cases. 106 // Also keep track of non-HTTP portals and error cases.
105 captive_portal_no_response_ = 107 captive_portal_no_response_ =
106 captive_portal_no_response_ || 108 captive_portal_no_response_ ||
107 (results->result == captive_portal::RESULT_NO_RESPONSE); 109 (results->result == captive_portal::RESULT_NO_RESPONSE);
108 }
109 } 110 }
OLDNEW
« no previous file with comments | « chrome/browser/spellchecker/spellcheck_service.cc ('k') | chrome/browser/ssl/ssl_client_auth_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698