Chromium Code Reviews| 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 #include <map> | |
| 7 #include <string> | 8 #include <string> |
| 8 | 9 |
| 9 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 10 #include "base/debug/activity_tracker.h" | 11 #include "base/debug/activity_tracker.h" |
| 11 #include "base/feature_list.h" | 12 #include "base/feature_list.h" |
| 13 #include "base/files/file_util.h" | |
| 12 #include "base/metrics/field_trial.h" | 14 #include "base/metrics/field_trial.h" |
| 15 #include "base/metrics/histogram_macros.h" | |
| 13 #include "base/path_service.h" | 16 #include "base/path_service.h" |
| 14 #include "chrome/browser/prerender/prerender_field_trial.h" | 17 #include "chrome/browser/prerender/prerender_field_trial.h" |
| 15 #include "chrome/common/chrome_paths.h" | 18 #include "chrome/common/chrome_paths.h" |
| 16 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
| 17 #include "chrome/common/variations/variations_util.h" | 20 #include "chrome/common/variations/variations_util.h" |
| 21 #include "components/browser_watcher/features.h" | |
| 18 #include "components/variations/variations_associated_data.h" | 22 #include "components/variations/variations_associated_data.h" |
| 19 #include "content/public/common/content_switches.h" | 23 #include "content/public/common/content_switches.h" |
| 20 | 24 |
| 25 #if defined(OS_WIN) | |
| 26 #include "components/browser_watcher/stability_debugging_win.h" | |
| 27 #endif | |
| 28 | |
| 21 namespace chrome { | 29 namespace chrome { |
| 22 | 30 |
| 23 namespace { | 31 namespace { |
| 24 | 32 |
| 25 const base::Feature kStabilityDebuggingFeature{ | 33 using browser_watcher::StabilityDebugging; |
| 26 "StabilityDebugging", base::FEATURE_DISABLED_BY_DEFAULT | |
| 27 }; | |
| 28 | 34 |
| 29 void SetupStunProbeTrial() { | 35 void SetupStunProbeTrial() { |
| 30 #if defined(ENABLE_WEBRTC) | 36 #if defined(ENABLE_WEBRTC) |
| 31 std::map<std::string, std::string> params; | 37 std::map<std::string, std::string> params; |
| 32 if (!variations::GetVariationParams("StunProbeTrial2", ¶ms)) | 38 if (!variations::GetVariationParams("StunProbeTrial2", ¶ms)) |
| 33 return; | 39 return; |
| 34 | 40 |
| 35 // The parameter, used by StartStunFieldTrial, should have the following | 41 // The parameter, used by StartStunFieldTrial, should have the following |
| 36 // format: "request_per_ip/interval/sharedsocket/batch_size/total_batches/ | 42 // format: "request_per_ip/interval/sharedsocket/batch_size/total_batches/ |
| 37 // server1:port/server2:port/server3:port/" | 43 // server1:port/server2:port/server3:port/" |
| 38 std::string cmd_param = params["request_per_ip"] + "/" + params["interval"] + | 44 std::string cmd_param = params["request_per_ip"] + "/" + params["interval"] + |
| 39 "/" + params["sharedsocket"] + "/" + | 45 "/" + params["sharedsocket"] + "/" + |
| 40 params["batch_size"] + "/" + params["total_batches"] + | 46 params["batch_size"] + "/" + params["total_batches"] + |
| 41 "/" + params["server1"] + "/" + params["server2"] + | 47 "/" + params["server1"] + "/" + params["server2"] + |
| 42 "/" + params["server3"] + "/" + params["server4"] + | 48 "/" + params["server3"] + "/" + params["server4"] + |
| 43 "/" + params["server5"] + "/" + params["server6"]; | 49 "/" + params["server5"] + "/" + params["server6"]; |
| 44 | 50 |
| 45 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 51 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 46 switches::kWebRtcStunProbeTrialParameter, cmd_param); | 52 switches::kWebRtcStunProbeTrialParameter, cmd_param); |
| 47 #endif | 53 #endif |
| 48 } | 54 } |
| 49 | 55 |
| 56 #if defined(OS_WIN) | |
| 57 // DO NOT CHANGE VALUES. This is logged persistently in a histogram. | |
| 58 enum StabilityDebuggingInitializationStatus { | |
| 59 INIT_SUCCESS = 0, | |
| 60 CREATE_STABILITY_DIR_FAILED = 1, | |
| 61 GET_STABILITY_FILE_PATH_FAILED = 2, | |
| 62 INIT_STATUS_MAX = 3 | |
| 63 }; | |
| 64 | |
| 65 void LogStabilityDebuggingInitStatusWithoutStaticVar( | |
| 66 StabilityDebuggingInitializationStatus status) { | |
| 67 base::HistogramBase* init_status_hist = base::LinearHistogram::FactoryGet( | |
|
Sigurður Ásgeirsson
2016/09/22 15:46:14
Ah - I see.
Since this'll at least instantiate onl
Alexei Svitkine (slow)
2016/09/23 14:13:53
Yeah, I'd suggest using the macro. Not using the m
manzagop (departed)
2016/09/23 21:57:01
Done.
manzagop (departed)
2016/09/23 21:57:01
Done.
Sigurður Ásgeirsson
2016/09/26 15:22:25
Each of those macro incantations instantiates a fa
Alexei Svitkine (slow)
2016/09/26 15:29:49
Agreed.
We've previously done some exploration an
| |
| 68 "ActivityTracker.Record.InitStatus", 1, INIT_STATUS_MAX, | |
| 69 INIT_STATUS_MAX + 1, base::HistogramBase::kUmaTargetedHistogramFlag); | |
| 70 init_status_hist->Add(status); | |
| 71 } | |
| 72 | |
| 50 void SetupStabilityDebugging() { | 73 void SetupStabilityDebugging() { |
| 51 if (!base::FeatureList::IsEnabled(kStabilityDebuggingFeature)) | 74 if (!base::FeatureList::IsEnabled( |
| 75 browser_watcher::kStabilityDebuggingFeature)) | |
|
Alexei Svitkine (slow)
2016/09/23 14:13:53
Nit: {} now that if is multi-line
manzagop (departed)
2016/09/23 21:57:01
Done.
| |
| 52 return; | 76 return; |
| 53 | 77 |
| 54 // TODO(bcwhite): Adjust these numbers once there is real data to show | 78 // TODO(bcwhite): Adjust these numbers once there is real data to show |
| 55 // just how much of an arena is necessary. | 79 // just how much of an arena is necessary. |
| 56 const size_t kMemorySize = 1 << 20; // 1 MiB | 80 const size_t kMemorySize = 1 << 20; // 1 MiB |
| 57 const int kStackDepth = 4; | 81 const int kStackDepth = 4; |
| 58 const uint64_t kAllocatorId = 0; | 82 const uint64_t kAllocatorId = 0; |
| 59 | 83 |
| 84 // Ensure the stability directory exists and determine the stability file's | |
| 85 // path. | |
| 86 base::FilePath user_data_dir; | |
| 87 if (!base::PathService::Get(chrome::DIR_USER_DATA, &user_data_dir) || | |
| 88 !base::CreateDirectory(StabilityDebugging::GetDir(user_data_dir))) { | |
| 89 LOG(ERROR) << "Failed to create the stability directory."; | |
| 90 LogStabilityDebuggingInitStatusWithoutStaticVar( | |
| 91 CREATE_STABILITY_DIR_FAILED); | |
| 92 return; | |
| 93 } | |
| 94 base::FilePath stability_file; | |
| 95 if (!StabilityDebugging::GetFileForProcess(base::Process::Current(), | |
| 96 user_data_dir, &stability_file)) { | |
| 97 LOG(ERROR) << "Failed to obtain stability file's path."; | |
| 98 LogStabilityDebuggingInitStatusWithoutStaticVar( | |
| 99 GET_STABILITY_FILE_PATH_FAILED); | |
| 100 return; | |
| 101 } | |
| 102 LogStabilityDebuggingInitStatusWithoutStaticVar(INIT_SUCCESS); | |
| 103 | |
| 60 // Track code activities (such as posting task, blocking on locks, and | 104 // Track code activities (such as posting task, blocking on locks, and |
| 61 // joining threads) that can cause hanging threads and general instability. | 105 // joining threads) that can cause hanging threads and general instability |
| 62 base::FilePath user_data_dir; | |
| 63 bool success = base::PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); | |
| 64 DCHECK(success); | |
| 65 base::debug::GlobalActivityTracker::CreateWithFile( | 106 base::debug::GlobalActivityTracker::CreateWithFile( |
| 66 user_data_dir | 107 stability_file, kMemorySize, kAllocatorId, |
| 67 .AppendASCII("StabilityDebugInfo") | 108 browser_watcher::kStabilityDebuggingFeature.name, kStackDepth); |
| 68 .AddExtension(base::PersistentMemoryAllocator::kFileExtension), | |
| 69 kMemorySize, kAllocatorId, kStabilityDebuggingFeature.name, kStackDepth); | |
| 70 } | 109 } |
| 110 #endif | |
|
Alexei Svitkine (slow)
2016/09/23 14:13:53
// defined(OS_WIN)
manzagop (departed)
2016/09/23 21:57:01
Done.
| |
| 71 | 111 |
| 72 } // namespace | 112 } // namespace |
| 73 | 113 |
| 74 void SetupDesktopFieldTrials(const base::CommandLine& parsed_command_line) { | 114 void SetupDesktopFieldTrials(const base::CommandLine& parsed_command_line) { |
| 75 prerender::ConfigurePrerender(parsed_command_line); | 115 prerender::ConfigurePrerender(parsed_command_line); |
| 76 SetupStunProbeTrial(); | 116 SetupStunProbeTrial(); |
| 117 #if defined(OS_WIN) | |
| 77 SetupStabilityDebugging(); | 118 SetupStabilityDebugging(); |
| 119 #endif | |
| 78 } | 120 } |
| 79 | 121 |
| 80 } // namespace chrome | 122 } // namespace chrome |
| OLD | NEW |