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

Side by Side Diff: components/feature_engagement_tracker/internal/once_condition_validator.cc

Issue 2911123003: Metrics for feature engagement tracker. (Closed)
Patch Set: Created 3 years, 6 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/feature_engagement_tracker/internal/once_condition_validato r.h" 5 #include "components/feature_engagement_tracker/internal/once_condition_validato r.h"
6 6
7 #include "components/feature_engagement_tracker/internal/configuration.h" 7 #include "components/feature_engagement_tracker/internal/configuration.h"
8 #include "components/feature_engagement_tracker/internal/model.h" 8 #include "components/feature_engagement_tracker/internal/model.h"
9 9
10 namespace feature_engagement_tracker { 10 namespace feature_engagement_tracker {
11 11
12 OnceConditionValidator::OnceConditionValidator() 12 OnceConditionValidator::OnceConditionValidator()
13 : currently_showing_feature_(nullptr) {} 13 : currently_showing_feature_(nullptr) {}
14 14
15 OnceConditionValidator::~OnceConditionValidator() = default; 15 OnceConditionValidator::~OnceConditionValidator() = default;
16 16
17 ConditionValidator::Result OnceConditionValidator::MeetsConditions( 17 ConditionValidator::Result OnceConditionValidator::MeetsConditions(
18 const base::Feature& feature, 18 const base::Feature& feature,
19 const FeatureConfig& config, 19 const FeatureConfig& config,
20 const Model& model, 20 const Model& model,
21 const AvailabilityModel& availability_model, 21 const AvailabilityModel& availability_model,
22 uint32_t current_day) const { 22 uint32_t current_day) const {
23 ConditionValidator::Result result(true); 23 ConditionValidator::Result result(true);
24 result.model_ready_ok = model.IsReady(); 24 result.event_model_ready_ok = model.IsReady();
25 25
26 result.currently_showing_ok = currently_showing_feature_ == nullptr; 26 result.currently_showing_ok = currently_showing_feature_ == nullptr;
27 27
28 result.config_ok = config.valid; 28 result.config_ok = config.valid;
29 29
30 result.session_rate_ok = 30 result.session_rate_ok =
31 shown_features_.find(&feature) == shown_features_.end(); 31 shown_features_.find(&feature) == shown_features_.end();
32 32
33 return result; 33 return result;
34 } 34 }
35 35
36 void OnceConditionValidator::NotifyIsShowing(const base::Feature& feature) { 36 void OnceConditionValidator::NotifyIsShowing(const base::Feature& feature) {
37 DCHECK(currently_showing_feature_ == nullptr); 37 DCHECK(currently_showing_feature_ == nullptr);
38 DCHECK(shown_features_.find(&feature) == shown_features_.end()); 38 DCHECK(shown_features_.find(&feature) == shown_features_.end());
39 shown_features_.insert(&feature); 39 shown_features_.insert(&feature);
40 currently_showing_feature_ = &feature; 40 currently_showing_feature_ = &feature;
41 } 41 }
42 42
43 void OnceConditionValidator::NotifyDismissed(const base::Feature& feature) { 43 void OnceConditionValidator::NotifyDismissed(const base::Feature& feature) {
44 DCHECK(&feature == currently_showing_feature_); 44 DCHECK(&feature == currently_showing_feature_);
45 currently_showing_feature_ = nullptr; 45 currently_showing_feature_ = nullptr;
46 } 46 }
47 47
48 } // namespace feature_engagement_tracker 48 } // namespace feature_engagement_tracker
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698