Index: chrome/browser/precache/precache_util.cc |
diff --git a/chrome/browser/precache/precache_util.cc b/chrome/browser/precache/precache_util.cc |
index 049155ba5122cea054071d7eb1b8884612c5a18d..f9a38aa00d8d3c2e6b5ff186c572fe2204e79c1d 100644 |
--- a/chrome/browser/precache/precache_util.cc |
+++ b/chrome/browser/precache/precache_util.cc |
@@ -4,13 +4,19 @@ |
#include "chrome/browser/precache/precache_util.h" |
+#include <vector> |
+ |
+#include "base/metrics/field_trial.h" |
+#include "base/strings/string_util.h" |
#include "base/time/time.h" |
#include "chrome/browser/browser_process.h" |
+#include "chrome/browser/metrics/chrome_metrics_service_accessor.h" |
#include "chrome/browser/precache/precache_manager_factory.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/profiles/profile_manager.h" |
#include "components/data_use_measurement/content/content_url_request_classifier.h" |
#include "components/precache/content/precache_manager.h" |
+#include "components/variations/metrics_util.h" |
#include "content/public/browser/browser_thread.h" |
#include "net/url_request/url_request.h" |
#include "url/gurl.h" |
@@ -21,6 +27,15 @@ class HttpResponseInfo; |
namespace { |
+const char kPrecacheFieldTrialName[] = "Precache"; |
+const char kPrecacheSyntheticFieldTrialName[] = "PrecacheSynthetic"; |
+ |
+// Users who precached in the last |kDaysForPrecacheCandidates| and |
+// |kDaysForRecentPrecacheCandidates| days will be placed in separate trial |
+// groups. |
+const size_t kDaysForPrecacheCandidates = 15; |
+const size_t kDaysForRecentPrecacheCandidates = 1; |
jamartin
2016/12/21 23:54:33
(nit)
s/kDaysForPrecacheCandidates/kDaysForPrecac
twifkak
2017/01/05 23:53:14
You read my code incorrectly. Keep in mind that th
|
+ |
void UpdatePrecacheMetricsAndStateOnUIThread(const GURL& url, |
const GURL& referrer, |
base::TimeDelta latency, |
@@ -70,4 +85,17 @@ void UpdatePrecacheMetricsAndState(const net::URLRequest* request, |
data_use_measurement::IsUserRequest(*request), profile_id)); |
} |
+void RegisterPrecacheSyntheticFieldTrial(const base::Time& last_precache_time) { |
+ std::vector<uint32_t> groups; |
+ base::TimeDelta time_ago = base::Time::Now() - last_precache_time; |
+ std::string group_name = |
+ base::FieldTrialList::FindFullName(kPrecacheFieldTrialName); |
+ if (time_ago <= base::TimeDelta::FromDays(kDaysForPrecacheCandidates)) |
+ groups.push_back(metrics::HashName(group_name)); |
+ if (time_ago <= base::TimeDelta::FromDays(kDaysForRecentPrecacheCandidates)) |
+ groups.push_back(metrics::HashName(group_name + "Recent")); |
+ ChromeMetricsServiceAccessor::RegisterSyntheticMultiGroupFieldTrial( |
jamartin
2016/12/21 23:54:33
I couldn't find any other caller for this function
twifkak
2017/01/05 23:53:14
It looks like it was implemented in https://chromi
|
+ kPrecacheSyntheticFieldTrialName, groups); |
+} |
+ |
} // namespace precache |