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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 #include "content/common/sandbox_win.h" | 194 #include "content/common/sandbox_win.h" |
195 #include "sandbox/win/src/sandbox_policy.h" | 195 #include "sandbox/win/src/sandbox_policy.h" |
196 #include "ui/gfx/win/dpi.h" | 196 #include "ui/gfx/win/dpi.h" |
197 #endif | 197 #endif |
198 | 198 |
199 #if defined(OS_MACOSX) && !defined(OS_IOS) | 199 #if defined(OS_MACOSX) && !defined(OS_IOS) |
200 #include "content/browser/bootstrap_sandbox_manager_mac.h" | 200 #include "content/browser/bootstrap_sandbox_manager_mac.h" |
201 #include "content/browser/mach_broker_mac.h" | 201 #include "content/browser/mach_broker_mac.h" |
202 #endif | 202 #endif |
203 | 203 |
| 204 #if defined(OS_POSIX) |
| 205 #include "content/browser/zygote_host/zygote_communication_linux.h" |
| 206 #include "content/browser/zygote_host/zygote_host_impl_linux.h" |
| 207 #endif // defined(OS_POSIX) |
| 208 |
204 #if defined(USE_OZONE) | 209 #if defined(USE_OZONE) |
205 #include "ui/ozone/public/client_native_pixmap_factory.h" | 210 #include "ui/ozone/public/client_native_pixmap_factory.h" |
206 #include "ui/ozone/public/ozone_platform.h" | 211 #include "ui/ozone/public/ozone_platform.h" |
207 #include "ui/ozone/public/ozone_switches.h" | 212 #include "ui/ozone/public/ozone_switches.h" |
208 #endif | 213 #endif |
209 | 214 |
210 #if defined(ENABLE_BROWSER_CDMS) | 215 #if defined(ENABLE_BROWSER_CDMS) |
211 #include "content/browser/media/cdm/browser_cdm_manager.h" | 216 #include "content/browser/media/cdm/browser_cdm_manager.h" |
212 #endif | 217 #endif |
213 | 218 |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 DCHECK(context); | 360 DCHECK(context); |
356 SiteProcessMap* map = static_cast<SiteProcessMap*>( | 361 SiteProcessMap* map = static_cast<SiteProcessMap*>( |
357 context->GetUserData(kSiteProcessMapKeyName)); | 362 context->GetUserData(kSiteProcessMapKeyName)); |
358 if (!map) { | 363 if (!map) { |
359 map = new SiteProcessMap(); | 364 map = new SiteProcessMap(); |
360 context->SetUserData(kSiteProcessMapKeyName, map); | 365 context->SetUserData(kSiteProcessMapKeyName, map); |
361 } | 366 } |
362 return map; | 367 return map; |
363 } | 368 } |
364 | 369 |
| 370 #if defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX) |
| 371 // This static member variable holds the zygote communication information for |
| 372 // the renderer. |
| 373 ZygoteHandle zygote; |
| 374 #endif // defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX) |
| 375 |
365 // NOTE: changes to this class need to be reviewed by the security team. | 376 // NOTE: changes to this class need to be reviewed by the security team. |
366 class RendererSandboxedProcessLauncherDelegate | 377 class RendererSandboxedProcessLauncherDelegate |
367 : public SandboxedProcessLauncherDelegate { | 378 : public SandboxedProcessLauncherDelegate { |
368 public: | 379 public: |
369 explicit RendererSandboxedProcessLauncherDelegate(IPC::ChannelProxy* channel) | 380 explicit RendererSandboxedProcessLauncherDelegate(IPC::ChannelProxy* channel) |
370 #if defined(OS_POSIX) | 381 #if defined(OS_POSIX) |
371 : ipc_fd_(channel->TakeClientFileDescriptor()) | 382 : ipc_fd_(channel->TakeClientFileDescriptor()) |
372 #endif // OS_POSIX | 383 #endif // OS_POSIX |
373 { | 384 { |
374 } | 385 } |
375 | 386 |
376 ~RendererSandboxedProcessLauncherDelegate() override {} | 387 ~RendererSandboxedProcessLauncherDelegate() override {} |
377 | 388 |
378 #if defined(OS_WIN) | 389 #if defined(OS_WIN) |
379 bool PreSpawnTarget(sandbox::TargetPolicy* policy) override { | 390 bool PreSpawnTarget(sandbox::TargetPolicy* policy) override { |
380 AddBaseHandleClosePolicy(policy); | 391 AddBaseHandleClosePolicy(policy); |
381 | 392 |
382 const base::string16& sid = | 393 const base::string16& sid = |
383 GetContentClient()->browser()->GetAppContainerSidForSandboxType( | 394 GetContentClient()->browser()->GetAppContainerSidForSandboxType( |
384 GetSandboxType()); | 395 GetSandboxType()); |
385 if (!sid.empty()) | 396 if (!sid.empty()) |
386 AddAppContainerPolicy(policy, sid.c_str()); | 397 AddAppContainerPolicy(policy, sid.c_str()); |
387 | 398 |
388 return GetContentClient()->browser()->PreSpawnRenderer(policy); | 399 return GetContentClient()->browser()->PreSpawnRenderer(policy); |
389 } | 400 } |
390 | 401 |
391 #elif defined(OS_POSIX) | 402 #elif defined(OS_POSIX) |
392 bool ShouldUseZygote() override { | 403 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) |
| 404 ZygoteHandle* GetZygote() override { |
393 const base::CommandLine& browser_command_line = | 405 const base::CommandLine& browser_command_line = |
394 *base::CommandLine::ForCurrentProcess(); | 406 *base::CommandLine::ForCurrentProcess(); |
395 base::CommandLine::StringType renderer_prefix = | 407 base::CommandLine::StringType renderer_prefix = |
396 browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix); | 408 browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix); |
397 return renderer_prefix.empty(); | 409 if (!renderer_prefix.empty()) |
| 410 return nullptr; |
| 411 return &zygote; |
398 } | 412 } |
| 413 #endif // !defined(OS_MACOSX) && !defined(OS_ANDROID) |
399 base::ScopedFD TakeIpcFd() override { return std::move(ipc_fd_); } | 414 base::ScopedFD TakeIpcFd() override { return std::move(ipc_fd_); } |
400 #endif // OS_WIN | 415 #endif // OS_WIN |
401 | 416 |
402 SandboxType GetSandboxType() override { return SANDBOX_TYPE_RENDERER; } | 417 SandboxType GetSandboxType() override { return SANDBOX_TYPE_RENDERER; } |
403 | 418 |
404 private: | 419 private: |
405 #if defined(OS_POSIX) | 420 #if defined(OS_POSIX) |
406 base::ScopedFD ipc_fd_; | 421 base::ScopedFD ipc_fd_; |
407 #endif // OS_POSIX | 422 #endif // OS_POSIX |
408 }; | 423 }; |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 } | 533 } |
519 | 534 |
520 // static | 535 // static |
521 bool g_run_renderer_in_process_ = false; | 536 bool g_run_renderer_in_process_ = false; |
522 | 537 |
523 // static | 538 // static |
524 void RenderProcessHost::SetMaxRendererProcessCount(size_t count) { | 539 void RenderProcessHost::SetMaxRendererProcessCount(size_t count) { |
525 g_max_renderer_count_override = count; | 540 g_max_renderer_count_override = count; |
526 } | 541 } |
527 | 542 |
| 543 #if defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX) |
| 544 // static |
| 545 void RenderProcessHostImpl::EarlyZygoteLaunch() { |
| 546 DCHECK(!zygote); |
| 547 zygote = new ZygoteCommunication(); |
| 548 zygote->Init(); |
| 549 // TODO(kerrnel): Investigate doing this without the ZygoteHostImpl as a |
| 550 // proxy. It is currently done this way due to concerns about race |
| 551 // conditions. |
| 552 ZygoteHostImpl::GetInstance()->SetRendererSandboxStatus( |
| 553 zygote->GetSandboxStatus()); |
| 554 } |
| 555 #endif // defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX) |
| 556 |
528 RenderProcessHostImpl::RenderProcessHostImpl( | 557 RenderProcessHostImpl::RenderProcessHostImpl( |
529 BrowserContext* browser_context, | 558 BrowserContext* browser_context, |
530 StoragePartitionImpl* storage_partition_impl, | 559 StoragePartitionImpl* storage_partition_impl, |
531 bool is_for_guests_only) | 560 bool is_for_guests_only) |
532 : fast_shutdown_started_(false), | 561 : fast_shutdown_started_(false), |
533 deleting_soon_(false), | 562 deleting_soon_(false), |
534 #ifndef NDEBUG | 563 #ifndef NDEBUG |
535 is_self_deleted_(false), | 564 is_self_deleted_(false), |
536 #endif | 565 #endif |
537 pending_views_(0), | 566 pending_views_(0), |
(...skipping 2209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2747 void RenderProcessHostImpl::GetAudioOutputControllers( | 2776 void RenderProcessHostImpl::GetAudioOutputControllers( |
2748 const GetAudioOutputControllersCallback& callback) const { | 2777 const GetAudioOutputControllersCallback& callback) const { |
2749 audio_renderer_host()->GetOutputControllers(callback); | 2778 audio_renderer_host()->GetOutputControllers(callback); |
2750 } | 2779 } |
2751 | 2780 |
2752 BluetoothDispatcherHost* RenderProcessHostImpl::GetBluetoothDispatcherHost() { | 2781 BluetoothDispatcherHost* RenderProcessHostImpl::GetBluetoothDispatcherHost() { |
2753 return bluetooth_dispatcher_host_.get(); | 2782 return bluetooth_dispatcher_host_.get(); |
2754 } | 2783 } |
2755 | 2784 |
2756 } // namespace content | 2785 } // namespace content |
OLD | NEW |