OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/browser_child_process_host_impl.h" | 5 #include "content/browser/browser_child_process_host_impl.h" |
6 | 6 |
7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/dump_without_crashing.h" | 10 #include "base/debug/dump_without_crashing.h" |
| 11 #include "base/feature_list.h" |
11 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
12 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
13 #include "base/logging.h" | 14 #include "base/logging.h" |
14 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/metrics/field_trial.h" |
15 #include "base/metrics/histogram.h" | 17 #include "base/metrics/histogram.h" |
16 #include "base/stl_util.h" | 18 #include "base/stl_util.h" |
17 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
18 #include "base/synchronization/waitable_event.h" | 20 #include "base/synchronization/waitable_event.h" |
19 #include "build/build_config.h" | 21 #include "build/build_config.h" |
20 #include "components/tracing/tracing_switches.h" | 22 #include "components/tracing/tracing_switches.h" |
21 #include "content/browser/histogram_message_filter.h" | 23 #include "content/browser/histogram_message_filter.h" |
22 #include "content/browser/loader/resource_message_filter.h" | 24 #include "content/browser/loader/resource_message_filter.h" |
23 #include "content/browser/memory/memory_message_filter.h" | 25 #include "content/browser/memory/memory_message_filter.h" |
24 #include "content/browser/profiler_message_filter.h" | 26 #include "content/browser/profiler_message_filter.h" |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 171 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
170 // Make a copy since the BrowserChildProcessHost dtor mutates the original | 172 // Make a copy since the BrowserChildProcessHost dtor mutates the original |
171 // list. | 173 // list. |
172 BrowserChildProcessList copy = g_child_process_list.Get(); | 174 BrowserChildProcessList copy = g_child_process_list.Get(); |
173 for (BrowserChildProcessList::iterator it = copy.begin(); | 175 for (BrowserChildProcessList::iterator it = copy.begin(); |
174 it != copy.end(); ++it) { | 176 it != copy.end(); ++it) { |
175 delete (*it)->delegate(); // ~*HostDelegate deletes *HostImpl. | 177 delete (*it)->delegate(); // ~*HostDelegate deletes *HostImpl. |
176 } | 178 } |
177 } | 179 } |
178 | 180 |
| 181 // static |
| 182 void BrowserChildProcessHostImpl::CopyFeatureAndFieldTrialFlags( |
| 183 base::CommandLine* cmd_line) { |
| 184 std::string enabled_features; |
| 185 std::string disabled_features; |
| 186 base::FeatureList::GetInstance()->GetFeatureOverrides(&enabled_features, |
| 187 &disabled_features); |
| 188 if (!enabled_features.empty()) |
| 189 cmd_line->AppendSwitchASCII(switches::kEnableFeatures, enabled_features); |
| 190 if (!disabled_features.empty()) |
| 191 cmd_line->AppendSwitchASCII(switches::kDisableFeatures, disabled_features); |
| 192 |
| 193 // If we run base::FieldTrials, we want to pass to their state to the |
| 194 // child process so that it can act in accordance with each state. |
| 195 std::string field_trial_states; |
| 196 base::FieldTrialList::AllStatesToString(&field_trial_states); |
| 197 if (!field_trial_states.empty()) { |
| 198 cmd_line->AppendSwitchASCII(switches::kForceFieldTrials, |
| 199 field_trial_states); |
| 200 } |
| 201 } |
| 202 |
179 void BrowserChildProcessHostImpl::Launch( | 203 void BrowserChildProcessHostImpl::Launch( |
180 SandboxedProcessLauncherDelegate* delegate, | 204 SandboxedProcessLauncherDelegate* delegate, |
181 base::CommandLine* cmd_line, | 205 base::CommandLine* cmd_line, |
182 bool terminate_on_shutdown) { | 206 bool terminate_on_shutdown) { |
183 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 207 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
184 | 208 |
185 GetContentClient()->browser()->AppendExtraCommandLineSwitches( | 209 GetContentClient()->browser()->AppendExtraCommandLineSwitches( |
186 cmd_line, data_.id); | 210 cmd_line, data_.id); |
187 | 211 |
188 const base::CommandLine& browser_command_line = | 212 const base::CommandLine& browser_command_line = |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 | 459 |
436 #if defined(OS_WIN) | 460 #if defined(OS_WIN) |
437 | 461 |
438 void BrowserChildProcessHostImpl::OnObjectSignaled(HANDLE object) { | 462 void BrowserChildProcessHostImpl::OnObjectSignaled(HANDLE object) { |
439 OnChildDisconnected(); | 463 OnChildDisconnected(); |
440 } | 464 } |
441 | 465 |
442 #endif | 466 #endif |
443 | 467 |
444 } // namespace content | 468 } // namespace content |
OLD | NEW |