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

Side by Side Diff: content/browser/browser_child_process_host_impl.cc

Issue 2365273004: Initial implementation for sharing field trial state (win) (Closed)
Patch Set: rebase + gclient sync Created 4 years, 2 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 (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"
(...skipping 20 matching lines...) Expand all
31 #include "content/browser/service_manager/service_manager_context.h" 31 #include "content/browser/service_manager/service_manager_context.h"
32 #include "content/browser/tracing/trace_message_filter.h" 32 #include "content/browser/tracing/trace_message_filter.h"
33 #include "content/common/child_process_host_impl.h" 33 #include "content/common/child_process_host_impl.h"
34 #include "content/common/child_process_messages.h" 34 #include "content/common/child_process_messages.h"
35 #include "content/common/service_manager/child_connection.h" 35 #include "content/common/service_manager/child_connection.h"
36 #include "content/public/browser/browser_child_process_host_delegate.h" 36 #include "content/public/browser/browser_child_process_host_delegate.h"
37 #include "content/public/browser/browser_child_process_observer.h" 37 #include "content/public/browser/browser_child_process_observer.h"
38 #include "content/public/browser/browser_thread.h" 38 #include "content/public/browser/browser_thread.h"
39 #include "content/public/browser/child_process_data.h" 39 #include "content/public/browser/child_process_data.h"
40 #include "content/public/browser/content_browser_client.h" 40 #include "content/public/browser/content_browser_client.h"
41 #include "content/public/common/content_features.h"
41 #include "content/public/common/content_switches.h" 42 #include "content/public/common/content_switches.h"
42 #include "content/public/common/mojo_channel_switches.h" 43 #include "content/public/common/mojo_channel_switches.h"
43 #include "content/public/common/process_type.h" 44 #include "content/public/common/process_type.h"
44 #include "content/public/common/result_codes.h" 45 #include "content/public/common/result_codes.h"
45 #include "ipc/attachment_broker.h" 46 #include "ipc/attachment_broker.h"
46 #include "ipc/attachment_broker_privileged.h" 47 #include "ipc/attachment_broker_privileged.h"
47 #include "mojo/edk/embedder/embedder.h" 48 #include "mojo/edk/embedder/embedder.h"
48 49
49 #if defined(OS_MACOSX) 50 #if defined(OS_MACOSX)
50 #include "content/browser/mach_broker_mac.h" 51 #include "content/browser/mach_broker_mac.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 // Make a copy since the BrowserChildProcessHost dtor mutates the original 201 // Make a copy since the BrowserChildProcessHost dtor mutates the original
201 // list. 202 // list.
202 BrowserChildProcessList copy = g_child_process_list.Get(); 203 BrowserChildProcessList copy = g_child_process_list.Get();
203 for (BrowserChildProcessList::iterator it = copy.begin(); 204 for (BrowserChildProcessList::iterator it = copy.begin();
204 it != copy.end(); ++it) { 205 it != copy.end(); ++it) {
205 delete (*it)->delegate(); // ~*HostDelegate deletes *HostImpl. 206 delete (*it)->delegate(); // ~*HostDelegate deletes *HostImpl.
206 } 207 }
207 } 208 }
208 209
209 // static 210 // static
210 void BrowserChildProcessHostImpl::CopyFeatureAndFieldTrialFlags( 211 std::unique_ptr<base::SharedMemory>
212 BrowserChildProcessHostImpl::CopyFeatureAndFieldTrialFlags(
211 base::CommandLine* cmd_line) { 213 base::CommandLine* cmd_line) {
212 std::string enabled_features; 214 std::string enabled_features;
213 std::string disabled_features; 215 std::string disabled_features;
214 base::FeatureList::GetInstance()->GetFeatureOverrides(&enabled_features, 216 base::FeatureList::GetInstance()->GetFeatureOverrides(&enabled_features,
215 &disabled_features); 217 &disabled_features);
216 if (!enabled_features.empty()) 218 if (!enabled_features.empty())
217 cmd_line->AppendSwitchASCII(switches::kEnableFeatures, enabled_features); 219 cmd_line->AppendSwitchASCII(switches::kEnableFeatures, enabled_features);
218 if (!disabled_features.empty()) 220 if (!disabled_features.empty())
219 cmd_line->AppendSwitchASCII(switches::kDisableFeatures, disabled_features); 221 cmd_line->AppendSwitchASCII(switches::kDisableFeatures, disabled_features);
220 222
221 // If we run base::FieldTrials, we want to pass to their state to the 223 // If we run base::FieldTrials, we want to pass to their state to the
222 // child process so that it can act in accordance with each state. 224 // child process so that it can act in accordance with each state.
223 std::string field_trial_states; 225 return base::FieldTrialList::CopyFieldTrialStateToFlags(
224 base::FieldTrialList::AllStatesToString(&field_trial_states); 226 switches::kFieldTrialHandle, cmd_line);
225 if (!field_trial_states.empty()) {
226 cmd_line->AppendSwitchASCII(switches::kForceFieldTrials,
227 field_trial_states);
228 }
229 } 227 }
230 228
231 void BrowserChildProcessHostImpl::Launch( 229 void BrowserChildProcessHostImpl::Launch(
232 SandboxedProcessLauncherDelegate* delegate, 230 SandboxedProcessLauncherDelegate* delegate,
233 base::CommandLine* cmd_line, 231 base::CommandLine* cmd_line,
232 const base::SharedMemory* field_trial_state,
234 bool terminate_on_shutdown) { 233 bool terminate_on_shutdown) {
235 DCHECK_CURRENTLY_ON(BrowserThread::IO); 234 DCHECK_CURRENTLY_ON(BrowserThread::IO);
236 235
237 GetContentClient()->browser()->AppendExtraCommandLineSwitches( 236 GetContentClient()->browser()->AppendExtraCommandLineSwitches(
238 cmd_line, data_.id); 237 cmd_line, data_.id);
239 238
240 const base::CommandLine& browser_command_line = 239 const base::CommandLine& browser_command_line =
241 *base::CommandLine::ForCurrentProcess(); 240 *base::CommandLine::ForCurrentProcess();
242 static const char* const kForwardSwitches[] = { 241 static const char* const kForwardSwitches[] = {
243 switches::kDisableLogging, 242 switches::kDisableLogging,
244 switches::kEnableLogging, 243 switches::kEnableLogging,
245 switches::kIPCConnectionTimeout, 244 switches::kIPCConnectionTimeout,
246 switches::kLoggingLevel, 245 switches::kLoggingLevel,
247 switches::kTraceToConsole, 246 switches::kTraceToConsole,
248 switches::kV, 247 switches::kV,
249 switches::kVModule, 248 switches::kVModule,
250 }; 249 };
251 cmd_line->CopySwitchesFrom(browser_command_line, kForwardSwitches, 250 cmd_line->CopySwitchesFrom(browser_command_line, kForwardSwitches,
252 arraysize(kForwardSwitches)); 251 arraysize(kForwardSwitches));
253 252
254 if (child_connection_) { 253 if (child_connection_) {
255 cmd_line->AppendSwitchASCII(switches::kServiceRequestChannelToken, 254 cmd_line->AppendSwitchASCII(switches::kServiceRequestChannelToken,
256 child_connection_->service_token()); 255 child_connection_->service_token());
257 } 256 }
258 257
259 notify_child_disconnected_ = true; 258 notify_child_disconnected_ = true;
260 child_process_.reset(new ChildProcessLauncher( 259 child_process_.reset(new ChildProcessLauncher(
261 delegate, 260 delegate, cmd_line, data_.id, this, field_trial_state, child_token_,
262 cmd_line,
263 data_.id,
264 this,
265 child_token_,
266 base::Bind(&BrowserChildProcessHostImpl::OnMojoError, 261 base::Bind(&BrowserChildProcessHostImpl::OnMojoError,
267 weak_factory_.GetWeakPtr(), 262 weak_factory_.GetWeakPtr(),
268 base::ThreadTaskRunnerHandle::Get()), 263 base::ThreadTaskRunnerHandle::Get()),
269 terminate_on_shutdown)); 264 terminate_on_shutdown));
270 } 265 }
271 266
272 const ChildProcessData& BrowserChildProcessHostImpl::GetData() const { 267 const ChildProcessData& BrowserChildProcessHostImpl::GetData() const {
273 DCHECK_CURRENTLY_ON(BrowserThread::IO); 268 DCHECK_CURRENTLY_ON(BrowserThread::IO);
274 return data_; 269 return data_;
275 } 270 }
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 597
603 #if defined(OS_WIN) 598 #if defined(OS_WIN)
604 599
605 void BrowserChildProcessHostImpl::OnObjectSignaled(HANDLE object) { 600 void BrowserChildProcessHostImpl::OnObjectSignaled(HANDLE object) {
606 OnChildDisconnected(); 601 OnChildDisconnected();
607 } 602 }
608 603
609 #endif 604 #endif
610 605
611 } // namespace content 606 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_child_process_host_impl.h ('k') | content/browser/child_process_launcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698