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

Side by Side Diff: components/payments/core/journey_logger.cc

Issue 2893943004: Refactor UKM interface for mojo-ification (Closed)
Patch Set: Fixed contextualsearch Created 3 years, 7 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
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/payments/core/journey_logger.h" 5 #include "components/payments/core/journey_logger.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/metrics/histogram_functions.h" 9 #include "base/metrics/histogram_functions.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
11 #include "components/ukm/ukm_entry_builder.h" 11 #include "components/ukm/public/ukm_entry_builder.h"
12 #include "components/ukm/ukm_service.h" 12 #include "components/ukm/public/ukm_recorder.h"
13 13
14 namespace payments { 14 namespace payments {
15 15
16 namespace internal { 16 namespace internal {
17 extern const char kUKMCheckoutEventsEntryName[] = 17 extern const char kUKMCheckoutEventsEntryName[] =
18 "PaymentRequest.CheckoutEvents"; 18 "PaymentRequest.CheckoutEvents";
19 extern const char kUKMCompletionStatusMetricName[] = "CompletionStatus"; 19 extern const char kUKMCompletionStatusMetricName[] = "CompletionStatus";
20 extern const char kUKMEventsMetricName[] = "Events"; 20 extern const char kUKMEventsMetricName[] = "Events";
21 } // namespace internal 21 } // namespace internal
22 22
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 } 58 }
59 59
60 DCHECK(!name_suffix.empty()); 60 DCHECK(!name_suffix.empty());
61 return name_suffix; 61 return name_suffix;
62 } 62 }
63 63
64 } // namespace 64 } // namespace
65 65
66 JourneyLogger::JourneyLogger(bool is_incognito, 66 JourneyLogger::JourneyLogger(bool is_incognito,
67 const GURL& url, 67 const GURL& url,
68 ukm::UkmService* ukm_service) 68 ukm::UkmRecorder* ukm_recorder)
69 : is_incognito_(is_incognito), 69 : is_incognito_(is_incognito),
70 events_(EVENT_INITIATED), 70 events_(EVENT_INITIATED),
71 url_(url), 71 url_(url),
72 ukm_service_(ukm_service) {} 72 ukm_recorder_(ukm_recorder) {}
73 73
74 JourneyLogger::~JourneyLogger() { 74 JourneyLogger::~JourneyLogger() {
75 if (was_show_called_) 75 if (was_show_called_)
76 DCHECK(has_recorded_); 76 DCHECK(has_recorded_);
77 } 77 }
78 78
79 void JourneyLogger::IncrementSelectionAdds(Section section) { 79 void JourneyLogger::IncrementSelectionAdds(Section section) {
80 DCHECK_LT(section, SECTION_MAX); 80 DCHECK_LT(section, SECTION_MAX);
81 sections_[section].number_selection_adds_++; 81 sections_[section].number_selection_adds_++;
82 } 82 }
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 histogram_name += "Used.TrueWithShowEffectOnCompletion"; 235 histogram_name += "Used.TrueWithShowEffectOnCompletion";
236 } else { 236 } else {
237 histogram_name += "Used.FalseWithShowEffectOnCompletion"; 237 histogram_name += "Used.FalseWithShowEffectOnCompletion";
238 } 238 }
239 239
240 base::UmaHistogramEnumeration(histogram_name, completion_status, 240 base::UmaHistogramEnumeration(histogram_name, completion_status,
241 COMPLETION_STATUS_MAX); 241 COMPLETION_STATUS_MAX);
242 } 242 }
243 243
244 void JourneyLogger::RecordUrlKeyedMetrics(CompletionStatus completion_status) { 244 void JourneyLogger::RecordUrlKeyedMetrics(CompletionStatus completion_status) {
245 if (!ukm_service_ || !url_.is_valid()) 245 if (!ukm_recorder_ || !url_.is_valid())
246 return; 246 return;
247 247
248 // Record the Checkout Funnel UKM. 248 // Record the Checkout Funnel UKM.
249 int32_t source_id = ukm_service_->GetNewSourceID(); 249 ukm::SourceId source_id = ukm_recorder_->GetNewSourceID();
250 ukm_service_->UpdateSourceURL(source_id, url_); 250 ukm_recorder_->UpdateSourceURL(source_id, url_);
251 std::unique_ptr<ukm::UkmEntryBuilder> builder = ukm_service_->GetEntryBuilder( 251 std::unique_ptr<ukm::UkmEntryBuilder> builder =
252 source_id, internal::kUKMCheckoutEventsEntryName); 252 ukm_recorder_->GetEntryBuilder(source_id,
253 internal::kUKMCheckoutEventsEntryName);
253 builder->AddMetric(internal::kUKMCompletionStatusMetricName, 254 builder->AddMetric(internal::kUKMCompletionStatusMetricName,
254 completion_status); 255 completion_status);
255 builder->AddMetric(internal::kUKMEventsMetricName, events_); 256 builder->AddMetric(internal::kUKMEventsMetricName, events_);
256 } 257 }
257 258
258 } // namespace payments 259 } // namespace payments
OLDNEW
« no previous file with comments | « components/payments/core/journey_logger.h ('k') | components/payments/core/journey_logger_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698