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

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

Issue 2326723003: Discount for inactivity timeout for recording session length (Closed)
Patch Set: fix histogram description 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
120 DVLOG(4) << "Logging session length of " << delta.InSeconds() << " seconds."; 125 DVLOG(4) << "Logging session length of " << delta.InSeconds() << " seconds.";
121 126
122 // Note: This metric is recorded separately for Android in 127 // Note: This metric is recorded separately for Android in
123 // UmaSessionStats::UmaEndSession. 128 // UmaSessionStats::UmaEndSession.
124 UMA_HISTOGRAM_LONG_TIMES("Session.TotalDuration", delta); 129 UMA_HISTOGRAM_LONG_TIMES("Session.TotalDuration", delta);
125 } 130 }
126 131
127 void DesktopEngagementService::InitInactivityTimeout() { 132 void DesktopEngagementService::InitInactivityTimeout() {
128 const int kDefaultInactivityTimeoutMinutes = 5; 133 const int kDefaultInactivityTimeoutMinutes = 5;
129 134
130 int timeout_minutes = kDefaultInactivityTimeoutMinutes; 135 int timeout_minutes = kDefaultInactivityTimeoutMinutes;
131 std::string param_value = variations::GetVariationParamValue( 136 std::string param_value = variations::GetVariationParamValue(
132 "DesktopEngagement", "inactivity_timeout"); 137 "DesktopEngagement", "inactivity_timeout");
133 if (!param_value.empty()) 138 if (!param_value.empty())
134 base::StringToInt(param_value, &timeout_minutes); 139 base::StringToInt(param_value, &timeout_minutes);
135 140
136 inactivity_timeout_ = base::TimeDelta::FromMinutes(timeout_minutes); 141 inactivity_timeout_ = base::TimeDelta::FromMinutes(timeout_minutes);
137 } 142 }
138 143
139 } // namespace metrics 144 } // 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