| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/browser/metrics/chrome_stability_metrics_provider.h" | 5 #include "chrome/browser/metrics/chrome_stability_metrics_provider.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "chrome/test/base/testing_browser_process.h" | 8 #include "chrome/test/base/testing_browser_process.h" |
| 9 #include "chrome/test/base/testing_profile.h" | 9 #include "chrome/test/base/testing_profile.h" |
| 10 #include "chrome/test/base/testing_profile_manager.h" | 10 #include "chrome/test/base/testing_profile_manager.h" |
| 11 #include "components/metrics/proto/system_profile.pb.h" | 11 #include "components/metrics/proto/system_profile.pb.h" |
| 12 #include "components/prefs/pref_service.h" | 12 #include "components/prefs/pref_service.h" |
| 13 #include "components/prefs/scoped_user_pref_update.h" | 13 #include "components/prefs/scoped_user_pref_update.h" |
| 14 #include "components/prefs/testing_pref_service.h" | 14 #include "components/prefs/testing_pref_service.h" |
| 15 #include "content/public/browser/browser_context.h" | 15 #include "content/public/browser/browser_context.h" |
| 16 #include "content/public/browser/child_process_data.h" | 16 #include "content/public/browser/child_process_data.h" |
| 17 #include "content/public/browser/notification_details.h" | 17 #include "content/public/browser/notification_details.h" |
| 18 #include "content/public/browser/notification_source.h" | 18 #include "content/public/browser/notification_source.h" |
| 19 #include "content/public/browser/notification_types.h" | 19 #include "content/public/browser/notification_types.h" |
| 20 #include "content/public/browser/render_process_host.h" | 20 #include "content/public/browser/render_process_host.h" |
| 21 #include "content/public/browser/site_instance.h" | 21 #include "content/public/browser/site_instance.h" |
| 22 #include "content/public/common/process_type.h" | 22 #include "content/public/common/process_type.h" |
| 23 #include "content/public/test/mock_render_process_host.h" | 23 #include "content/public/test/mock_render_process_host.h" |
| 24 #include "content/public/test/test_browser_thread_bundle.h" | 24 #include "content/public/test/test_browser_thread_bundle.h" |
| 25 #include "extensions/features/features.h" |
| 25 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
| 26 | 27 |
| 27 #if defined(ENABLE_EXTENSIONS) | 28 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 28 #include "extensions/browser/process_map.h" | 29 #include "extensions/browser/process_map.h" |
| 29 #endif | 30 #endif |
| 30 | 31 |
| 31 namespace { | 32 namespace { |
| 32 | 33 |
| 33 class ChromeStabilityMetricsProviderTest : public testing::Test { | 34 class ChromeStabilityMetricsProviderTest : public testing::Test { |
| 34 protected: | 35 protected: |
| 35 ChromeStabilityMetricsProviderTest() : prefs_(new TestingPrefServiceSimple) { | 36 ChromeStabilityMetricsProviderTest() : prefs_(new TestingPrefServiceSimple) { |
| 36 metrics::StabilityMetricsHelper::RegisterPrefs(prefs()->registry()); | 37 metrics::StabilityMetricsHelper::RegisterPrefs(prefs()->registry()); |
| 37 } | 38 } |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 metrics::SystemProfileProto system_profile; | 125 metrics::SystemProfileProto system_profile; |
| 125 | 126 |
| 126 // Call ProvideStabilityMetrics to check that it will force pending tasks to | 127 // Call ProvideStabilityMetrics to check that it will force pending tasks to |
| 127 // be executed immediately. | 128 // be executed immediately. |
| 128 provider.ProvideStabilityMetrics(&system_profile); | 129 provider.ProvideStabilityMetrics(&system_profile); |
| 129 | 130 |
| 130 EXPECT_EQ(2, system_profile.stability().renderer_crash_count()); | 131 EXPECT_EQ(2, system_profile.stability().renderer_crash_count()); |
| 131 EXPECT_EQ(1, system_profile.stability().renderer_failed_launch_count()); | 132 EXPECT_EQ(1, system_profile.stability().renderer_failed_launch_count()); |
| 132 EXPECT_EQ(0, system_profile.stability().extension_renderer_crash_count()); | 133 EXPECT_EQ(0, system_profile.stability().extension_renderer_crash_count()); |
| 133 | 134 |
| 134 #if defined(ENABLE_EXTENSIONS) | 135 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 135 provider.ClearSavedStabilityMetrics(); | 136 provider.ClearSavedStabilityMetrics(); |
| 136 | 137 |
| 137 // Owned by rph_factory. | 138 // Owned by rph_factory. |
| 138 content::RenderProcessHost* extension_host( | 139 content::RenderProcessHost* extension_host( |
| 139 rph_factory->CreateRenderProcessHost(profile, site_instance.get())); | 140 rph_factory->CreateRenderProcessHost(profile, site_instance.get())); |
| 140 | 141 |
| 141 // Make the rph an extension rph. | 142 // Make the rph an extension rph. |
| 142 extensions::ProcessMap::Get(profile) | 143 extensions::ProcessMap::Get(profile) |
| 143 ->Insert("1", extension_host->GetID(), site_instance->GetId()); | 144 ->Insert("1", extension_host->GetID(), site_instance->GetId()); |
| 144 | 145 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 160 provider.ProvideStabilityMetrics(&system_profile); | 161 provider.ProvideStabilityMetrics(&system_profile); |
| 161 | 162 |
| 162 EXPECT_EQ(0, system_profile.stability().renderer_crash_count()); | 163 EXPECT_EQ(0, system_profile.stability().renderer_crash_count()); |
| 163 EXPECT_EQ(1, system_profile.stability().extension_renderer_crash_count()); | 164 EXPECT_EQ(1, system_profile.stability().extension_renderer_crash_count()); |
| 164 EXPECT_EQ( | 165 EXPECT_EQ( |
| 165 1, system_profile.stability().extension_renderer_failed_launch_count()); | 166 1, system_profile.stability().extension_renderer_failed_launch_count()); |
| 166 #endif | 167 #endif |
| 167 | 168 |
| 168 profile_manager->DeleteAllTestingProfiles(); | 169 profile_manager->DeleteAllTestingProfiles(); |
| 169 } | 170 } |
| OLD | NEW |