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

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

Issue 177863002: Refactor configuration of sandboxes - first steps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Respond to further review comments from jam@ Created 6 years, 9 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 #include "content/public/browser/render_process_host_factory.h" 120 #include "content/public/browser/render_process_host_factory.h"
121 #include "content/public/browser/render_process_host_observer.h" 121 #include "content/public/browser/render_process_host_observer.h"
122 #include "content/public/browser/render_widget_host.h" 122 #include "content/public/browser/render_widget_host.h"
123 #include "content/public/browser/render_widget_host_iterator.h" 123 #include "content/public/browser/render_widget_host_iterator.h"
124 #include "content/public/browser/resource_context.h" 124 #include "content/public/browser/resource_context.h"
125 #include "content/public/browser/user_metrics.h" 125 #include "content/public/browser/user_metrics.h"
126 #include "content/public/common/content_constants.h" 126 #include "content/public/common/content_constants.h"
127 #include "content/public/common/content_switches.h" 127 #include "content/public/common/content_switches.h"
128 #include "content/public/common/process_type.h" 128 #include "content/public/common/process_type.h"
129 #include "content/public/common/result_codes.h" 129 #include "content/public/common/result_codes.h"
130 #include "content/public/common/sandboxed_process_launcher_delegate.h"
130 #include "content/public/common/url_constants.h" 131 #include "content/public/common/url_constants.h"
131 #include "gpu/command_buffer/service/gpu_switches.h" 132 #include "gpu/command_buffer/service/gpu_switches.h"
132 #include "ipc/ipc_channel.h" 133 #include "ipc/ipc_channel.h"
133 #include "ipc/ipc_logging.h" 134 #include "ipc/ipc_logging.h"
134 #include "ipc/ipc_switches.h" 135 #include "ipc/ipc_switches.h"
135 #include "media/base/media_switches.h" 136 #include "media/base/media_switches.h"
136 #include "net/url_request/url_request_context_getter.h" 137 #include "net/url_request/url_request_context_getter.h"
137 #include "ppapi/shared_impl/ppapi_switches.h" 138 #include "ppapi/shared_impl/ppapi_switches.h"
138 #include "ui/base/ui_base_switches.h" 139 #include "ui/base/ui_base_switches.h"
139 #include "ui/events/event_switches.h" 140 #include "ui/events/event_switches.h"
140 #include "ui/gfx/switches.h" 141 #include "ui/gfx/switches.h"
141 #include "ui/gl/gl_switches.h" 142 #include "ui/gl/gl_switches.h"
142 #include "webkit/browser/fileapi/sandbox_file_system_backend.h" 143 #include "webkit/browser/fileapi/sandbox_file_system_backend.h"
143 #include "webkit/common/resource_type.h" 144 #include "webkit/common/resource_type.h"
144 145
145 #if defined(OS_WIN) 146 #if defined(OS_WIN)
146 #include "base/win/scoped_com_initializer.h" 147 #include "base/win/scoped_com_initializer.h"
147 #include "content/common/font_cache_dispatcher_win.h" 148 #include "content/common/font_cache_dispatcher_win.h"
148 #include "content/common/sandbox_win.h" 149 #include "content/common/sandbox_win.h"
149 #include "content/public/common/sandboxed_process_launcher_delegate.h"
150 #endif 150 #endif
151 151
152 #if defined(ENABLE_WEBRTC) 152 #if defined(ENABLE_WEBRTC)
153 #include "content/browser/media/webrtc_internals.h" 153 #include "content/browser/media/webrtc_internals.h"
154 #include "content/browser/renderer_host/media/webrtc_identity_service_host.h" 154 #include "content/browser/renderer_host/media/webrtc_identity_service_host.h"
155 #include "content/common/media/media_stream_messages.h" 155 #include "content/common/media/media_stream_messages.h"
156 #endif 156 #endif
157 157
158 #include "third_party/skia/include/core/SkBitmap.h" 158 #include "third_party/skia/include/core/SkBitmap.h"
159 159
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 DCHECK(context); 278 DCHECK(context);
279 SiteProcessMap* map = static_cast<SiteProcessMap*>( 279 SiteProcessMap* map = static_cast<SiteProcessMap*>(
280 context->GetUserData(kSiteProcessMapKeyName)); 280 context->GetUserData(kSiteProcessMapKeyName));
281 if (!map) { 281 if (!map) {
282 map = new SiteProcessMap(); 282 map = new SiteProcessMap();
283 context->SetUserData(kSiteProcessMapKeyName, map); 283 context->SetUserData(kSiteProcessMapKeyName, map);
284 } 284 }
285 return map; 285 return map;
286 } 286 }
287 287
288 #if defined(OS_WIN)
289 // NOTE: changes to this class need to be reviewed by the security team. 288 // NOTE: changes to this class need to be reviewed by the security team.
290 class RendererSandboxedProcessLauncherDelegate 289 class RendererSandboxedProcessLauncherDelegate
291 : public content::SandboxedProcessLauncherDelegate { 290 : public content::SandboxedProcessLauncherDelegate {
292 public: 291 public:
293 RendererSandboxedProcessLauncherDelegate() {} 292 RendererSandboxedProcessLauncherDelegate(IPC::ChannelProxy* channel)
293 #if defined(OS_POSIX)
294 : ipc_fd_(channel->TakeClientFileDescriptor())
295 #endif // OS_POSIX
296 {}
297
294 virtual ~RendererSandboxedProcessLauncherDelegate() {} 298 virtual ~RendererSandboxedProcessLauncherDelegate() {}
295 299
300 #if defined(OS_WIN)
296 virtual void PreSpawnTarget(sandbox::TargetPolicy* policy, 301 virtual void PreSpawnTarget(sandbox::TargetPolicy* policy,
297 bool* success) { 302 bool* success) {
298 AddBaseHandleClosePolicy(policy); 303 AddBaseHandleClosePolicy(policy);
299 GetContentClient()->browser()->PreSpawnRenderer(policy, success); 304 GetContentClient()->browser()->PreSpawnRenderer(policy, success);
300 } 305 }
306
307 #elif defined(OS_POSIX)
308 virtual bool ShouldUseZygote() OVERRIDE {
309 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
310 CommandLine::StringType renderer_prefix =
311 browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix);
312 return renderer_prefix.empty();
313 }
314 virtual int GetIpcFd() OVERRIDE {
315 return ipc_fd_;
316 }
317 #endif // OS_WIN
318
319 private:
320 #if defined(OS_POSIX)
321 int ipc_fd_;
322 #endif // OS_POSIX
301 }; 323 };
302 #endif // OS_WIN
303 324
304 } // namespace 325 } // namespace
305 326
306 RendererMainThreadFactoryFunction g_renderer_main_thread_factory = NULL; 327 RendererMainThreadFactoryFunction g_renderer_main_thread_factory = NULL;
307 328
308 void RenderProcessHost::RegisterRendererMainThreadFactory( 329 void RenderProcessHost::RegisterRendererMainThreadFactory(
309 RendererMainThreadFactoryFunction create) { 330 RendererMainThreadFactoryFunction create) {
310 g_renderer_main_thread_factory = create; 331 g_renderer_main_thread_factory = create;
311 } 332 }
312 333
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 CommandLine* cmd_line = new CommandLine(renderer_path); 580 CommandLine* cmd_line = new CommandLine(renderer_path);
560 if (!renderer_prefix.empty()) 581 if (!renderer_prefix.empty())
561 cmd_line->PrependWrapper(renderer_prefix); 582 cmd_line->PrependWrapper(renderer_prefix);
562 AppendRendererCommandLine(cmd_line); 583 AppendRendererCommandLine(cmd_line);
563 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); 584 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id);
564 585
565 // Spawn the child process asynchronously to avoid blocking the UI thread. 586 // Spawn the child process asynchronously to avoid blocking the UI thread.
566 // As long as there's no renderer prefix, we can use the zygote process 587 // As long as there's no renderer prefix, we can use the zygote process
567 // at this stage. 588 // at this stage.
568 child_process_launcher_.reset(new ChildProcessLauncher( 589 child_process_launcher_.reset(new ChildProcessLauncher(
569 #if defined(OS_WIN) 590 new RendererSandboxedProcessLauncherDelegate(channel_.get()),
570 new RendererSandboxedProcessLauncherDelegate,
571 false,
572 #elif defined(OS_POSIX)
573 renderer_prefix.empty(),
574 base::EnvironmentMap(),
575 channel_->TakeClientFileDescriptor(),
576 #endif
577 cmd_line, 591 cmd_line,
578 GetID(), 592 GetID(),
579 this)); 593 this));
580 594
581 fast_shutdown_started_ = false; 595 fast_shutdown_started_ = false;
582 } 596 }
583 597
584 if (!gpu_observer_registered_) { 598 if (!gpu_observer_registered_) {
585 gpu_observer_registered_ = true; 599 gpu_observer_registered_ = true;
586 GpuDataManagerImpl::GetInstance()->AddObserver(this); 600 GpuDataManagerImpl::GetInstance()->AddObserver(this);
(...skipping 1490 matching lines...) Expand 10 before | Expand all | Expand 10 after
2077 return; 2091 return;
2078 Send(new MediaStreamMsg_EnableAecDump(file_for_transit)); 2092 Send(new MediaStreamMsg_EnableAecDump(file_for_transit));
2079 } 2093 }
2080 2094
2081 void RenderProcessHostImpl::SendDisableAecDumpToRenderer() { 2095 void RenderProcessHostImpl::SendDisableAecDumpToRenderer() {
2082 Send(new MediaStreamMsg_DisableAecDump()); 2096 Send(new MediaStreamMsg_DisableAecDump());
2083 } 2097 }
2084 #endif 2098 #endif
2085 2099
2086 } // namespace content 2100 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698