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

Side by Side Diff: content/browser/renderer_host/render_process_host_impl.cc

Issue 1532423003: Have each SandboxedProcessLauncherDelegate maintain a zygote. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanups per review., Created 4 years, 11 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
OLDNEW
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
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 #include "content/public/browser/zygote_handle_linux.h"
208 #endif // defined(OS_POSIX)
209
204 #if defined(USE_OZONE) 210 #if defined(USE_OZONE)
205 #include "ui/ozone/public/client_native_pixmap_factory.h" 211 #include "ui/ozone/public/client_native_pixmap_factory.h"
206 #include "ui/ozone/public/ozone_platform.h" 212 #include "ui/ozone/public/ozone_platform.h"
207 #include "ui/ozone/public/ozone_switches.h" 213 #include "ui/ozone/public/ozone_switches.h"
208 #endif 214 #endif
209 215
210 #if defined(ENABLE_BROWSER_CDMS) 216 #if defined(ENABLE_BROWSER_CDMS)
211 #include "content/browser/media/cdm/browser_cdm_manager.h" 217 #include "content/browser/media/cdm/browser_cdm_manager.h"
212 #endif 218 #endif
213 219
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 DCHECK(context); 361 DCHECK(context);
356 SiteProcessMap* map = static_cast<SiteProcessMap*>( 362 SiteProcessMap* map = static_cast<SiteProcessMap*>(
357 context->GetUserData(kSiteProcessMapKeyName)); 363 context->GetUserData(kSiteProcessMapKeyName));
358 if (!map) { 364 if (!map) {
359 map = new SiteProcessMap(); 365 map = new SiteProcessMap();
360 context->SetUserData(kSiteProcessMapKeyName, map); 366 context->SetUserData(kSiteProcessMapKeyName, map);
361 } 367 }
362 return map; 368 return map;
363 } 369 }
364 370
371 #if defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX)
372 // This static member variable holds the zygote communication information for
373 // the renderer.
374 ZygoteHandle g_render_zygote;
375 #endif // defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX)
376
365 // NOTE: changes to this class need to be reviewed by the security team. 377 // NOTE: changes to this class need to be reviewed by the security team.
366 class RendererSandboxedProcessLauncherDelegate 378 class RendererSandboxedProcessLauncherDelegate
367 : public SandboxedProcessLauncherDelegate { 379 : public SandboxedProcessLauncherDelegate {
368 public: 380 public:
369 explicit RendererSandboxedProcessLauncherDelegate(IPC::ChannelProxy* channel) 381 explicit RendererSandboxedProcessLauncherDelegate(IPC::ChannelProxy* channel)
370 #if defined(OS_POSIX) 382 #if defined(OS_POSIX)
371 : ipc_fd_(channel->TakeClientFileDescriptor()) 383 : ipc_fd_(channel->TakeClientFileDescriptor())
372 #endif // OS_POSIX 384 #endif // OS_POSIX
373 { 385 {
374 } 386 }
375 387
376 ~RendererSandboxedProcessLauncherDelegate() override {} 388 ~RendererSandboxedProcessLauncherDelegate() override {}
377 389
378 #if defined(OS_WIN) 390 #if defined(OS_WIN)
379 bool PreSpawnTarget(sandbox::TargetPolicy* policy) override { 391 bool PreSpawnTarget(sandbox::TargetPolicy* policy) override {
380 AddBaseHandleClosePolicy(policy); 392 AddBaseHandleClosePolicy(policy);
381 393
382 const base::string16& sid = 394 const base::string16& sid =
383 GetContentClient()->browser()->GetAppContainerSidForSandboxType( 395 GetContentClient()->browser()->GetAppContainerSidForSandboxType(
384 GetSandboxType()); 396 GetSandboxType());
385 if (!sid.empty()) 397 if (!sid.empty())
386 AddAppContainerPolicy(policy, sid.c_str()); 398 AddAppContainerPolicy(policy, sid.c_str());
387 399
388 return GetContentClient()->browser()->PreSpawnRenderer(policy); 400 return GetContentClient()->browser()->PreSpawnRenderer(policy);
389 } 401 }
390 402
391 #elif defined(OS_POSIX) 403 #elif defined(OS_POSIX)
392 bool ShouldUseZygote() override { 404 #if !defined(OS_MACOSX) && !defined(OS_ANDROID)
405 ZygoteHandle* GetZygote() override {
393 const base::CommandLine& browser_command_line = 406 const base::CommandLine& browser_command_line =
394 *base::CommandLine::ForCurrentProcess(); 407 *base::CommandLine::ForCurrentProcess();
395 base::CommandLine::StringType renderer_prefix = 408 base::CommandLine::StringType renderer_prefix =
396 browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix); 409 browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix);
397 return renderer_prefix.empty(); 410 if (!renderer_prefix.empty())
411 return nullptr;
412 return &g_render_zygote;
398 } 413 }
414 #endif // !defined(OS_MACOSX) && !defined(OS_ANDROID)
399 base::ScopedFD TakeIpcFd() override { return std::move(ipc_fd_); } 415 base::ScopedFD TakeIpcFd() override { return std::move(ipc_fd_); }
400 #endif // OS_WIN 416 #endif // OS_WIN
401 417
402 SandboxType GetSandboxType() override { return SANDBOX_TYPE_RENDERER; } 418 SandboxType GetSandboxType() override { return SANDBOX_TYPE_RENDERER; }
403 419
404 private: 420 private:
405 #if defined(OS_POSIX) 421 #if defined(OS_POSIX)
406 base::ScopedFD ipc_fd_; 422 base::ScopedFD ipc_fd_;
407 #endif // OS_POSIX 423 #endif // OS_POSIX
408 }; 424 };
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 } 534 }
519 535
520 // static 536 // static
521 bool g_run_renderer_in_process_ = false; 537 bool g_run_renderer_in_process_ = false;
522 538
523 // static 539 // static
524 void RenderProcessHost::SetMaxRendererProcessCount(size_t count) { 540 void RenderProcessHost::SetMaxRendererProcessCount(size_t count) {
525 g_max_renderer_count_override = count; 541 g_max_renderer_count_override = count;
526 } 542 }
527 543
544 #if defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX)
545 // static
546 void RenderProcessHostImpl::EarlyZygoteLaunch() {
547 DCHECK(!g_render_zygote);
548 g_render_zygote = zygote_handle::CreateZygote();
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 g_render_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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698