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

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

Issue 2412113002: Use SharedPersistentMemoryAllocator to share field trial state (Closed)
Patch Set: gclient sync Created 4 years, 1 month 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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 // Make a copy since the BrowserChildProcessHost dtor mutates the original 201 // Make a copy since the BrowserChildProcessHost dtor mutates the original
202 // list. 202 // list.
203 BrowserChildProcessList copy = g_child_process_list.Get(); 203 BrowserChildProcessList copy = g_child_process_list.Get();
204 for (BrowserChildProcessList::iterator it = copy.begin(); 204 for (BrowserChildProcessList::iterator it = copy.begin();
205 it != copy.end(); ++it) { 205 it != copy.end(); ++it) {
206 delete (*it)->delegate(); // ~*HostDelegate deletes *HostImpl. 206 delete (*it)->delegate(); // ~*HostDelegate deletes *HostImpl.
207 } 207 }
208 } 208 }
209 209
210 // static 210 // static
211 std::unique_ptr<base::SharedMemory> 211 void BrowserChildProcessHostImpl::CopyFeatureAndFieldTrialFlags(
212 BrowserChildProcessHostImpl::CopyFeatureAndFieldTrialFlags(
213 base::CommandLine* cmd_line) { 212 base::CommandLine* cmd_line) {
214 std::string enabled_features; 213 std::string enabled_features;
215 std::string disabled_features; 214 std::string disabled_features;
216 base::FeatureList::GetInstance()->GetFeatureOverrides(&enabled_features, 215 base::FeatureList::GetInstance()->GetFeatureOverrides(&enabled_features,
217 &disabled_features); 216 &disabled_features);
218 if (!enabled_features.empty()) 217 if (!enabled_features.empty())
219 cmd_line->AppendSwitchASCII(switches::kEnableFeatures, enabled_features); 218 cmd_line->AppendSwitchASCII(switches::kEnableFeatures, enabled_features);
220 if (!disabled_features.empty()) 219 if (!disabled_features.empty())
221 cmd_line->AppendSwitchASCII(switches::kDisableFeatures, disabled_features); 220 cmd_line->AppendSwitchASCII(switches::kDisableFeatures, disabled_features);
222 221
223 // If we run base::FieldTrials, we want to pass to their state to the 222 // If we run base::FieldTrials, we want to pass to their state to the
224 // child process so that it can act in accordance with each state. 223 // child process so that it can act in accordance with each state.
225 return base::FieldTrialList::CopyFieldTrialStateToFlags( 224 base::FieldTrialList::CopyFieldTrialStateToFlags(switches::kFieldTrialHandle,
226 switches::kFieldTrialHandle, cmd_line); 225 cmd_line);
227 } 226 }
228 227
229 void BrowserChildProcessHostImpl::Launch( 228 void BrowserChildProcessHostImpl::Launch(
230 SandboxedProcessLauncherDelegate* delegate, 229 SandboxedProcessLauncherDelegate* delegate,
231 base::CommandLine* cmd_line, 230 base::CommandLine* cmd_line,
232 const base::SharedMemory* field_trial_state,
233 bool terminate_on_shutdown) { 231 bool terminate_on_shutdown) {
234 DCHECK_CURRENTLY_ON(BrowserThread::IO); 232 DCHECK_CURRENTLY_ON(BrowserThread::IO);
235 233
236 GetContentClient()->browser()->AppendExtraCommandLineSwitches( 234 GetContentClient()->browser()->AppendExtraCommandLineSwitches(
237 cmd_line, data_.id); 235 cmd_line, data_.id);
238 236
239 const base::CommandLine& browser_command_line = 237 const base::CommandLine& browser_command_line =
240 *base::CommandLine::ForCurrentProcess(); 238 *base::CommandLine::ForCurrentProcess();
241 static const char* const kForwardSwitches[] = { 239 static const char* const kForwardSwitches[] = {
242 switches::kDisableLogging, 240 switches::kDisableLogging,
243 switches::kEnableLogging, 241 switches::kEnableLogging,
244 switches::kIPCConnectionTimeout, 242 switches::kIPCConnectionTimeout,
245 switches::kLoggingLevel, 243 switches::kLoggingLevel,
246 switches::kTraceToConsole, 244 switches::kTraceToConsole,
247 switches::kV, 245 switches::kV,
248 switches::kVModule, 246 switches::kVModule,
249 }; 247 };
250 cmd_line->CopySwitchesFrom(browser_command_line, kForwardSwitches, 248 cmd_line->CopySwitchesFrom(browser_command_line, kForwardSwitches,
251 arraysize(kForwardSwitches)); 249 arraysize(kForwardSwitches));
252 250
253 if (child_connection_) { 251 if (child_connection_) {
254 cmd_line->AppendSwitchASCII(switches::kServiceRequestChannelToken, 252 cmd_line->AppendSwitchASCII(switches::kServiceRequestChannelToken,
255 child_connection_->service_token()); 253 child_connection_->service_token());
256 } 254 }
257 255
258 notify_child_disconnected_ = true; 256 notify_child_disconnected_ = true;
259 child_process_.reset(new ChildProcessLauncher( 257 child_process_.reset(new ChildProcessLauncher(
260 delegate, cmd_line, data_.id, this, field_trial_state, child_token_, 258 delegate, cmd_line, data_.id, this, child_token_,
261 base::Bind(&BrowserChildProcessHostImpl::OnMojoError, 259 base::Bind(&BrowserChildProcessHostImpl::OnMojoError,
262 weak_factory_.GetWeakPtr(), 260 weak_factory_.GetWeakPtr(),
263 base::ThreadTaskRunnerHandle::Get()), 261 base::ThreadTaskRunnerHandle::Get()),
264 terminate_on_shutdown)); 262 terminate_on_shutdown));
265 } 263 }
266 264
267 const ChildProcessData& BrowserChildProcessHostImpl::GetData() const { 265 const ChildProcessData& BrowserChildProcessHostImpl::GetData() const {
268 DCHECK_CURRENTLY_ON(BrowserThread::IO); 266 DCHECK_CURRENTLY_ON(BrowserThread::IO);
269 return data_; 267 return data_;
270 } 268 }
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 596
599 #if defined(OS_WIN) 597 #if defined(OS_WIN)
600 598
601 void BrowserChildProcessHostImpl::OnObjectSignaled(HANDLE object) { 599 void BrowserChildProcessHostImpl::OnObjectSignaled(HANDLE object) {
602 OnChildDisconnected(); 600 OnChildDisconnected();
603 } 601 }
604 602
605 #endif 603 #endif
606 604
607 } // namespace content 605 } // 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