OLD | NEW |
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/metrics/persistent_system_profile.h" | 27 #include "components/metrics/persistent_system_profile.h" |
30 #include "components/variations/variations_associated_data.h" | 28 #include "components/variations/variations_associated_data.h" |
31 #include "content/public/common/content_switches.h" | 29 #include "content/public/common/content_switches.h" |
32 #include "media/media_features.h" | 30 #include "media/media_features.h" |
33 | 31 |
34 #if defined(OS_WIN) | 32 #if defined(OS_WIN) |
35 #include "base/win/pe_image.h" | 33 #include "base/win/pe_image.h" |
36 #include "chrome/install_static/install_util.h" | 34 #include "chrome/install_static/install_util.h" |
| 35 #include "components/browser_watcher/features.h" |
37 #include "components/browser_watcher/stability_data_names.h" | 36 #include "components/browser_watcher/stability_data_names.h" |
| 37 #include "components/browser_watcher/stability_metrics.h" |
| 38 #include "components/browser_watcher/stability_paths.h" |
38 #endif | 39 #endif |
39 | 40 |
40 #if defined(OS_WIN) | 41 #if defined(OS_WIN) |
41 // http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx | 42 // http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx |
42 extern "C" IMAGE_DOS_HEADER __ImageBase; | 43 extern "C" IMAGE_DOS_HEADER __ImageBase; |
43 #endif | 44 #endif |
44 | 45 |
45 namespace chrome { | 46 namespace chrome { |
46 | 47 |
47 namespace { | 48 namespace { |
(...skipping 13 matching lines...) Expand all Loading... |
61 "/" + params["server1"] + "/" + params["server2"] + | 62 "/" + params["server1"] + "/" + params["server2"] + |
62 "/" + params["server3"] + "/" + params["server4"] + | 63 "/" + params["server3"] + "/" + params["server4"] + |
63 "/" + params["server5"] + "/" + params["server6"]; | 64 "/" + params["server5"] + "/" + params["server6"]; |
64 | 65 |
65 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 66 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
66 switches::kWebRtcStunProbeTrialParameter, cmd_param); | 67 switches::kWebRtcStunProbeTrialParameter, cmd_param); |
67 #endif | 68 #endif |
68 } | 69 } |
69 | 70 |
70 #if defined(OS_WIN) | 71 #if defined(OS_WIN) |
71 // DO NOT CHANGE VALUES. This is logged persistently in a histogram. | |
72 enum StabilityDebuggingInitializationStatus { | |
73 INIT_SUCCESS = 0, | |
74 CREATE_STABILITY_DIR_FAILED = 1, | |
75 GET_STABILITY_FILE_PATH_FAILED = 2, | |
76 INIT_STATUS_MAX = 3 | |
77 }; | |
78 | |
79 void LogStabilityDebuggingInitStatus( | |
80 StabilityDebuggingInitializationStatus status) { | |
81 UMA_HISTOGRAM_ENUMERATION("ActivityTracker.Record.InitStatus", status, | |
82 INIT_STATUS_MAX); | |
83 } | |
84 | 72 |
85 // Record information about the chrome module. | 73 // Record information about the chrome module. |
86 void RecordChromeModuleInfo( | 74 void RecordChromeModuleInfo( |
87 base::debug::GlobalActivityTracker* global_tracker) { | 75 base::debug::GlobalActivityTracker* global_tracker) { |
88 DCHECK(global_tracker); | 76 DCHECK(global_tracker); |
89 | 77 |
90 base::debug::GlobalActivityTracker::ModuleInfo module; | 78 base::debug::GlobalActivityTracker::ModuleInfo module; |
91 module.is_loaded = true; | 79 module.is_loaded = true; |
92 module.address = reinterpret_cast<uintptr_t>(&__ImageBase); | 80 module.address = reinterpret_cast<uintptr_t>(&__ImageBase); |
93 | 81 |
(...skipping 29 matching lines...) Expand all Loading... |
123 // just how much of an arena is necessary. | 111 // just how much of an arena is necessary. |
124 const size_t kMemorySize = 1 << 20; // 1 MiB | 112 const size_t kMemorySize = 1 << 20; // 1 MiB |
125 const int kStackDepth = 4; | 113 const int kStackDepth = 4; |
126 const uint64_t kAllocatorId = 0; | 114 const uint64_t kAllocatorId = 0; |
127 | 115 |
128 // Ensure the stability directory exists and determine the stability file's | 116 // Ensure the stability directory exists and determine the stability file's |
129 // path. | 117 // path. |
130 base::FilePath user_data_dir; | 118 base::FilePath user_data_dir; |
131 if (!base::PathService::Get(chrome::DIR_USER_DATA, &user_data_dir) || | 119 if (!base::PathService::Get(chrome::DIR_USER_DATA, &user_data_dir) || |
132 !base::CreateDirectory(browser_watcher::GetStabilityDir(user_data_dir))) { | 120 !base::CreateDirectory(browser_watcher::GetStabilityDir(user_data_dir))) { |
133 LOG(ERROR) << "Failed to create the stability directory."; | |
134 LogStabilityDebuggingInitStatus(CREATE_STABILITY_DIR_FAILED); | |
135 return; | 121 return; |
136 } | 122 } |
| 123 browser_watcher::LogStabilityRecordEvent( |
| 124 browser_watcher::StabilityRecordEvent::kStabilityDirectoryExists); |
| 125 |
137 base::FilePath stability_file; | 126 base::FilePath stability_file; |
138 if (!browser_watcher::GetStabilityFileForProcess( | 127 if (!browser_watcher::GetStabilityFileForProcess( |
139 base::Process::Current(), user_data_dir, &stability_file)) { | 128 base::Process::Current(), user_data_dir, &stability_file)) { |
140 LOG(ERROR) << "Failed to obtain stability file's path."; | |
141 LogStabilityDebuggingInitStatus(GET_STABILITY_FILE_PATH_FAILED); | |
142 return; | 129 return; |
143 } | 130 } |
144 LogStabilityDebuggingInitStatus(INIT_SUCCESS); | 131 browser_watcher::LogStabilityRecordEvent( |
| 132 browser_watcher::StabilityRecordEvent::kGotStabilityPath); |
145 | 133 |
146 // Track code activities (such as posting task, blocking on locks, and | 134 // Track code activities (such as posting task, blocking on locks, and |
147 // joining threads) that can cause hanging threads and general instability | 135 // joining threads) that can cause hanging threads and general instability |
148 base::debug::GlobalActivityTracker::CreateWithFile( | 136 base::debug::GlobalActivityTracker::CreateWithFile( |
149 stability_file, kMemorySize, kAllocatorId, | 137 stability_file, kMemorySize, kAllocatorId, |
150 browser_watcher::kStabilityDebuggingFeature.name, kStackDepth); | 138 browser_watcher::kStabilityDebuggingFeature.name, kStackDepth); |
151 | 139 |
152 // Record basic information. | 140 // Record basic information. |
153 base::debug::GlobalActivityTracker* global_tracker = | 141 base::debug::GlobalActivityTracker* global_tracker = |
154 base::debug::GlobalActivityTracker::Get(); | 142 base::debug::GlobalActivityTracker::Get(); |
155 if (global_tracker) { | 143 if (global_tracker) { |
| 144 browser_watcher::LogStabilityRecordEvent( |
| 145 browser_watcher::StabilityRecordEvent::kGotTracker); |
156 // Record product, version, channel, special build and platform. | 146 // Record product, version, channel, special build and platform. |
157 wchar_t exe_file[MAX_PATH] = {}; | 147 wchar_t exe_file[MAX_PATH] = {}; |
158 CHECK(::GetModuleFileName(nullptr, exe_file, arraysize(exe_file))); | 148 CHECK(::GetModuleFileName(nullptr, exe_file, arraysize(exe_file))); |
159 | 149 |
160 base::string16 product_name; | 150 base::string16 product_name; |
161 base::string16 version_number; | 151 base::string16 version_number; |
162 base::string16 channel_name; | 152 base::string16 channel_name; |
163 base::string16 special_build; | 153 base::string16 special_build; |
164 install_static::GetExecutableVersionDetails(exe_file, &product_name, | 154 install_static::GetExecutableVersionDetails(exe_file, &product_name, |
165 &version_number, &special_build, | 155 &version_number, &special_build, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 void SetupDesktopFieldTrials() { | 197 void SetupDesktopFieldTrials() { |
208 prerender::ConfigurePrerender(); | 198 prerender::ConfigurePrerender(); |
209 SetupStunProbeTrial(); | 199 SetupStunProbeTrial(); |
210 #if defined(OS_WIN) | 200 #if defined(OS_WIN) |
211 SetupStabilityDebugging(); | 201 SetupStabilityDebugging(); |
212 base::FeatureList::IsEnabled(features::kModuleDatabase); | 202 base::FeatureList::IsEnabled(features::kModuleDatabase); |
213 #endif // defined(OS_WIN) | 203 #endif // defined(OS_WIN) |
214 } | 204 } |
215 | 205 |
216 } // namespace chrome | 206 } // namespace chrome |
OLD | NEW |