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

Side by Side Diff: chrome/browser/renderer_host/browser_render_process_host.cc

Issue 21190: POSIX: add command line option to launch renderers in a wrapper (Closed)
Patch Set: ... Created 11 years, 10 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
« no previous file with comments | « base/command_line.cc ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 // Represents the browser side of the browser <--> renderer communication 5 // Represents the browser side of the browser <--> renderer communication
6 // channel. There will be one RenderProcessHost per renderer process. 6 // channel. There will be one RenderProcessHost per renderer process.
7 7
8 #include "chrome/browser/renderer_host/browser_render_process_host.h" 8 #include "chrome/browser/renderer_host/browser_render_process_host.h"
9 9
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 if (browser_command_line.HasSwitch(switches::kInProcessPlugins)) { 277 if (browser_command_line.HasSwitch(switches::kInProcessPlugins)) {
278 // In process plugins won't work if the sandbox is enabled. 278 // In process plugins won't work if the sandbox is enabled.
279 in_sandbox = false; 279 in_sandbox = false;
280 } 280 }
281 281
282 #if defined(OS_WIN) 282 #if defined(OS_WIN)
283 bool child_needs_help = 283 bool child_needs_help =
284 DebugFlags::ProcessDebugFlags(&cmd_line, 284 DebugFlags::ProcessDebugFlags(&cmd_line,
285 DebugFlags::RENDERER, 285 DebugFlags::RENDERER,
286 in_sandbox); 286 in_sandbox);
287 #elif defined(OS_POSIX)
288 if (browser_command_line.HasSwitch(switches::kRendererCmdPrefix)) {
289 // launch the renderer child with some prefix (usually "gdb --args")
290 const std::wstring prefix =
291 browser_command_line.GetSwitchValue(switches::kRendererCmdPrefix);
292 cmd_line.PrependWrapper(prefix);
293 }
287 #endif 294 #endif
288 295
289 cmd_line.AppendSwitchWithValue(switches::kProcessType, 296 cmd_line.AppendSwitchWithValue(switches::kProcessType,
290 switches::kRendererProcess); 297 switches::kRendererProcess);
291 298
292 cmd_line.AppendSwitchWithValue(switches::kProcessChannelID, 299 cmd_line.AppendSwitchWithValue(switches::kProcessChannelID,
293 channel_id); 300 channel_id);
294 301
295 const std::wstring& profile_path = 302 const std::wstring& profile_path =
296 browser_command_line.GetSwitchValue(switches::kUserDataDir); 303 browser_command_line.GetSwitchValue(switches::kUserDataDir);
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 process_.set_handle(OpenProcess(MAXIMUM_ALLOWED, FALSE, peer_pid)); 644 process_.set_handle(OpenProcess(MAXIMUM_ALLOWED, FALSE, peer_pid));
638 #elif defined(OS_POSIX) 645 #elif defined(OS_POSIX)
639 // ProcessHandle is just a pid. 646 // ProcessHandle is just a pid.
640 process_.set_handle(peer_pid); 647 process_.set_handle(peer_pid);
641 #endif 648 #endif
642 DCHECK(process_.handle()); 649 DCHECK(process_.handle());
643 } 650 }
644 } else { 651 } else {
645 // Need to verify that the peer_pid is actually the process we know, if 652 // Need to verify that the peer_pid is actually the process we know, if
646 // it is not, we need to panic now. See bug 1002150. 653 // it is not, we need to panic now. See bug 1002150.
647 CHECK(peer_pid == process_.pid()); 654 if (peer_pid != process_.pid()) {
655 // In the case that we are running the renderer in a wrapper, this check
656 // is invalid as it's the wrapper PID that we'll have, not the actual
657 // renderer
658 const CommandLine& cmd_line = *CommandLine::ForCurrentProcess();
659 if (cmd_line.HasSwitch(switches::kRendererCmdPrefix))
660 return;
661 CHECK(peer_pid == process_.pid());
662 }
648 } 663 }
649 } 664 }
650 665
651 // Static. This function can be called from the IO Thread or from the UI thread. 666 // Static. This function can be called from the IO Thread or from the UI thread.
652 void BrowserRenderProcessHost::BadMessageTerminateProcess(uint16 msg_type, 667 void BrowserRenderProcessHost::BadMessageTerminateProcess(uint16 msg_type,
653 base::ProcessHandle pr ocess) { 668 base::ProcessHandle pr ocess) {
654 LOG(ERROR) << "bad message " << msg_type << " terminating renderer."; 669 LOG(ERROR) << "bad message " << msg_type << " terminating renderer.";
655 if (BrowserRenderProcessHost::run_renderer_in_process()) { 670 if (BrowserRenderProcessHost::run_renderer_in_process()) {
656 // In single process mode it is better if we don't suicide but just crash. 671 // In single process mode it is better if we don't suicide but just crash.
657 CHECK(false); 672 CHECK(false);
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 // child processes determine the pid of the parent. 804 // child processes determine the pid of the parent.
790 // Build the channel ID. This is composed of a unique identifier for the 805 // Build the channel ID. This is composed of a unique identifier for the
791 // parent browser process, an identifier for the renderer/plugin instance, 806 // parent browser process, an identifier for the renderer/plugin instance,
792 // and a random component. We use a random component so that a hacked child 807 // and a random component. We use a random component so that a hacked child
793 // process can't cause denial of service by causing future named pipe creation 808 // process can't cause denial of service by causing future named pipe creation
794 // to fail. 809 // to fail.
795 return StringPrintf(L"%d.%x.%d", 810 return StringPrintf(L"%d.%x.%d",
796 base::GetCurrentProcId(), instance, 811 base::GetCurrentProcId(), instance,
797 base::RandInt(0, std::numeric_limits<int>::max())); 812 base::RandInt(0, std::numeric_limits<int>::max()));
798 } 813 }
OLDNEW
« no previous file with comments | « base/command_line.cc ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698