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

Side by Side Diff: components/metrics/stability_metrics_helper.cc

Issue 2886933003: Use stricter type checking in UMA_HISTOGRAM_ENUMERATION (Closed)
Patch Set: simplify type checking Created 3 years, 5 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 "components/metrics/stability_metrics_helper.h" 5 #include "components/metrics/stability_metrics_helper.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 // Since |abs(STATUS_GUARD_PAGE_VIOLATION) == MAX_INT| it causes problems in 46 // Since |abs(STATUS_GUARD_PAGE_VIOLATION) == MAX_INT| it causes problems in
47 // histograms.cc. Solve this by remapping it to a smaller value, which 47 // histograms.cc. Solve this by remapping it to a smaller value, which
48 // hopefully doesn't conflict with other codes. 48 // hopefully doesn't conflict with other codes.
49 if (static_cast<DWORD>(exit_code) == STATUS_GUARD_PAGE_VIOLATION) 49 if (static_cast<DWORD>(exit_code) == STATUS_GUARD_PAGE_VIOLATION)
50 return 0x1FCF7EC3; // Randomly picked number. 50 return 0x1FCF7EC3; // Randomly picked number.
51 #endif 51 #endif
52 52
53 return std::abs(exit_code); 53 return std::abs(exit_code);
54 } 54 }
55 55
56 void RecordChildKills(int histogram_type) { 56 void RecordChildKills(RendererType histogram_type) {
57 UMA_HISTOGRAM_ENUMERATION("BrowserRenderProcessHost.ChildKills", 57 UMA_HISTOGRAM_ENUMERATION("BrowserRenderProcessHost.ChildKills",
58 histogram_type, RENDERER_TYPE_COUNT); 58 histogram_type, RENDERER_TYPE_COUNT);
59 } 59 }
60 60
61 } // namespace 61 } // namespace
62 62
63 StabilityMetricsHelper::StabilityMetricsHelper(PrefService* local_state) 63 StabilityMetricsHelper::StabilityMetricsHelper(PrefService* local_state)
64 : local_state_(local_state) { 64 : local_state_(local_state) {
65 DCHECK(local_state_); 65 DCHECK(local_state_);
66 } 66 }
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 base::RecordAction(base::UserMetricsAction("PageLoad")); 172 base::RecordAction(base::UserMetricsAction("PageLoad"));
173 IncrementPrefValue(prefs::kStabilityPageLoadCount); 173 IncrementPrefValue(prefs::kStabilityPageLoadCount);
174 IncrementLongPrefsValue(prefs::kUninstallMetricsPageLoadCount); 174 IncrementLongPrefsValue(prefs::kUninstallMetricsPageLoadCount);
175 // We need to save the prefs, as page load count is a critical stat, and it 175 // We need to save the prefs, as page load count is a critical stat, and it
176 // might be lost due to a crash :-(. 176 // might be lost due to a crash :-(.
177 } 177 }
178 178
179 void StabilityMetricsHelper::LogRendererCrash(bool was_extension_process, 179 void StabilityMetricsHelper::LogRendererCrash(bool was_extension_process,
180 base::TerminationStatus status, 180 base::TerminationStatus status,
181 int exit_code) { 181 int exit_code) {
182 int histogram_type = 182 RendererType histogram_type =
183 was_extension_process ? RENDERER_TYPE_EXTENSION : RENDERER_TYPE_RENDERER; 183 was_extension_process ? RENDERER_TYPE_EXTENSION : RENDERER_TYPE_RENDERER;
184 184
185 switch (status) { 185 switch (status) {
186 case base::TERMINATION_STATUS_NORMAL_TERMINATION: 186 case base::TERMINATION_STATUS_NORMAL_TERMINATION:
187 break; 187 break;
188 case base::TERMINATION_STATUS_PROCESS_CRASHED: 188 case base::TERMINATION_STATUS_PROCESS_CRASHED:
189 case base::TERMINATION_STATUS_ABNORMAL_TERMINATION: 189 case base::TERMINATION_STATUS_ABNORMAL_TERMINATION:
190 case base::TERMINATION_STATUS_OOM: 190 case base::TERMINATION_STATUS_OOM:
191 if (was_extension_process) { 191 if (was_extension_process) {
192 IncrementPrefValue(prefs::kStabilityExtensionRendererCrashCount); 192 IncrementPrefValue(prefs::kStabilityExtensionRendererCrashCount);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 void StabilityMetricsHelper::IncrementLongPrefsValue(const char* path) { 256 void StabilityMetricsHelper::IncrementLongPrefsValue(const char* path) {
257 int64_t value = local_state_->GetInt64(path); 257 int64_t value = local_state_->GetInt64(path);
258 local_state_->SetInt64(path, value + 1); 258 local_state_->SetInt64(path, value + 1);
259 } 259 }
260 260
261 void StabilityMetricsHelper::LogRendererHang() { 261 void StabilityMetricsHelper::LogRendererHang() {
262 IncrementPrefValue(prefs::kStabilityRendererHangCount); 262 IncrementPrefValue(prefs::kStabilityRendererHangCount);
263 } 263 }
264 264
265 } // namespace metrics 265 } // namespace metrics
OLDNEW
« no previous file with comments | « components/leveldb/public/cpp/util.cc ('k') | components/password_manager/core/browser/password_syncable_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698