Chromium Code Reviews| 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/public/app/content_main_runner.h" | 5 #include "content/public/app/content_main_runner.h" |
| 6 | 6 |
| 7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/debug/debugger.h" | 9 #include "base/debug/debugger.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 216 | 216 |
| 217 if (delegate) delegate->ZygoteForked(); | 217 if (delegate) delegate->ZygoteForked(); |
| 218 | 218 |
| 219 // Zygote::HandleForkRequest may have reallocated the command | 219 // Zygote::HandleForkRequest may have reallocated the command |
| 220 // line so update it here with the new version. | 220 // line so update it here with the new version. |
| 221 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 221 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 222 | 222 |
| 223 // If a custom user agent was passed on the command line, we need | 223 // If a custom user agent was passed on the command line, we need |
| 224 // to (re)set it now, rather than using the default one the zygote | 224 // to (re)set it now, rather than using the default one the zygote |
| 225 // initialized. | 225 // initialized. |
| 226 bool custom = false; | 226 if (command_line.HasSwitch(switches::kUserAgent)) { |
| 227 std::string ua = content::GetContentClient()->GetUserAgent(&custom); | 227 webkit_glue::SetUserAgent( |
| 228 if (custom) webkit_glue::SetUserAgent(ua, custom); | 228 command_line.GetSwitchValueASCII(switches::kUserAgent), true); |
| 229 } | |
| 229 | 230 |
| 230 // The StatsTable must be initialized in each process; we already | 231 // The StatsTable must be initialized in each process; we already |
| 231 // initialized for the browser process, now we need to initialize | 232 // initialized for the browser process, now we need to initialize |
| 232 // within the new processes as well. | 233 // within the new processes as well. |
| 233 pid_t browser_pid = base::GetParentProcessId( | 234 pid_t browser_pid = base::GetParentProcessId( |
| 234 base::GetParentProcessId(base::GetCurrentProcId())); | 235 base::GetParentProcessId(base::GetCurrentProcId())); |
| 235 InitializeStatsTable(browser_pid, command_line); | 236 InitializeStatsTable(browser_pid, command_line); |
| 236 | 237 |
| 237 content::MainFunctionParams main_params(command_line); | 238 content::MainFunctionParams main_params(command_line); |
| 238 | 239 |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 460 // On linux, we're in the zygote here; so we need the parent process' id. | 461 // On linux, we're in the zygote here; so we need the parent process' id. |
| 461 browser_pid = base::GetParentProcessId(base::GetCurrentProcId()); | 462 browser_pid = base::GetParentProcessId(base::GetCurrentProcId()); |
| 462 #endif | 463 #endif |
| 463 } | 464 } |
| 464 | 465 |
| 465 InitializeStatsTable(browser_pid, command_line); | 466 InitializeStatsTable(browser_pid, command_line); |
| 466 | 467 |
| 467 if (delegate) | 468 if (delegate) |
| 468 delegate->PreSandboxStartup(); | 469 delegate->PreSandboxStartup(); |
| 469 | 470 |
| 471 // Set any custom user agent passed on the command line now so the string | |
| 472 // doesn't change between calls to webkit_glue::GetUserAgent(), otherwise it | |
| 473 // defaults to the user agent set during SetContentClient(). | |
| 474 DCHECK(content::GetContentClient()) | |
| 475 << "SetContentClient() must be called by this point in time"; | |
|
jam
2012/04/06 23:13:52
nit: are you sure this dcheck is necessary? ie. ha
scherkus (not reviewing)
2012/04/06 23:59:41
if the call to SetContentClient() happens after se
jam
2012/04/07 00:03:07
just to be clear, i meant if there's code in conte
| |
| 476 if (command_line.HasSwitch(switches::kUserAgent)) { | |
| 477 webkit_glue::SetUserAgent( | |
| 478 command_line.GetSwitchValueASCII(switches::kUserAgent), true); | |
| 479 } | |
| 480 | |
| 470 if (!process_type.empty()) | 481 if (!process_type.empty()) |
| 471 CommonSubprocessInit(process_type); | 482 CommonSubprocessInit(process_type); |
| 472 | 483 |
| 473 #if defined(OS_WIN) | 484 #if defined(OS_WIN) |
| 474 CHECK(content::InitializeSandbox(sandbox_info)); | 485 CHECK(content::InitializeSandbox(sandbox_info)); |
| 475 #elif defined(OS_MACOSX) | 486 #elif defined(OS_MACOSX) |
| 476 if (process_type == switches::kRendererProcess || | 487 if (process_type == switches::kRendererProcess || |
| 477 process_type == switches::kPpapiPluginProcess || | 488 process_type == switches::kPpapiPluginProcess || |
| 478 (delegate && delegate->DelaySandboxInitialization(process_type))) { | 489 (delegate && delegate->DelaySandboxInitialization(process_type))) { |
| 479 // On OS X the renderer sandbox needs to be initialized later in the | 490 // On OS X the renderer sandbox needs to be initialized later in the |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 567 } // namespace | 578 } // namespace |
| 568 | 579 |
| 569 namespace content { | 580 namespace content { |
| 570 | 581 |
| 571 // static | 582 // static |
| 572 ContentMainRunner* ContentMainRunner::Create() { | 583 ContentMainRunner* ContentMainRunner::Create() { |
| 573 return new ContentMainRunnerImpl(); | 584 return new ContentMainRunnerImpl(); |
| 574 } | 585 } |
| 575 | 586 |
| 576 } // namespace content | 587 } // namespace content |
| OLD | NEW |