OLD | NEW |
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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 #include "content/public/browser/render_process_host_observer.h" | 122 #include "content/public/browser/render_process_host_observer.h" |
123 #include "content/public/browser/render_widget_host.h" | 123 #include "content/public/browser/render_widget_host.h" |
124 #include "content/public/browser/render_widget_host_iterator.h" | 124 #include "content/public/browser/render_widget_host_iterator.h" |
125 #include "content/public/browser/resource_context.h" | 125 #include "content/public/browser/resource_context.h" |
126 #include "content/public/browser/user_metrics.h" | 126 #include "content/public/browser/user_metrics.h" |
127 #include "content/public/browser/worker_service.h" | 127 #include "content/public/browser/worker_service.h" |
128 #include "content/public/common/content_constants.h" | 128 #include "content/public/common/content_constants.h" |
129 #include "content/public/common/content_switches.h" | 129 #include "content/public/common/content_switches.h" |
130 #include "content/public/common/process_type.h" | 130 #include "content/public/common/process_type.h" |
131 #include "content/public/common/result_codes.h" | 131 #include "content/public/common/result_codes.h" |
| 132 #include "content/public/common/sandboxed_process_launcher_delegate.h" |
132 #include "content/public/common/url_constants.h" | 133 #include "content/public/common/url_constants.h" |
133 #include "gpu/command_buffer/service/gpu_switches.h" | 134 #include "gpu/command_buffer/service/gpu_switches.h" |
134 #include "ipc/ipc_channel.h" | 135 #include "ipc/ipc_channel.h" |
135 #include "ipc/ipc_logging.h" | 136 #include "ipc/ipc_logging.h" |
136 #include "ipc/ipc_switches.h" | 137 #include "ipc/ipc_switches.h" |
137 #include "media/base/media_switches.h" | 138 #include "media/base/media_switches.h" |
138 #include "net/url_request/url_request_context_getter.h" | 139 #include "net/url_request/url_request_context_getter.h" |
139 #include "ppapi/shared_impl/ppapi_switches.h" | 140 #include "ppapi/shared_impl/ppapi_switches.h" |
140 #include "ui/base/ui_base_switches.h" | 141 #include "ui/base/ui_base_switches.h" |
141 #include "ui/events/event_switches.h" | 142 #include "ui/events/event_switches.h" |
142 #include "ui/gfx/switches.h" | 143 #include "ui/gfx/switches.h" |
143 #include "ui/gl/gl_switches.h" | 144 #include "ui/gl/gl_switches.h" |
144 #include "webkit/browser/fileapi/sandbox_file_system_backend.h" | 145 #include "webkit/browser/fileapi/sandbox_file_system_backend.h" |
145 #include "webkit/common/resource_type.h" | 146 #include "webkit/common/resource_type.h" |
146 | 147 |
147 #if defined(OS_WIN) | 148 #if defined(OS_WIN) |
148 #include "base/win/scoped_com_initializer.h" | 149 #include "base/win/scoped_com_initializer.h" |
149 #include "content/common/font_cache_dispatcher_win.h" | 150 #include "content/common/font_cache_dispatcher_win.h" |
150 #include "content/common/sandbox_win.h" | 151 #include "content/common/sandbox_win.h" |
151 #include "content/public/common/sandboxed_process_launcher_delegate.h" | |
152 #endif | 152 #endif |
153 | 153 |
154 #if defined(ENABLE_WEBRTC) | 154 #if defined(ENABLE_WEBRTC) |
155 #include "content/browser/media/webrtc_internals.h" | 155 #include "content/browser/media/webrtc_internals.h" |
156 #include "content/browser/renderer_host/media/webrtc_identity_service_host.h" | 156 #include "content/browser/renderer_host/media/webrtc_identity_service_host.h" |
157 #include "content/common/media/media_stream_messages.h" | 157 #include "content/common/media/media_stream_messages.h" |
158 #endif | 158 #endif |
159 | 159 |
160 #include "third_party/skia/include/core/SkBitmap.h" | 160 #include "third_party/skia/include/core/SkBitmap.h" |
161 | 161 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 DCHECK(context); | 280 DCHECK(context); |
281 SiteProcessMap* map = static_cast<SiteProcessMap*>( | 281 SiteProcessMap* map = static_cast<SiteProcessMap*>( |
282 context->GetUserData(kSiteProcessMapKeyName)); | 282 context->GetUserData(kSiteProcessMapKeyName)); |
283 if (!map) { | 283 if (!map) { |
284 map = new SiteProcessMap(); | 284 map = new SiteProcessMap(); |
285 context->SetUserData(kSiteProcessMapKeyName, map); | 285 context->SetUserData(kSiteProcessMapKeyName, map); |
286 } | 286 } |
287 return map; | 287 return map; |
288 } | 288 } |
289 | 289 |
290 #if defined(OS_WIN) | |
291 // NOTE: changes to this class need to be reviewed by the security team. | 290 // NOTE: changes to this class need to be reviewed by the security team. |
292 class RendererSandboxedProcessLauncherDelegate | 291 class RendererSandboxedProcessLauncherDelegate |
293 : public content::SandboxedProcessLauncherDelegate { | 292 : public content::SandboxedProcessLauncherDelegate { |
294 public: | 293 public: |
295 RendererSandboxedProcessLauncherDelegate() {} | 294 RendererSandboxedProcessLauncherDelegate(IPC::ChannelProxy* channel) |
| 295 #if defined(OS_POSIX) |
| 296 : ipc_fd_(channel->TakeClientFileDescriptor()) |
| 297 #endif // OS_POSIX |
| 298 {} |
| 299 |
296 virtual ~RendererSandboxedProcessLauncherDelegate() {} | 300 virtual ~RendererSandboxedProcessLauncherDelegate() {} |
297 | 301 |
| 302 #if defined(OS_WIN) |
298 virtual void PreSpawnTarget(sandbox::TargetPolicy* policy, | 303 virtual void PreSpawnTarget(sandbox::TargetPolicy* policy, |
299 bool* success) { | 304 bool* success) { |
300 AddBaseHandleClosePolicy(policy); | 305 AddBaseHandleClosePolicy(policy); |
301 GetContentClient()->browser()->PreSpawnRenderer(policy, success); | 306 GetContentClient()->browser()->PreSpawnRenderer(policy, success); |
302 } | 307 } |
| 308 |
| 309 #elif defined(OS_POSIX) |
| 310 virtual bool ShouldUseZygote() OVERRIDE { |
| 311 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
| 312 CommandLine::StringType renderer_prefix = |
| 313 browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix); |
| 314 return renderer_prefix.empty(); |
| 315 } |
| 316 virtual int GetIpcFd() OVERRIDE { |
| 317 return ipc_fd_; |
| 318 } |
| 319 #endif // OS_WIN |
| 320 |
| 321 private: |
| 322 #if defined(OS_POSIX) |
| 323 int ipc_fd_; |
| 324 #endif // OS_POSIX |
303 }; | 325 }; |
304 #endif // OS_WIN | |
305 | 326 |
306 } // namespace | 327 } // namespace |
307 | 328 |
308 RendererMainThreadFactoryFunction g_renderer_main_thread_factory = NULL; | 329 RendererMainThreadFactoryFunction g_renderer_main_thread_factory = NULL; |
309 | 330 |
310 void RenderProcessHost::RegisterRendererMainThreadFactory( | 331 void RenderProcessHost::RegisterRendererMainThreadFactory( |
311 RendererMainThreadFactoryFunction create) { | 332 RendererMainThreadFactoryFunction create) { |
312 g_renderer_main_thread_factory = create; | 333 g_renderer_main_thread_factory = create; |
313 } | 334 } |
314 | 335 |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 CommandLine* cmd_line = new CommandLine(renderer_path); | 584 CommandLine* cmd_line = new CommandLine(renderer_path); |
564 if (!renderer_prefix.empty()) | 585 if (!renderer_prefix.empty()) |
565 cmd_line->PrependWrapper(renderer_prefix); | 586 cmd_line->PrependWrapper(renderer_prefix); |
566 AppendRendererCommandLine(cmd_line); | 587 AppendRendererCommandLine(cmd_line); |
567 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); | 588 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); |
568 | 589 |
569 // Spawn the child process asynchronously to avoid blocking the UI thread. | 590 // Spawn the child process asynchronously to avoid blocking the UI thread. |
570 // As long as there's no renderer prefix, we can use the zygote process | 591 // As long as there's no renderer prefix, we can use the zygote process |
571 // at this stage. | 592 // at this stage. |
572 child_process_launcher_.reset(new ChildProcessLauncher( | 593 child_process_launcher_.reset(new ChildProcessLauncher( |
573 #if defined(OS_WIN) | 594 new RendererSandboxedProcessLauncherDelegate(channel_.get()), |
574 new RendererSandboxedProcessLauncherDelegate, | |
575 false, | |
576 #elif defined(OS_POSIX) | |
577 renderer_prefix.empty(), | |
578 base::EnvironmentMap(), | |
579 channel_->TakeClientFileDescriptor(), | |
580 #endif | |
581 cmd_line, | 595 cmd_line, |
582 GetID(), | 596 GetID(), |
583 this)); | 597 this)); |
584 | 598 |
585 fast_shutdown_started_ = false; | 599 fast_shutdown_started_ = false; |
586 } | 600 } |
587 | 601 |
588 if (!gpu_observer_registered_) { | 602 if (!gpu_observer_registered_) { |
589 gpu_observer_registered_ = true; | 603 gpu_observer_registered_ = true; |
590 GpuDataManagerImpl::GetInstance()->AddObserver(this); | 604 GpuDataManagerImpl::GetInstance()->AddObserver(this); |
(...skipping 1521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2112 | 2126 |
2113 void RenderProcessHostImpl::DecrementWorkerRefCount() { | 2127 void RenderProcessHostImpl::DecrementWorkerRefCount() { |
2114 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 2128 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
2115 DCHECK_GT(worker_ref_count_, 0); | 2129 DCHECK_GT(worker_ref_count_, 0); |
2116 --worker_ref_count_; | 2130 --worker_ref_count_; |
2117 if (worker_ref_count_ == 0) | 2131 if (worker_ref_count_ == 0) |
2118 Cleanup(); | 2132 Cleanup(); |
2119 } | 2133 } |
2120 | 2134 |
2121 } // namespace content | 2135 } // namespace content |
OLD | NEW |