Enable Persistent Histograms on iOS

Bug: 963504
Change-Id: I3eae1120ba7b4b7cfd6cbc2a7d2cfc9c1c20d313
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1616988
Commit-Queue: Mike Dougherty <michaeldo@chromium.org>
Reviewed-by: Rohit Rao <rohitrao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#661472}
diff --git a/ios/chrome/browser/ios_chrome_field_trials.cc b/ios/chrome/browser/ios_chrome_field_trials.cc
index 3ba4cd2..d2afe96 100644
--- a/ios/chrome/browser/ios_chrome_field_trials.cc
+++ b/ios/chrome/browser/ios_chrome_field_trials.cc
@@ -4,6 +4,18 @@
 
 #include "ios/chrome/browser/ios_chrome_field_trials.h"
 
+#include "base/path_service.h"
+#include "components/metrics/persistent_histograms.h"
+#include "ios/chrome/browser/chrome_paths.h"
+
+void IOSChromeFieldTrials::SetupFieldTrials() {
+  // Persistent histograms must be enabled as soon as possible.
+  base::FilePath user_data_dir;
+  if (base::PathService::Get(ios::DIR_USER_DATA, &user_data_dir)) {
+    InstantiatePersistentHistograms(user_data_dir);
+  }
+}
+
 void IOSChromeFieldTrials::SetupFeatureControllingFieldTrials(
     bool has_seed,
     base::FeatureList* feature_list) {
diff --git a/ios/chrome/browser/ios_chrome_field_trials.h b/ios/chrome/browser/ios_chrome_field_trials.h
index 68c2b05b..25c35fa 100644
--- a/ios/chrome/browser/ios_chrome_field_trials.h
+++ b/ios/chrome/browser/ios_chrome_field_trials.h
@@ -16,7 +16,7 @@
   ~IOSChromeFieldTrials() override {}
 
   // variations::PlatformFieldTrials:
-  void SetupFieldTrials() override {}
+  void SetupFieldTrials() override;
   void SetupFeatureControllingFieldTrials(
       bool has_seed,
       base::FeatureList* feature_list) override;