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

Side by Side Diff: chrome/browser/metrics/chrome_stability_metrics_provider_unittest.cc

Issue 1320153002: Add new termination status for failed launch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase and a nit. Created 5 years, 3 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 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/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/prefs/scoped_user_pref_update.h" 9 #include "base/prefs/scoped_user_pref_update.h"
10 #include "base/prefs/testing_pref_service.h" 10 #include "base/prefs/testing_pref_service.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 105
106 // Kill does not increment renderer crash count. 106 // Kill does not increment renderer crash count.
107 content::RenderProcessHost::RendererClosedDetails kill_details( 107 content::RenderProcessHost::RendererClosedDetails kill_details(
108 base::TERMINATION_STATUS_PROCESS_WAS_KILLED, 1); 108 base::TERMINATION_STATUS_PROCESS_WAS_KILLED, 1);
109 provider.Observe( 109 provider.Observe(
110 content::NOTIFICATION_RENDERER_PROCESS_CLOSED, 110 content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
111 content::Source<content::RenderProcessHost>(host), 111 content::Source<content::RenderProcessHost>(host),
112 content::Details<content::RenderProcessHost::RendererClosedDetails>( 112 content::Details<content::RenderProcessHost::RendererClosedDetails>(
113 &kill_details)); 113 &kill_details));
114 114
115 // Failed launch increments crash count.
116 content::RenderProcessHost::RendererClosedDetails failed_launch_details(
117 base::TERMINATION_STATUS_LAUNCH_FAILED, 1);
118 provider.Observe(
119 content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
120 content::Source<content::RenderProcessHost>(host),
121 content::Details<content::RenderProcessHost::RendererClosedDetails>(
122 &failed_launch_details));
123
115 metrics::SystemProfileProto system_profile; 124 metrics::SystemProfileProto system_profile;
116 125
117 // Call ProvideStabilityMetrics to check that it will force pending tasks to 126 // Call ProvideStabilityMetrics to check that it will force pending tasks to
118 // be executed immediately. 127 // be executed immediately.
119 provider.ProvideStabilityMetrics(&system_profile); 128 provider.ProvideStabilityMetrics(&system_profile);
120 129
121 EXPECT_EQ(2, system_profile.stability().renderer_crash_count()); 130 EXPECT_EQ(3, system_profile.stability().renderer_crash_count());
122 EXPECT_EQ(0, system_profile.stability().extension_renderer_crash_count()); 131 EXPECT_EQ(0, system_profile.stability().extension_renderer_crash_count());
123 132
124 #if defined(ENABLE_EXTENSIONS) 133 #if defined(ENABLE_EXTENSIONS)
125 provider.ClearSavedStabilityMetrics(); 134 provider.ClearSavedStabilityMetrics();
126 135
127 // Owned by rph_factory. 136 // Owned by rph_factory.
128 content::RenderProcessHost* extension_host( 137 content::RenderProcessHost* extension_host(
129 rph_factory->CreateRenderProcessHost(profile, site_instance.get())); 138 rph_factory->CreateRenderProcessHost(profile, site_instance.get()));
130 139
131 // Make the rph an extension rph. 140 // Make the rph an extension rph.
132 extensions::ProcessMap::Get(profile) 141 extensions::ProcessMap::Get(profile)
133 ->Insert("1", extension_host->GetID(), site_instance->GetId()); 142 ->Insert("1", extension_host->GetID(), site_instance->GetId());
134 143
135 // Crash and abnormal termination should increment extension crash count. 144 // Crash and abnormal termination should increment extension crash count.
136 provider.Observe( 145 provider.Observe(
137 content::NOTIFICATION_RENDERER_PROCESS_CLOSED, 146 content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
138 content::Source<content::RenderProcessHost>(extension_host), 147 content::Source<content::RenderProcessHost>(extension_host),
139 content::Details<content::RenderProcessHost::RendererClosedDetails>( 148 content::Details<content::RenderProcessHost::RendererClosedDetails>(
140 &crash_details)); 149 &crash_details));
141 150
142 system_profile.Clear(); 151 system_profile.Clear();
143 provider.ProvideStabilityMetrics(&system_profile); 152 provider.ProvideStabilityMetrics(&system_profile);
144 153
145 EXPECT_EQ(0, system_profile.stability().renderer_crash_count()); 154 EXPECT_EQ(0, system_profile.stability().renderer_crash_count());
146 EXPECT_EQ(1, system_profile.stability().extension_renderer_crash_count()); 155 EXPECT_EQ(1, system_profile.stability().extension_renderer_crash_count());
147 #endif 156 #endif
148 157
149 profile_manager->DeleteAllTestingProfiles(); 158 profile_manager->DeleteAllTestingProfiles();
150 } 159 }
OLDNEW
« no previous file with comments | « chrome/browser/metrics/chrome_stability_metrics_provider.cc ('k') | chrome/browser/ui/sad_tab_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698