OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/port.h" | 9 #include "base/port.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
11 #include "base/prefs/testing_pref_service.h" | 11 #include "base/prefs/testing_pref_service.h" |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
15 #include "base/threading/sequenced_worker_pool.h" | 15 #include "base/threading/sequenced_worker_pool.h" |
16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
17 #include "base/tracked_objects.h" | 17 #include "base/tracked_objects.h" |
18 #include "chrome/browser/google/google_util.h" | 18 #include "chrome/browser/google/google_util.h" |
19 #include "chrome/browser/metrics/metrics_log.h" | 19 #include "chrome/browser/metrics/metrics_log.h" |
20 #include "chrome/browser/prefs/browser_prefs.h" | 20 #include "chrome/browser/prefs/browser_prefs.h" |
21 #include "chrome/common/metrics/proto/profiler_event.pb.h" | 21 #include "chrome/common/metrics/proto/profiler_event.pb.h" |
22 #include "chrome/common/metrics/proto/system_profile.pb.h" | 22 #include "chrome/common/metrics/proto/system_profile.pb.h" |
23 #include "chrome/common/metrics/variations/variations_util.h" | 23 #include "chrome/common/metrics/variations/variations_util.h" |
24 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
25 #include "chrome/installer/util/google_update_settings.h" | 25 #include "chrome/installer/util/google_update_settings.h" |
26 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
27 #include "content/public/common/process_type.h" | 27 #include "content/public/common/process_type.h" |
| 28 #include "content/public/common/webplugininfo.h" |
28 #include "content/public/test/test_utils.h" | 29 #include "content/public/test/test_utils.h" |
29 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
30 #include "ui/gfx/size.h" | 31 #include "ui/gfx/size.h" |
31 #include "url/gurl.h" | 32 #include "url/gurl.h" |
32 #include "webkit/plugins/webplugininfo.h" | |
33 | 33 |
34 #if defined(OS_CHROMEOS) | 34 #if defined(OS_CHROMEOS) |
35 #include "chromeos/dbus/mock_dbus_thread_manager_without_gmock.h" | 35 #include "chromeos/dbus/mock_dbus_thread_manager_without_gmock.h" |
36 #endif // OS_CHROMEOS | 36 #endif // OS_CHROMEOS |
37 | 37 |
38 using base::TimeDelta; | 38 using base::TimeDelta; |
39 using metrics::ProfilerEventProto; | 39 using metrics::ProfilerEventProto; |
40 using tracked_objects::ProcessDataSnapshot; | 40 using tracked_objects::ProcessDataSnapshot; |
41 using tracked_objects::TaskSnapshot; | 41 using tracked_objects::TaskSnapshot; |
42 | 42 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 } // namespace | 121 } // namespace |
122 | 122 |
123 class MetricsLogTest : public testing::Test { | 123 class MetricsLogTest : public testing::Test { |
124 public: | 124 public: |
125 MetricsLogTest() : message_loop_(base::MessageLoop::TYPE_IO) {} | 125 MetricsLogTest() : message_loop_(base::MessageLoop::TYPE_IO) {} |
126 | 126 |
127 protected: | 127 protected: |
128 void TestRecordEnvironment(bool proto_only) { | 128 void TestRecordEnvironment(bool proto_only) { |
129 TestMetricsLog log(kClientId, kSessionId); | 129 TestMetricsLog log(kClientId, kSessionId); |
130 | 130 |
131 std::vector<webkit::WebPluginInfo> plugins; | 131 std::vector<content::WebPluginInfo> plugins; |
132 GoogleUpdateMetrics google_update_metrics; | 132 GoogleUpdateMetrics google_update_metrics; |
133 if (proto_only) | 133 if (proto_only) |
134 log.RecordEnvironmentProto(plugins, google_update_metrics); | 134 log.RecordEnvironmentProto(plugins, google_update_metrics); |
135 else | 135 else |
136 log.RecordEnvironment(plugins, google_update_metrics); | 136 log.RecordEnvironment(plugins, google_update_metrics); |
137 | 137 |
138 // Computed from original time of 1373051956. | 138 // Computed from original time of 1373051956. |
139 EXPECT_EQ(1373050800, log.system_profile().install_date()); | 139 EXPECT_EQ(1373050800, log.system_profile().install_date()); |
140 | 140 |
141 // Computed from original time of 1373001211. | 141 // Computed from original time of 1373001211. |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 EXPECT_EQ(113, tracked_object->exec_time_sampled()); | 328 EXPECT_EQ(113, tracked_object->exec_time_sampled()); |
329 EXPECT_EQ(108, tracked_object->queue_time_total()); | 329 EXPECT_EQ(108, tracked_object->queue_time_total()); |
330 EXPECT_EQ(103, tracked_object->queue_time_sampled()); | 330 EXPECT_EQ(103, tracked_object->queue_time_sampled()); |
331 EXPECT_EQ(GG_UINT64_C(7246674144371406371), | 331 EXPECT_EQ(GG_UINT64_C(7246674144371406371), |
332 tracked_object->exec_thread_name_hash()); | 332 tracked_object->exec_thread_name_hash()); |
333 EXPECT_EQ(1177U, tracked_object->process_id()); | 333 EXPECT_EQ(1177U, tracked_object->process_id()); |
334 EXPECT_EQ(ProfilerEventProto::TrackedObject::RENDERER, | 334 EXPECT_EQ(ProfilerEventProto::TrackedObject::RENDERER, |
335 tracked_object->process_type()); | 335 tracked_object->process_type()); |
336 } | 336 } |
337 } | 337 } |
OLD | NEW |