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

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

Issue 1640123005: Revert of Have each SandboxedProcessLauncherDelegate maintain a zygote. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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
210 #if defined(USE_OZONE) 204 #if defined(USE_OZONE)
211 #include "ui/ozone/public/client_native_pixmap_factory.h" 205 #include "ui/ozone/public/client_native_pixmap_factory.h"
212 #include "ui/ozone/public/ozone_platform.h" 206 #include "ui/ozone/public/ozone_platform.h"
213 #include "ui/ozone/public/ozone_switches.h" 207 #include "ui/ozone/public/ozone_switches.h"
214 #endif 208 #endif
215 209
216 #if defined(ENABLE_BROWSER_CDMS) 210 #if defined(ENABLE_BROWSER_CDMS)
217 #include "content/browser/media/cdm/browser_cdm_manager.h" 211 #include "content/browser/media/cdm/browser_cdm_manager.h"
218 #endif 212 #endif
219 213
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 DCHECK(context); 355 DCHECK(context);
362 SiteProcessMap* map = static_cast<SiteProcessMap*>( 356 SiteProcessMap* map = static_cast<SiteProcessMap*>(
363 context->GetUserData(kSiteProcessMapKeyName)); 357 context->GetUserData(kSiteProcessMapKeyName));
364 if (!map) { 358 if (!map) {
365 map = new SiteProcessMap(); 359 map = new SiteProcessMap();
366 context->SetUserData(kSiteProcessMapKeyName, map); 360 context->SetUserData(kSiteProcessMapKeyName, map);
367 } 361 }
368 return map; 362 return map;
369 } 363 }
370 364
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
377 // NOTE: changes to this class need to be reviewed by the security team. 365 // NOTE: changes to this class need to be reviewed by the security team.
378 class RendererSandboxedProcessLauncherDelegate 366 class RendererSandboxedProcessLauncherDelegate
379 : public SandboxedProcessLauncherDelegate { 367 : public SandboxedProcessLauncherDelegate {
380 public: 368 public:
381 explicit RendererSandboxedProcessLauncherDelegate(IPC::ChannelProxy* channel) 369 explicit RendererSandboxedProcessLauncherDelegate(IPC::ChannelProxy* channel)
382 #if defined(OS_POSIX) 370 #if defined(OS_POSIX)
383 : ipc_fd_(channel->TakeClientFileDescriptor()) 371 : ipc_fd_(channel->TakeClientFileDescriptor())
384 #endif // OS_POSIX 372 #endif // OS_POSIX
385 { 373 {
386 } 374 }
387 375
388 ~RendererSandboxedProcessLauncherDelegate() override {} 376 ~RendererSandboxedProcessLauncherDelegate() override {}
389 377
390 #if defined(OS_WIN) 378 #if defined(OS_WIN)
391 bool PreSpawnTarget(sandbox::TargetPolicy* policy) override { 379 bool PreSpawnTarget(sandbox::TargetPolicy* policy) override {
392 AddBaseHandleClosePolicy(policy); 380 AddBaseHandleClosePolicy(policy);
393 381
394 const base::string16& sid = 382 const base::string16& sid =
395 GetContentClient()->browser()->GetAppContainerSidForSandboxType( 383 GetContentClient()->browser()->GetAppContainerSidForSandboxType(
396 GetSandboxType()); 384 GetSandboxType());
397 if (!sid.empty()) 385 if (!sid.empty())
398 AddAppContainerPolicy(policy, sid.c_str()); 386 AddAppContainerPolicy(policy, sid.c_str());
399 387
400 return GetContentClient()->browser()->PreSpawnRenderer(policy); 388 return GetContentClient()->browser()->PreSpawnRenderer(policy);
401 } 389 }
402 390
403 #elif defined(OS_POSIX) 391 #elif defined(OS_POSIX)
404 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) 392 bool ShouldUseZygote() override {
405 ZygoteHandle* GetZygote() override {
406 const base::CommandLine& browser_command_line = 393 const base::CommandLine& browser_command_line =
407 *base::CommandLine::ForCurrentProcess(); 394 *base::CommandLine::ForCurrentProcess();
408 base::CommandLine::StringType renderer_prefix = 395 base::CommandLine::StringType renderer_prefix =
409 browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix); 396 browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix);
410 if (!renderer_prefix.empty()) 397 return renderer_prefix.empty();
411 return nullptr;
412 return &g_render_zygote;
413 } 398 }
414 #endif // !defined(OS_MACOSX) && !defined(OS_ANDROID)
415 base::ScopedFD TakeIpcFd() override { return std::move(ipc_fd_); } 399 base::ScopedFD TakeIpcFd() override { return std::move(ipc_fd_); }
416 #endif // OS_WIN 400 #endif // OS_WIN
417 401
418 SandboxType GetSandboxType() override { return SANDBOX_TYPE_RENDERER; } 402 SandboxType GetSandboxType() override { return SANDBOX_TYPE_RENDERER; }
419 403
420 private: 404 private:
421 #if defined(OS_POSIX) 405 #if defined(OS_POSIX)
422 base::ScopedFD ipc_fd_; 406 base::ScopedFD ipc_fd_;
423 #endif // OS_POSIX 407 #endif // OS_POSIX
424 }; 408 };
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 } 518 }
535 519
536 // static 520 // static
537 bool g_run_renderer_in_process_ = false; 521 bool g_run_renderer_in_process_ = false;
538 522
539 // static 523 // static
540 void RenderProcessHost::SetMaxRendererProcessCount(size_t count) { 524 void RenderProcessHost::SetMaxRendererProcessCount(size_t count) {
541 g_max_renderer_count_override = count; 525 g_max_renderer_count_override = count;
542 } 526 }
543 527
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 = 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
557 RenderProcessHostImpl::RenderProcessHostImpl( 528 RenderProcessHostImpl::RenderProcessHostImpl(
558 BrowserContext* browser_context, 529 BrowserContext* browser_context,
559 StoragePartitionImpl* storage_partition_impl, 530 StoragePartitionImpl* storage_partition_impl,
560 bool is_for_guests_only) 531 bool is_for_guests_only)
561 : fast_shutdown_started_(false), 532 : fast_shutdown_started_(false),
562 deleting_soon_(false), 533 deleting_soon_(false),
563 #ifndef NDEBUG 534 #ifndef NDEBUG
564 is_self_deleted_(false), 535 is_self_deleted_(false),
565 #endif 536 #endif
566 pending_views_(0), 537 pending_views_(0),
(...skipping 2209 matching lines...) Expand 10 before | Expand all | Expand 10 after
2776 void RenderProcessHostImpl::GetAudioOutputControllers( 2747 void RenderProcessHostImpl::GetAudioOutputControllers(
2777 const GetAudioOutputControllersCallback& callback) const { 2748 const GetAudioOutputControllersCallback& callback) const {
2778 audio_renderer_host()->GetOutputControllers(callback); 2749 audio_renderer_host()->GetOutputControllers(callback);
2779 } 2750 }
2780 2751
2781 BluetoothDispatcherHost* RenderProcessHostImpl::GetBluetoothDispatcherHost() { 2752 BluetoothDispatcherHost* RenderProcessHostImpl::GetBluetoothDispatcherHost() {
2782 return bluetooth_dispatcher_host_.get(); 2753 return bluetooth_dispatcher_host_.get();
2783 } 2754 }
2784 2755
2785 } // namespace content 2756 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.h ('k') | content/browser/utility_process_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698