Index: components/ukm/test_ukm_service.cc |
diff --git a/components/ukm/test_ukm_service.cc b/components/ukm/test_ukm_service.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..5b72405610ee08793399b7ed82e473a22055499b |
--- /dev/null |
+++ b/components/ukm/test_ukm_service.cc |
@@ -0,0 +1,30 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "components/ukm/test_ukm_service.h" |
+ |
+namespace ukm { |
+ |
+UkmServiceTestingHarness::UkmServiceTestingHarness() { |
+ UkmService::RegisterPrefs(test_prefs_.registry()); |
+ test_prefs_.ClearPref(prefs::kUkmClientId); |
+ test_prefs_.ClearPref(prefs::kUkmPersistedLogs); |
+ |
+ test_ukm_service_ = base::MakeUnique<TestUkmService>(&test_prefs_); |
+} |
+ |
+UkmServiceTestingHarness::~UkmServiceTestingHarness() = default; |
+ |
+TestUkmService::TestUkmService(PrefService* prefs_service) |
+ : UkmService(prefs_service, &test_metrics_service_client_) { |
+ DisableReporting(); |
+} |
+ |
+TestUkmService::~TestUkmService() = default; |
+ |
+const UkmSource* TestUkmService::GetSource(size_t source_num) const { |
+ return sources_for_testing()[source_num].get(); |
+} |
+ |
+} // namespace ukm |