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

Side by Side Diff: components/ukm/test_ukm_service.cc

Issue 2737953002: UKM: Remove UkmService::RecordSource (Closed)
Patch Set: fix error from rebase Created 3 years, 9 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 | « components/ukm/test_ukm_service.h ('k') | components/ukm/ukm_service.h » ('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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "components/ukm/test_ukm_service.h" 5 #include "components/ukm/test_ukm_service.h"
6 6
7 #include "components/ukm/ukm_source.h"
8
7 namespace ukm { 9 namespace ukm {
8 10
9 UkmServiceTestingHarness::UkmServiceTestingHarness() { 11 UkmServiceTestingHarness::UkmServiceTestingHarness() {
10 UkmService::RegisterPrefs(test_prefs_.registry()); 12 UkmService::RegisterPrefs(test_prefs_.registry());
11 test_prefs_.ClearPref(prefs::kUkmClientId); 13 test_prefs_.ClearPref(prefs::kUkmClientId);
12 test_prefs_.ClearPref(prefs::kUkmSessionId); 14 test_prefs_.ClearPref(prefs::kUkmSessionId);
13 test_prefs_.ClearPref(prefs::kUkmPersistedLogs); 15 test_prefs_.ClearPref(prefs::kUkmPersistedLogs);
14 16
15 test_ukm_service_ = base::MakeUnique<TestUkmService>(&test_prefs_); 17 test_ukm_service_ = base::MakeUnique<TestUkmService>(&test_prefs_);
16 } 18 }
17 19
18 UkmServiceTestingHarness::~UkmServiceTestingHarness() = default; 20 UkmServiceTestingHarness::~UkmServiceTestingHarness() = default;
19 21
20 TestUkmService::TestUkmService(PrefService* prefs_service) 22 TestUkmService::TestUkmService(PrefService* prefs_service)
21 : UkmService(prefs_service, &test_metrics_service_client_) { 23 : UkmService(prefs_service, &test_metrics_service_client_) {
22 EnableRecording(); 24 EnableRecording();
23 DisableReporting(); 25 DisableReporting();
24 } 26 }
25 27
26 TestUkmService::~TestUkmService() = default; 28 TestUkmService::~TestUkmService() = default;
27 29
28 const UkmSource* TestUkmService::GetSource(size_t source_num) const { 30 const std::map<int32_t, std::unique_ptr<UkmSource>>&
29 return sources_for_testing()[source_num].get(); 31 TestUkmService::GetSources() const {
32 return sources_for_testing();
33 }
34
35 const UkmSource* TestUkmService::GetSourceForUrl(const char* url) const {
36 for (const auto& kv : sources_for_testing()) {
37 if (kv.second->url() == url)
38 return kv.second.get();
39 }
40 return nullptr;
30 } 41 }
31 42
32 const UkmEntry* TestUkmService::GetEntry(size_t entry_num) const { 43 const UkmEntry* TestUkmService::GetEntry(size_t entry_num) const {
33 return entries_for_testing()[entry_num].get(); 44 return entries_for_testing()[entry_num].get();
34 } 45 }
35 46
36 } // namespace ukm 47 } // namespace ukm
OLDNEW
« no previous file with comments | « components/ukm/test_ukm_service.h ('k') | components/ukm/ukm_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698