OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/metrics/metrics_log.h" | 5 #include "components/metrics/metrics_log.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 TestMetricsLog(const std::string& client_id, | 46 TestMetricsLog(const std::string& client_id, |
47 int session_id, | 47 int session_id, |
48 LogType log_type, | 48 LogType log_type, |
49 MetricsServiceClient* client, | 49 MetricsServiceClient* client, |
50 TestingPrefServiceSimple* prefs) | 50 TestingPrefServiceSimple* prefs) |
51 : MetricsLog(client_id, session_id, log_type, client, prefs), | 51 : MetricsLog(client_id, session_id, log_type, client, prefs), |
52 prefs_(prefs) { | 52 prefs_(prefs) { |
53 InitPrefs(); | 53 InitPrefs(); |
54 } | 54 } |
55 | 55 |
56 virtual ~TestMetricsLog() {} | 56 ~TestMetricsLog() override {} |
57 | 57 |
58 const ChromeUserMetricsExtension& uma_proto() const { | 58 const ChromeUserMetricsExtension& uma_proto() const { |
59 return *MetricsLog::uma_proto(); | 59 return *MetricsLog::uma_proto(); |
60 } | 60 } |
61 | 61 |
62 const SystemProfileProto& system_profile() const { | 62 const SystemProfileProto& system_profile() const { |
63 return uma_proto().system_profile(); | 63 return uma_proto().system_profile(); |
64 } | 64 } |
65 | 65 |
66 private: | 66 private: |
67 void InitPrefs() { | 67 void InitPrefs() { |
68 prefs_->SetString(prefs::kMetricsReportingEnabledTimestamp, | 68 prefs_->SetString(prefs::kMetricsReportingEnabledTimestamp, |
69 base::Int64ToString(kEnabledDate)); | 69 base::Int64ToString(kEnabledDate)); |
70 } | 70 } |
71 | 71 |
72 virtual void GetFieldTrialIds( | 72 void GetFieldTrialIds( |
73 std::vector<variations::ActiveGroupId>* field_trial_ids) const | 73 std::vector<variations::ActiveGroupId>* field_trial_ids) const override { |
74 override { | |
75 ASSERT_TRUE(field_trial_ids->empty()); | 74 ASSERT_TRUE(field_trial_ids->empty()); |
76 | 75 |
77 for (size_t i = 0; i < arraysize(kFieldTrialIds); ++i) { | 76 for (size_t i = 0; i < arraysize(kFieldTrialIds); ++i) { |
78 field_trial_ids->push_back(kFieldTrialIds[i]); | 77 field_trial_ids->push_back(kFieldTrialIds[i]); |
79 } | 78 } |
80 } | 79 } |
81 | 80 |
82 // Weak pointer to the PrefsService used by this log. | 81 // Weak pointer to the PrefsService used by this log. |
83 TestingPrefServiceSimple* prefs_; | 82 TestingPrefServiceSimple* prefs_; |
84 | 83 |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 TestMetricsServiceClient client; | 399 TestMetricsServiceClient client; |
401 client.set_product(kTestProduct); | 400 client.set_product(kTestProduct); |
402 TestMetricsLog log( | 401 TestMetricsLog log( |
403 kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client, &prefs_); | 402 kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client, &prefs_); |
404 // Check that the product is set to |kTestProduct|. | 403 // Check that the product is set to |kTestProduct|. |
405 EXPECT_TRUE(log.uma_proto().has_product()); | 404 EXPECT_TRUE(log.uma_proto().has_product()); |
406 EXPECT_EQ(kTestProduct, log.uma_proto().product()); | 405 EXPECT_EQ(kTestProduct, log.uma_proto().product()); |
407 } | 406 } |
408 | 407 |
409 } // namespace metrics | 408 } // namespace metrics |
OLD | NEW |