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

Side by Side Diff: chrome/browser/metrics/desktop_engagement/desktop_engagement_service.cc

Issue 2328163002: Revert of Discount for inactivity timeout for recording session length. (https://codereview.chromiu… (Closed)
Patch Set: Created 4 years, 3 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
« no previous file with comments | « no previous file | chrome/browser/metrics/desktop_engagement/desktop_engagement_service_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/metrics/desktop_engagement/desktop_engagement_service.h " 5 #include "chrome/browser/metrics/desktop_engagement/desktop_engagement_service.h "
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/metrics/histogram_macros.h" 8 #include "base/metrics/histogram_macros.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "components/variations/variations_associated_data.h" 10 #include "components/variations/variations_associated_data.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 in_session_ = true; 110 in_session_ = true;
111 is_first_session_ = false; 111 is_first_session_ = false;
112 session_start_ = base::TimeTicks::Now(); 112 session_start_ = base::TimeTicks::Now();
113 StartTimer(inactivity_timeout_); 113 StartTimer(inactivity_timeout_);
114 } 114 }
115 115
116 void DesktopEngagementService::EndSession() { 116 void DesktopEngagementService::EndSession() {
117 in_session_ = false; 117 in_session_ = false;
118 118
119 base::TimeDelta delta = base::TimeTicks::Now() - session_start_; 119 base::TimeDelta delta = base::TimeTicks::Now() - session_start_;
120
121 // If timer is not running then session ended because of inactivity.
122 if (!timer_.IsRunning())
123 delta -= inactivity_timeout_;
124
125 DVLOG(4) << "Logging session length of " << delta.InSeconds() << " seconds."; 120 DVLOG(4) << "Logging session length of " << delta.InSeconds() << " seconds.";
126 121
127 // Note: This metric is recorded separately for Android in 122 // Note: This metric is recorded separately for Android in
128 // UmaSessionStats::UmaEndSession. 123 // UmaSessionStats::UmaEndSession.
129 UMA_HISTOGRAM_LONG_TIMES("Session.TotalDuration", delta); 124 UMA_HISTOGRAM_LONG_TIMES("Session.TotalDuration", delta);
130 } 125 }
131 126
132 void DesktopEngagementService::InitInactivityTimeout() { 127 void DesktopEngagementService::InitInactivityTimeout() {
133 const int kDefaultInactivityTimeoutMinutes = 5; 128 const int kDefaultInactivityTimeoutMinutes = 5;
134 129
135 int timeout_minutes = kDefaultInactivityTimeoutMinutes; 130 int timeout_minutes = kDefaultInactivityTimeoutMinutes;
136 std::string param_value = variations::GetVariationParamValue( 131 std::string param_value = variations::GetVariationParamValue(
137 "DesktopEngagement", "inactivity_timeout"); 132 "DesktopEngagement", "inactivity_timeout");
138 if (!param_value.empty()) 133 if (!param_value.empty())
139 base::StringToInt(param_value, &timeout_minutes); 134 base::StringToInt(param_value, &timeout_minutes);
140 135
141 inactivity_timeout_ = base::TimeDelta::FromMinutes(timeout_minutes); 136 inactivity_timeout_ = base::TimeDelta::FromMinutes(timeout_minutes);
142 } 137 }
143 138
144 } // namespace metrics 139 } // namespace metrics
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/metrics/desktop_engagement/desktop_engagement_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698