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" |
13 #include "base/path_service.h" | 15 #include "base/path_service.h" |
14 #include "chrome/browser/prerender/prerender_field_trial.h" | 16 #include "chrome/browser/prerender/prerender_field_trial.h" |
15 #include "chrome/common/chrome_paths.h" | 17 #include "chrome/common/chrome_paths.h" |
16 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
17 #include "chrome/common/variations/variations_util.h" | 19 #include "chrome/common/variations/variations_util.h" |
20 #include "components/browser_watcher/features.h" | |
18 #include "components/variations/variations_associated_data.h" | 21 #include "components/variations/variations_associated_data.h" |
19 #include "content/public/common/content_switches.h" | 22 #include "content/public/common/content_switches.h" |
20 | 23 |
24 #if defined(OS_WIN) | |
25 #include "components/browser_watcher/stability_debugging_win.h" | |
26 #endif | |
27 | |
21 namespace chrome { | 28 namespace chrome { |
22 | 29 |
23 namespace { | 30 namespace { |
24 | 31 |
25 const base::Feature kStabilityDebuggingFeature{ | 32 using browser_watcher::StabilityDebugging; |
26 "StabilityDebugging", base::FEATURE_DISABLED_BY_DEFAULT | |
27 }; | |
28 | 33 |
29 void SetupStunProbeTrial() { | 34 void SetupStunProbeTrial() { |
30 #if defined(ENABLE_WEBRTC) | 35 #if defined(ENABLE_WEBRTC) |
31 std::map<std::string, std::string> params; | 36 std::map<std::string, std::string> params; |
32 if (!variations::GetVariationParams("StunProbeTrial2", ¶ms)) | 37 if (!variations::GetVariationParams("StunProbeTrial2", ¶ms)) |
33 return; | 38 return; |
34 | 39 |
35 // The parameter, used by StartStunFieldTrial, should have the following | 40 // The parameter, used by StartStunFieldTrial, should have the following |
36 // format: "request_per_ip/interval/sharedsocket/batch_size/total_batches/ | 41 // format: "request_per_ip/interval/sharedsocket/batch_size/total_batches/ |
37 // server1:port/server2:port/server3:port/" | 42 // server1:port/server2:port/server3:port/" |
38 std::string cmd_param = params["request_per_ip"] + "/" + params["interval"] + | 43 std::string cmd_param = params["request_per_ip"] + "/" + params["interval"] + |
39 "/" + params["sharedsocket"] + "/" + | 44 "/" + params["sharedsocket"] + "/" + |
40 params["batch_size"] + "/" + params["total_batches"] + | 45 params["batch_size"] + "/" + params["total_batches"] + |
41 "/" + params["server1"] + "/" + params["server2"] + | 46 "/" + params["server1"] + "/" + params["server2"] + |
42 "/" + params["server3"] + "/" + params["server4"] + | 47 "/" + params["server3"] + "/" + params["server4"] + |
43 "/" + params["server5"] + "/" + params["server6"]; | 48 "/" + params["server5"] + "/" + params["server6"]; |
44 | 49 |
45 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 50 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
46 switches::kWebRtcStunProbeTrialParameter, cmd_param); | 51 switches::kWebRtcStunProbeTrialParameter, cmd_param); |
47 #endif | 52 #endif |
48 } | 53 } |
49 | 54 |
55 #if defined(OS_WIN) | |
50 void SetupStabilityDebugging() { | 56 void SetupStabilityDebugging() { |
51 if (!base::FeatureList::IsEnabled(kStabilityDebuggingFeature)) | 57 if (!base::FeatureList::IsEnabled( |
58 browser_watcher::kStabilityDebuggingFeature)) | |
52 return; | 59 return; |
53 | 60 |
54 // TODO(bcwhite): Adjust these numbers once there is real data to show | 61 // TODO(bcwhite): Adjust these numbers once there is real data to show |
55 // just how much of an arena is necessary. | 62 // just how much of an arena is necessary. |
56 const size_t kMemorySize = 1 << 20; // 1 MiB | 63 const size_t kMemorySize = 1 << 20; // 1 MiB |
57 const int kStackDepth = 4; | 64 const int kStackDepth = 4; |
58 const uint64_t kAllocatorId = 0; | 65 const uint64_t kAllocatorId = 0; |
59 | 66 |
67 // Ensure the stability directory exists and determine the stability file's | |
68 // path. | |
69 base::FilePath user_data_dir; | |
70 if (!base::PathService::Get(chrome::DIR_USER_DATA, &user_data_dir) || | |
71 !base::CreateDirectory(StabilityDebugging::GetDir(user_data_dir))) { | |
72 LOG(ERROR) << "Failed to create the stability directory."; | |
Sigurður Ásgeirsson
2016/09/19 14:20:05
in the forest, nobody hears your LOGs.
If you bel
manzagop (departed)
2016/09/21 22:00:43
Done.
| |
73 return; | |
74 } | |
75 base::FilePath stability_file; | |
76 if (!StabilityDebugging::GetFileForProcess(base::Process::Current(), | |
77 user_data_dir, &stability_file)) { | |
78 LOG(ERROR) << "Failed to obtain stability file's path."; | |
79 return; | |
80 } | |
81 | |
60 // Track code activities (such as posting task, blocking on locks, and | 82 // Track code activities (such as posting task, blocking on locks, and |
61 // joining threads) that can cause hanging threads and general instability. | 83 // 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( | 84 base::debug::GlobalActivityTracker::CreateWithFile( |
66 user_data_dir | 85 stability_file, kMemorySize, kAllocatorId, |
67 .AppendASCII("StabilityDebugInfo") | 86 browser_watcher::kStabilityDebuggingFeature.name, kStackDepth); |
68 .AddExtension(base::PersistentMemoryAllocator::kFileExtension), | |
69 kMemorySize, kAllocatorId, kStabilityDebuggingFeature.name, kStackDepth); | |
70 } | 87 } |
88 #endif | |
71 | 89 |
72 } // namespace | 90 } // namespace |
73 | 91 |
74 void SetupDesktopFieldTrials(const base::CommandLine& parsed_command_line) { | 92 void SetupDesktopFieldTrials(const base::CommandLine& parsed_command_line) { |
75 prerender::ConfigurePrerender(parsed_command_line); | 93 prerender::ConfigurePrerender(parsed_command_line); |
76 SetupStunProbeTrial(); | 94 SetupStunProbeTrial(); |
95 #if defined(OS_WIN) | |
77 SetupStabilityDebugging(); | 96 SetupStabilityDebugging(); |
97 #endif | |
78 } | 98 } |
79 | 99 |
80 } // namespace chrome | 100 } // namespace chrome |
OLD | NEW |