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

Side by Side Diff: chrome/browser/chrome_browser_field_trials_desktop.cc

Issue 2910003002: Stability instrumentation: metrics for collection on crash (Closed)
Patch Set: remove extra std::move Created 3 years, 6 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/chrome_browser_field_trials_desktop.h" 5 #include "chrome/browser/chrome_browser_field_trials_desktop.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #endif 9 #endif
10 10
11 #include <map> 11 #include <map>
12 #include <string> 12 #include <string>
13 13
14 #include "base/command_line.h" 14 #include "base/command_line.h"
15 #include "base/debug/activity_tracker.h" 15 #include "base/debug/activity_tracker.h"
16 #include "base/feature_list.h" 16 #include "base/feature_list.h"
17 #include "base/files/file_util.h" 17 #include "base/files/file_util.h"
18 #include "base/metrics/field_trial.h" 18 #include "base/metrics/field_trial.h"
19 #include "base/metrics/field_trial_params.h" 19 #include "base/metrics/field_trial_params.h"
20 #include "base/metrics/histogram_macros.h" 20 #include "base/metrics/histogram_macros.h"
21 #include "base/path_service.h" 21 #include "base/path_service.h"
22 #include "base/time/time.h" 22 #include "base/time/time.h"
23 #include "chrome/browser/prerender/prerender_field_trial.h" 23 #include "chrome/browser/prerender/prerender_field_trial.h"
24 #include "chrome/common/chrome_features.h" 24 #include "chrome/common/chrome_features.h"
25 #include "chrome/common/chrome_paths.h" 25 #include "chrome/common/chrome_paths.h"
26 #include "chrome/common/chrome_switches.h" 26 #include "chrome/common/chrome_switches.h"
27 #include "components/browser_watcher/features.h"
28 #include "components/browser_watcher/stability_paths.h"
29 #include "components/variations/variations_associated_data.h" 27 #include "components/variations/variations_associated_data.h"
30 #include "content/public/common/content_switches.h" 28 #include "content/public/common/content_switches.h"
31 #include "media/media_features.h" 29 #include "media/media_features.h"
32 30
33 #if defined(OS_WIN) 31 #if defined(OS_WIN)
34 #include "base/win/pe_image.h" 32 #include "base/win/pe_image.h"
35 #include "chrome/install_static/install_util.h" 33 #include "chrome/install_static/install_util.h"
34 #include "components/browser_watcher/features.h"
36 #include "components/browser_watcher/stability_data_names.h" 35 #include "components/browser_watcher/stability_data_names.h"
36 #include "components/browser_watcher/stability_metrics.h"
37 #include "components/browser_watcher/stability_paths.h"
37 #endif 38 #endif
38 39
39 #if defined(OS_WIN) 40 #if defined(OS_WIN)
40 // http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx 41 // http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx
41 extern "C" IMAGE_DOS_HEADER __ImageBase; 42 extern "C" IMAGE_DOS_HEADER __ImageBase;
42 #endif 43 #endif
43 44
44 namespace chrome { 45 namespace chrome {
45 46
46 namespace { 47 namespace {
(...skipping 13 matching lines...) Expand all
60 "/" + params["server1"] + "/" + params["server2"] + 61 "/" + params["server1"] + "/" + params["server2"] +
61 "/" + params["server3"] + "/" + params["server4"] + 62 "/" + params["server3"] + "/" + params["server4"] +
62 "/" + params["server5"] + "/" + params["server6"]; 63 "/" + params["server5"] + "/" + params["server6"];
63 64
64 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( 65 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
65 switches::kWebRtcStunProbeTrialParameter, cmd_param); 66 switches::kWebRtcStunProbeTrialParameter, cmd_param);
66 #endif 67 #endif
67 } 68 }
68 69
69 #if defined(OS_WIN) 70 #if defined(OS_WIN)
70 // DO NOT CHANGE VALUES. This is logged persistently in a histogram.
71 enum StabilityDebuggingInitializationStatus {
72 INIT_SUCCESS = 0,
73 CREATE_STABILITY_DIR_FAILED = 1,
74 GET_STABILITY_FILE_PATH_FAILED = 2,
75 INIT_STATUS_MAX = 3
76 };
77
78 void LogStabilityDebuggingInitStatus(
79 StabilityDebuggingInitializationStatus status) {
80 UMA_HISTOGRAM_ENUMERATION("ActivityTracker.Record.InitStatus", status,
81 INIT_STATUS_MAX);
82 }
83 71
84 // Record information about the chrome module. 72 // Record information about the chrome module.
85 void RecordChromeModuleInfo( 73 void RecordChromeModuleInfo(
86 base::debug::GlobalActivityTracker* global_tracker) { 74 base::debug::GlobalActivityTracker* global_tracker) {
87 DCHECK(global_tracker); 75 DCHECK(global_tracker);
88 76
89 base::debug::GlobalActivityTracker::ModuleInfo module; 77 base::debug::GlobalActivityTracker::ModuleInfo module;
90 module.is_loaded = true; 78 module.is_loaded = true;
91 module.address = reinterpret_cast<uintptr_t>(&__ImageBase); 79 module.address = reinterpret_cast<uintptr_t>(&__ImageBase);
92 80
(...skipping 29 matching lines...) Expand all
122 // just how much of an arena is necessary. 110 // just how much of an arena is necessary.
123 const size_t kMemorySize = 1 << 20; // 1 MiB 111 const size_t kMemorySize = 1 << 20; // 1 MiB
124 const int kStackDepth = 4; 112 const int kStackDepth = 4;
125 const uint64_t kAllocatorId = 0; 113 const uint64_t kAllocatorId = 0;
126 114
127 // Ensure the stability directory exists and determine the stability file's 115 // Ensure the stability directory exists and determine the stability file's
128 // path. 116 // path.
129 base::FilePath user_data_dir; 117 base::FilePath user_data_dir;
130 if (!base::PathService::Get(chrome::DIR_USER_DATA, &user_data_dir) || 118 if (!base::PathService::Get(chrome::DIR_USER_DATA, &user_data_dir) ||
131 !base::CreateDirectory(browser_watcher::GetStabilityDir(user_data_dir))) { 119 !base::CreateDirectory(browser_watcher::GetStabilityDir(user_data_dir))) {
132 LOG(ERROR) << "Failed to create the stability directory.";
133 LogStabilityDebuggingInitStatus(CREATE_STABILITY_DIR_FAILED);
134 return; 120 return;
135 } 121 }
122 browser_watcher::LogStabilityRecordEvent(
123 browser_watcher::StabilityRecordEvent::kStabilityDirectoryExists);
124
136 base::FilePath stability_file; 125 base::FilePath stability_file;
137 if (!browser_watcher::GetStabilityFileForProcess( 126 if (!browser_watcher::GetStabilityFileForProcess(
138 base::Process::Current(), user_data_dir, &stability_file)) { 127 base::Process::Current(), user_data_dir, &stability_file)) {
139 LOG(ERROR) << "Failed to obtain stability file's path.";
140 LogStabilityDebuggingInitStatus(GET_STABILITY_FILE_PATH_FAILED);
141 return; 128 return;
142 } 129 }
143 LogStabilityDebuggingInitStatus(INIT_SUCCESS); 130 browser_watcher::LogStabilityRecordEvent(
131 browser_watcher::StabilityRecordEvent::kGotStabilityPath);
144 132
145 // Track code activities (such as posting task, blocking on locks, and 133 // Track code activities (such as posting task, blocking on locks, and
146 // joining threads) that can cause hanging threads and general instability 134 // joining threads) that can cause hanging threads and general instability
147 base::debug::GlobalActivityTracker::CreateWithFile( 135 base::debug::GlobalActivityTracker::CreateWithFile(
148 stability_file, kMemorySize, kAllocatorId, 136 stability_file, kMemorySize, kAllocatorId,
149 browser_watcher::kStabilityDebuggingFeature.name, kStackDepth); 137 browser_watcher::kStabilityDebuggingFeature.name, kStackDepth);
150 138
151 // Record basic information. 139 // Record basic information.
152 base::debug::GlobalActivityTracker* global_tracker = 140 base::debug::GlobalActivityTracker* global_tracker =
153 base::debug::GlobalActivityTracker::Get(); 141 base::debug::GlobalActivityTracker::Get();
154 if (global_tracker) { 142 if (global_tracker) {
143 browser_watcher::LogStabilityRecordEvent(
144 browser_watcher::StabilityRecordEvent::kGotTracker);
155 // Record product, version, channel, special build and platform. 145 // Record product, version, channel, special build and platform.
156 wchar_t exe_file[MAX_PATH] = {}; 146 wchar_t exe_file[MAX_PATH] = {};
157 CHECK(::GetModuleFileName(nullptr, exe_file, arraysize(exe_file))); 147 CHECK(::GetModuleFileName(nullptr, exe_file, arraysize(exe_file)));
158 148
159 base::string16 product_name; 149 base::string16 product_name;
160 base::string16 version_number; 150 base::string16 version_number;
161 base::string16 channel_name; 151 base::string16 channel_name;
162 base::string16 special_build; 152 base::string16 special_build;
163 install_static::GetExecutableVersionDetails(exe_file, &product_name, 153 install_static::GetExecutableVersionDetails(exe_file, &product_name,
164 &version_number, &special_build, 154 &version_number, &special_build,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 void SetupDesktopFieldTrials() { 190 void SetupDesktopFieldTrials() {
201 prerender::ConfigurePrerender(); 191 prerender::ConfigurePrerender();
202 SetupStunProbeTrial(); 192 SetupStunProbeTrial();
203 #if defined(OS_WIN) 193 #if defined(OS_WIN)
204 SetupStabilityDebugging(); 194 SetupStabilityDebugging();
205 base::FeatureList::IsEnabled(features::kModuleDatabase); 195 base::FeatureList::IsEnabled(features::kModuleDatabase);
206 #endif // defined(OS_WIN) 196 #endif // defined(OS_WIN)
207 } 197 }
208 198
209 } // namespace chrome 199 } // namespace chrome
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/metrics/chrome_metrics_service_client.cc » ('j') | components/browser_watcher/stability_paths.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698