OLD | NEW |
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/engagement/site_engagement_score.h" | 5 #include "chrome/browser/engagement/site_engagement_score.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 5, // DECAY_POINTS | 76 5, // DECAY_POINTS |
77 0.5, // NAVIGATION_POINTS | 77 0.5, // NAVIGATION_POINTS |
78 0.2, // USER_INPUT_POINTS | 78 0.2, // USER_INPUT_POINTS |
79 0.02, // VISIBLE_MEDIA_POINTS | 79 0.02, // VISIBLE_MEDIA_POINTS |
80 0.01, // HIDDEN_MEDIA_POINTS | 80 0.01, // HIDDEN_MEDIA_POINTS |
81 5, // WEB_APP_INSTALLED_POINTS | 81 5, // WEB_APP_INSTALLED_POINTS |
82 0.5, // FIRST_DAILY_ENGAGEMENT | 82 0.5, // FIRST_DAILY_ENGAGEMENT |
83 8, // BOOTSTRAP_POINTS | 83 8, // BOOTSTRAP_POINTS |
84 5, // MEDIUM_ENGAGEMENT_BOUNDARY | 84 5, // MEDIUM_ENGAGEMENT_BOUNDARY |
85 50, // HIGH_ENGAGEMENT_BOUNDARY | 85 50, // HIGH_ENGAGEMENT_BOUNDARY |
| 86 240, // OBSOLETE_LAST_ENGAGEMENT_PERIOD_IN_HOURS |
86 }; | 87 }; |
87 | 88 |
88 const char* SiteEngagementScore::kRawScoreKey = "rawScore"; | 89 const char* SiteEngagementScore::kRawScoreKey = "rawScore"; |
89 const char* SiteEngagementScore::kPointsAddedTodayKey = "pointsAddedToday"; | 90 const char* SiteEngagementScore::kPointsAddedTodayKey = "pointsAddedToday"; |
90 const char* SiteEngagementScore::kLastEngagementTimeKey = "lastEngagementTime"; | 91 const char* SiteEngagementScore::kLastEngagementTimeKey = "lastEngagementTime"; |
91 const char* SiteEngagementScore::kLastShortcutLaunchTimeKey = | 92 const char* SiteEngagementScore::kLastShortcutLaunchTimeKey = |
92 "lastShortcutLaunchTime"; | 93 "lastShortcutLaunchTime"; |
93 | 94 |
94 double SiteEngagementScore::GetMaxPointsPerDay() { | 95 double SiteEngagementScore::GetMaxPointsPerDay() { |
95 return param_values[MAX_POINTS_PER_DAY]; | 96 return param_values[MAX_POINTS_PER_DAY]; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 } | 133 } |
133 | 134 |
134 double SiteEngagementScore::GetMediumEngagementBoundary() { | 135 double SiteEngagementScore::GetMediumEngagementBoundary() { |
135 return param_values[MEDIUM_ENGAGEMENT_BOUNDARY]; | 136 return param_values[MEDIUM_ENGAGEMENT_BOUNDARY]; |
136 } | 137 } |
137 | 138 |
138 double SiteEngagementScore::GetHighEngagementBoundary() { | 139 double SiteEngagementScore::GetHighEngagementBoundary() { |
139 return param_values[HIGH_ENGAGEMENT_BOUNDARY]; | 140 return param_values[HIGH_ENGAGEMENT_BOUNDARY]; |
140 } | 141 } |
141 | 142 |
| 143 double SiteEngagementScore::GetObsoleteLastEngagementPeriodInHours() { |
| 144 return param_values[OBSOLETE_LAST_ENGAGEMENT_PERIOD_IN_HOURS]; |
| 145 } |
| 146 |
142 // static | 147 // static |
143 void SiteEngagementScore::UpdateFromVariations(const char* param_name) { | 148 void SiteEngagementScore::UpdateFromVariations(const char* param_name) { |
144 double param_vals[MAX_VARIATION]; | 149 double param_vals[MAX_VARIATION]; |
145 | 150 |
146 for (int i = 0; i < MAX_VARIATION; ++i) { | 151 for (int i = 0; i < MAX_VARIATION; ++i) { |
147 std::string param_string = | 152 std::string param_string = |
148 variations::GetVariationParamValue(param_name, kVariationNames[i]); | 153 variations::GetVariationParamValue(param_name, kVariationNames[i]); |
149 | 154 |
150 // Bail out if we didn't get a param string for the key, or if we couldn't | 155 // Bail out if we didn't get a param string for the key, or if we couldn't |
151 // convert the param string to a double, or if we get a negative value. | 156 // convert the param string to a double, or if we get a negative value. |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 param_values[HIDDEN_MEDIA_POINTS] = 0.01; | 340 param_values[HIDDEN_MEDIA_POINTS] = 0.01; |
336 param_values[WEB_APP_INSTALLED_POINTS] = 5; | 341 param_values[WEB_APP_INSTALLED_POINTS] = 5; |
337 param_values[BOOTSTRAP_POINTS] = 8; | 342 param_values[BOOTSTRAP_POINTS] = 8; |
338 param_values[MEDIUM_ENGAGEMENT_BOUNDARY] = 5; | 343 param_values[MEDIUM_ENGAGEMENT_BOUNDARY] = 5; |
339 param_values[HIGH_ENGAGEMENT_BOUNDARY] = 50; | 344 param_values[HIGH_ENGAGEMENT_BOUNDARY] = 50; |
340 | 345 |
341 // This is set to zero to avoid interference with tests and is set when | 346 // This is set to zero to avoid interference with tests and is set when |
342 // testing this functionality. | 347 // testing this functionality. |
343 param_values[FIRST_DAILY_ENGAGEMENT] = 0; | 348 param_values[FIRST_DAILY_ENGAGEMENT] = 0; |
344 } | 349 } |
OLD | NEW |