| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 // 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 "content/browser/renderer_host/render_process_host_impl.h" | 8 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 #if defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX) | 369 #if defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX) |
| 370 // This static member variable holds the zygote communication information for | 370 // This static member variable holds the zygote communication information for |
| 371 // the renderer. | 371 // the renderer. |
| 372 ZygoteHandle g_render_zygote; | 372 ZygoteHandle g_render_zygote; |
| 373 #endif // defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX) | 373 #endif // defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX) |
| 374 | 374 |
| 375 // NOTE: changes to this class need to be reviewed by the security team. | 375 // NOTE: changes to this class need to be reviewed by the security team. |
| 376 class RendererSandboxedProcessLauncherDelegate | 376 class RendererSandboxedProcessLauncherDelegate |
| 377 : public SandboxedProcessLauncherDelegate { | 377 : public SandboxedProcessLauncherDelegate { |
| 378 public: | 378 public: |
| 379 explicit RendererSandboxedProcessLauncherDelegate(IPC::ChannelProxy* channel) | 379 RendererSandboxedProcessLauncherDelegate() {} |
| 380 #if defined(OS_POSIX) | |
| 381 : ipc_fd_(channel->TakeClientFileDescriptor()) | |
| 382 #endif // OS_POSIX | |
| 383 { | |
| 384 } | |
| 385 | 380 |
| 386 ~RendererSandboxedProcessLauncherDelegate() override {} | 381 ~RendererSandboxedProcessLauncherDelegate() override {} |
| 387 | 382 |
| 388 #if defined(OS_WIN) | 383 #if defined(OS_WIN) |
| 389 bool PreSpawnTarget(sandbox::TargetPolicy* policy) override { | 384 bool PreSpawnTarget(sandbox::TargetPolicy* policy) override { |
| 390 AddBaseHandleClosePolicy(policy); | 385 AddBaseHandleClosePolicy(policy); |
| 391 | 386 |
| 392 const base::string16& sid = | 387 const base::string16& sid = |
| 393 GetContentClient()->browser()->GetAppContainerSidForSandboxType( | 388 GetContentClient()->browser()->GetAppContainerSidForSandboxType( |
| 394 GetSandboxType()); | 389 GetSandboxType()); |
| 395 if (!sid.empty()) | 390 if (!sid.empty()) |
| 396 AddAppContainerPolicy(policy, sid.c_str()); | 391 AddAppContainerPolicy(policy, sid.c_str()); |
| 397 | 392 |
| 398 return GetContentClient()->browser()->PreSpawnRenderer(policy); | 393 return GetContentClient()->browser()->PreSpawnRenderer(policy); |
| 399 } | 394 } |
| 400 | 395 |
| 401 #elif defined(OS_POSIX) | 396 #elif defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) |
| 402 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) | |
| 403 ZygoteHandle* GetZygote() override { | 397 ZygoteHandle* GetZygote() override { |
| 404 const base::CommandLine& browser_command_line = | 398 const base::CommandLine& browser_command_line = |
| 405 *base::CommandLine::ForCurrentProcess(); | 399 *base::CommandLine::ForCurrentProcess(); |
| 406 base::CommandLine::StringType renderer_prefix = | 400 base::CommandLine::StringType renderer_prefix = |
| 407 browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix); | 401 browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix); |
| 408 if (!renderer_prefix.empty()) | 402 if (!renderer_prefix.empty()) |
| 409 return nullptr; | 403 return nullptr; |
| 410 return GetGenericZygote(); | 404 return GetGenericZygote(); |
| 411 } | 405 } |
| 412 #endif // !defined(OS_MACOSX) && !defined(OS_ANDROID) | |
| 413 base::ScopedFD TakeIpcFd() override { return std::move(ipc_fd_); } | |
| 414 #endif // OS_WIN | 406 #endif // OS_WIN |
| 415 | 407 |
| 416 SandboxType GetSandboxType() override { return SANDBOX_TYPE_RENDERER; } | 408 SandboxType GetSandboxType() override { return SANDBOX_TYPE_RENDERER; } |
| 417 | |
| 418 private: | |
| 419 #if defined(OS_POSIX) | |
| 420 base::ScopedFD ipc_fd_; | |
| 421 #endif // OS_POSIX | |
| 422 }; | 409 }; |
| 423 | 410 |
| 424 const char kSessionStorageHolderKey[] = "kSessionStorageHolderKey"; | 411 const char kSessionStorageHolderKey[] = "kSessionStorageHolderKey"; |
| 425 | 412 |
| 426 class SessionStorageHolder : public base::SupportsUserData::Data { | 413 class SessionStorageHolder : public base::SupportsUserData::Data { |
| 427 public: | 414 public: |
| 428 SessionStorageHolder() | 415 SessionStorageHolder() |
| 429 : session_storage_namespaces_awaiting_close_( | 416 : session_storage_namespaces_awaiting_close_( |
| 430 new std::map<int, SessionStorageNamespaceMap>) { | 417 new std::map<int, SessionStorageNamespaceMap>) { |
| 431 } | 418 } |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 886 // first so the process type argument will appear first. | 873 // first so the process type argument will appear first. |
| 887 base::CommandLine* cmd_line = new base::CommandLine(renderer_path); | 874 base::CommandLine* cmd_line = new base::CommandLine(renderer_path); |
| 888 if (!renderer_prefix.empty()) | 875 if (!renderer_prefix.empty()) |
| 889 cmd_line->PrependWrapper(renderer_prefix); | 876 cmd_line->PrependWrapper(renderer_prefix); |
| 890 AppendRendererCommandLine(cmd_line); | 877 AppendRendererCommandLine(cmd_line); |
| 891 | 878 |
| 892 // Spawn the child process asynchronously to avoid blocking the UI thread. | 879 // Spawn the child process asynchronously to avoid blocking the UI thread. |
| 893 // As long as there's no renderer prefix, we can use the zygote process | 880 // As long as there's no renderer prefix, we can use the zygote process |
| 894 // at this stage. | 881 // at this stage. |
| 895 child_process_launcher_.reset(new ChildProcessLauncher( | 882 child_process_launcher_.reset(new ChildProcessLauncher( |
| 896 new RendererSandboxedProcessLauncherDelegate(channel_.get()), cmd_line, | 883 new RendererSandboxedProcessLauncherDelegate(), cmd_line, GetID(), this, |
| 897 GetID(), this, child_token_, | 884 child_token_, base::Bind(&RenderProcessHostImpl::OnMojoError, id_))); |
| 898 base::Bind(&RenderProcessHostImpl::OnMojoError, id_))); | |
| 899 channel_->Pause(); | 885 channel_->Pause(); |
| 900 | 886 |
| 901 fast_shutdown_started_ = false; | 887 fast_shutdown_started_ = false; |
| 902 } | 888 } |
| 903 | 889 |
| 904 if (!gpu_observer_registered_) { | 890 if (!gpu_observer_registered_) { |
| 905 gpu_observer_registered_ = true; | 891 gpu_observer_registered_ = true; |
| 906 ui::GpuSwitchingManager::GetInstance()->AddObserver(this); | 892 ui::GpuSwitchingManager::GetInstance()->AddObserver(this); |
| 907 } | 893 } |
| 908 | 894 |
| (...skipping 2069 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2978 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; | 2964 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; |
| 2979 | 2965 |
| 2980 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias | 2966 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias |
| 2981 // enough information here so that we can determine what the bad message was. | 2967 // enough information here so that we can determine what the bad message was. |
| 2982 base::debug::Alias(&error); | 2968 base::debug::Alias(&error); |
| 2983 bad_message::ReceivedBadMessage(render_process_id, | 2969 bad_message::ReceivedBadMessage(render_process_id, |
| 2984 bad_message::RPH_MOJO_PROCESS_ERROR); | 2970 bad_message::RPH_MOJO_PROCESS_ERROR); |
| 2985 } | 2971 } |
| 2986 | 2972 |
| 2987 } // namespace content | 2973 } // namespace content |
| OLD | NEW |