| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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" | |
| 11 | |
| 12 #include <algorithm> | 10 #include <algorithm> |
| 13 #include <limits> | 11 #include <limits> |
| 14 #include <vector> | 12 #include <vector> |
| 15 | 13 |
| 16 #if defined(OS_POSIX) | 14 #if defined(OS_POSIX) |
| 17 #include <utility> // for pair<> | 15 #include <utility> // for pair<> |
| 18 #endif | 16 #endif |
| 19 | 17 |
| 20 #include "app/app_switches.h" | 18 #include "app/app_switches.h" |
| 21 #include "base/command_line.h" | 19 #include "base/command_line.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 #include "grit/generated_resources.h" | 57 #include "grit/generated_resources.h" |
| 60 #include "ipc/ipc_logging.h" | 58 #include "ipc/ipc_logging.h" |
| 61 #include "ipc/ipc_message.h" | 59 #include "ipc/ipc_message.h" |
| 62 #include "ipc/ipc_switches.h" | 60 #include "ipc/ipc_switches.h" |
| 63 | 61 |
| 64 #if defined(OS_WIN) | 62 #if defined(OS_WIN) |
| 65 #include "app/win_util.h" | 63 #include "app/win_util.h" |
| 66 #include "chrome/browser/sandbox_policy.h" | 64 #include "chrome/browser/sandbox_policy.h" |
| 67 #elif defined(OS_LINUX) | 65 #elif defined(OS_LINUX) |
| 68 #include "base/singleton.h" | 66 #include "base/singleton.h" |
| 67 #include "chrome/browser/crash_handler_host_linux.h" |
| 69 #include "chrome/browser/zygote_host_linux.h" | 68 #include "chrome/browser/zygote_host_linux.h" |
| 70 #include "chrome/browser/renderer_host/render_crash_handler_host_linux.h" | |
| 71 #include "chrome/browser/renderer_host/render_sandbox_host_linux.h" | 69 #include "chrome/browser/renderer_host/render_sandbox_host_linux.h" |
| 72 #endif | 70 #endif |
| 73 | 71 |
| 74 using WebKit::WebCache; | 72 using WebKit::WebCache; |
| 75 | 73 |
| 76 #include "third_party/skia/include/core/SkBitmap.h" | 74 #include "third_party/skia/include/core/SkBitmap.h" |
| 77 | 75 |
| 78 | 76 |
| 79 // This class creates the IO thread for the renderer when running in | 77 // This class creates the IO thread for the renderer when running in |
| 80 // single-process mode. It's not used in multi-process mode. | 78 // single-process mode. It's not used in multi-process mode. |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 bool has_cmd_prefix) { | 584 bool has_cmd_prefix) { |
| 587 #if defined(OS_LINUX) | 585 #if defined(OS_LINUX) |
| 588 // On Linux, normally spawn processes with zygotes. We can't do this when | 586 // On Linux, normally spawn processes with zygotes. We can't do this when |
| 589 // we're spawning child processes through an external program (i.e. there is a | 587 // we're spawning child processes through an external program (i.e. there is a |
| 590 // command prefix) like GDB so fall through to the POSIX case then. | 588 // command prefix) like GDB so fall through to the POSIX case then. |
| 591 if (!has_cmd_prefix) { | 589 if (!has_cmd_prefix) { |
| 592 base::GlobalDescriptors::Mapping mapping; | 590 base::GlobalDescriptors::Mapping mapping; |
| 593 const int ipcfd = channel_->GetClientFileDescriptor(); | 591 const int ipcfd = channel_->GetClientFileDescriptor(); |
| 594 mapping.push_back(std::pair<uint32_t, int>(kPrimaryIPCChannel, ipcfd)); | 592 mapping.push_back(std::pair<uint32_t, int>(kPrimaryIPCChannel, ipcfd)); |
| 595 const int crash_signal_fd = | 593 const int crash_signal_fd = |
| 596 Singleton<RenderCrashHandlerHostLinux>()->GetDeathSignalSocket(); | 594 Singleton<RendererCrashHandlerHostLinux>()->GetDeathSignalSocket(); |
| 597 if (crash_signal_fd >= 0) { | 595 if (crash_signal_fd >= 0) { |
| 598 mapping.push_back(std::pair<uint32_t, int>(kCrashDumpSignal, | 596 mapping.push_back(std::pair<uint32_t, int>(kCrashDumpSignal, |
| 599 crash_signal_fd)); | 597 crash_signal_fd)); |
| 600 } | 598 } |
| 601 zygote_child_ = true; | 599 zygote_child_ = true; |
| 602 return Singleton<ZygoteHost>()->ForkRenderer(cmd_line->argv(), mapping); | 600 return Singleton<ZygoteHost>()->ForkRenderer(cmd_line->argv(), mapping); |
| 603 } | 601 } |
| 604 #endif // defined(OS_LINUX) | 602 #endif // defined(OS_LINUX) |
| 605 | 603 |
| 606 // NOTE: This code is duplicated with plugin_process_host.cc, but | 604 // NOTE: This code is duplicated with plugin_process_host.cc, but |
| 607 // there's not a good place to de-duplicate it. | 605 // there's not a good place to de-duplicate it. |
| 608 base::file_handle_mapping_vector fds_to_map; | 606 base::file_handle_mapping_vector fds_to_map; |
| 609 const int ipcfd = channel_->GetClientFileDescriptor(); | 607 const int ipcfd = channel_->GetClientFileDescriptor(); |
| 610 fds_to_map.push_back(std::make_pair(ipcfd, kPrimaryIPCChannel + 3)); | 608 fds_to_map.push_back(std::make_pair(ipcfd, kPrimaryIPCChannel + 3)); |
| 611 | 609 |
| 612 #if defined(OS_LINUX) | 610 #if defined(OS_LINUX) |
| 613 // On Linux, we need to add some extra file descriptors for crash handling and | 611 // On Linux, we need to add some extra file descriptors for crash handling and |
| 614 // the sandbox. | 612 // the sandbox. |
| 615 const int crash_signal_fd = | 613 const int crash_signal_fd = |
| 616 Singleton<RenderCrashHandlerHostLinux>()->GetDeathSignalSocket(); | 614 Singleton<RendererCrashHandlerHostLinux>()->GetDeathSignalSocket(); |
| 617 if (crash_signal_fd >= 0) { | 615 if (crash_signal_fd >= 0) { |
| 618 fds_to_map.push_back(std::make_pair(crash_signal_fd, | 616 fds_to_map.push_back(std::make_pair(crash_signal_fd, |
| 619 kCrashDumpSignal + 3)); | 617 kCrashDumpSignal + 3)); |
| 620 } | 618 } |
| 621 const int sandbox_fd = | 619 const int sandbox_fd = |
| 622 Singleton<RenderSandboxHostLinux>()->GetRendererSocket(); | 620 Singleton<RenderSandboxHostLinux>()->GetRendererSocket(); |
| 623 fds_to_map.push_back(std::make_pair(sandbox_fd, kSandboxIPCChannel + 3)); | 621 fds_to_map.push_back(std::make_pair(sandbox_fd, kSandboxIPCChannel + 3)); |
| 624 #endif // defined(OS_LINUX) | 622 #endif // defined(OS_LINUX) |
| 625 | 623 |
| 626 // Actually launch the app. | 624 // Actually launch the app. |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 906 CHECK(peer_pid == process_.pid()) << peer_pid << " " << process_.pid(); | 904 CHECK(peer_pid == process_.pid()) << peer_pid << " " << process_.pid(); |
| 907 #endif | 905 #endif |
| 908 } | 906 } |
| 909 mark_child_process_activity_time(); | 907 mark_child_process_activity_time(); |
| 910 } | 908 } |
| 911 | 909 |
| 912 #if defined(IPC_MESSAGE_LOG_ENABLED) | 910 #if defined(IPC_MESSAGE_LOG_ENABLED) |
| 913 bool enabled = IPC::Logging::current()->Enabled(); | 911 bool enabled = IPC::Logging::current()->Enabled(); |
| 914 Send(new ViewMsg_SetIPCLoggingEnabled(enabled)); | 912 Send(new ViewMsg_SetIPCLoggingEnabled(enabled)); |
| 915 #endif | 913 #endif |
| 916 | |
| 917 } | 914 } |
| 918 | 915 |
| 919 // Static. This function can be called from any thread. | 916 // Static. This function can be called from any thread. |
| 920 void BrowserRenderProcessHost::BadMessageTerminateProcess( | 917 void BrowserRenderProcessHost::BadMessageTerminateProcess( |
| 921 uint16 msg_type, base::ProcessHandle process) { | 918 uint16 msg_type, base::ProcessHandle process) { |
| 922 LOG(ERROR) << "bad message " << msg_type << " terminating renderer."; | 919 LOG(ERROR) << "bad message " << msg_type << " terminating renderer."; |
| 923 if (BrowserRenderProcessHost::run_renderer_in_process()) { | 920 if (BrowserRenderProcessHost::run_renderer_in_process()) { |
| 924 // In single process mode it is better if we don't suicide but just crash. | 921 // In single process mode it is better if we don't suicide but just crash. |
| 925 CHECK(false); | 922 CHECK(false); |
| 926 } | 923 } |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1123 channel_->Send(new ViewMsg_SpellChecker_Init( | 1120 channel_->Send(new ViewMsg_SpellChecker_Init( |
| 1124 base::FileDescriptor(), std::vector<std::string>(), std::string(), | 1121 base::FileDescriptor(), std::vector<std::string>(), std::string(), |
| 1125 false)); | 1122 false)); |
| 1126 } | 1123 } |
| 1127 } | 1124 } |
| 1128 | 1125 |
| 1129 void BrowserRenderProcessHost::EnableAutoSpellCorrect(bool enable) { | 1126 void BrowserRenderProcessHost::EnableAutoSpellCorrect(bool enable) { |
| 1130 channel_->Send(new ViewMsg_SpellChecker_EnableAutoSpellCorrect(enable)); | 1127 channel_->Send(new ViewMsg_SpellChecker_EnableAutoSpellCorrect(enable)); |
| 1131 } | 1128 } |
| 1132 #endif | 1129 #endif |
| OLD | NEW |