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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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/sandboxed_process_launcher_delegate.h" |
133 #include "content/public/common/url_constants.h" | 133 #include "content/public/common/url_constants.h" |
134 #include "gpu/command_buffer/service/gpu_switches.h" | 134 #include "gpu/command_buffer/service/gpu_switches.h" |
135 #include "ipc/ipc_channel.h" | 135 #include "ipc/ipc_channel.h" |
136 #include "ipc/ipc_logging.h" | 136 #include "ipc/ipc_logging.h" |
137 #include "ipc/ipc_switches.h" | 137 #include "ipc/ipc_switches.h" |
138 #include "media/base/media_switches.h" | 138 #include "media/base/media_switches.h" |
139 #include "net/url_request/url_request_context_getter.h" | 139 #include "net/url_request/url_request_context_getter.h" |
140 #include "ppapi/shared_impl/ppapi_switches.h" | 140 #include "ppapi/shared_impl/ppapi_switches.h" |
141 #include "third_party/skia/include/core/SkBitmap.h" | |
142 #include "ui/base/ui_base_switches.h" | 141 #include "ui/base/ui_base_switches.h" |
143 #include "ui/events/event_switches.h" | 142 #include "ui/events/event_switches.h" |
144 #include "ui/gfx/switches.h" | 143 #include "ui/gfx/switches.h" |
145 #include "ui/gl/gl_switches.h" | 144 #include "ui/gl/gl_switches.h" |
146 #include "webkit/browser/fileapi/sandbox_file_system_backend.h" | 145 #include "webkit/browser/fileapi/sandbox_file_system_backend.h" |
147 #include "webkit/common/resource_type.h" | 146 #include "webkit/common/resource_type.h" |
148 | 147 |
149 #if defined(OS_WIN) | 148 #if defined(OS_WIN) |
150 #include "base/win/scoped_com_initializer.h" | 149 #include "base/win/scoped_com_initializer.h" |
151 #include "content/common/font_cache_dispatcher_win.h" | 150 #include "content/common/font_cache_dispatcher_win.h" |
152 #include "content/common/sandbox_win.h" | 151 #include "content/common/sandbox_win.h" |
153 #endif | 152 #endif |
154 | 153 |
155 #if defined(ENABLE_WEBRTC) | 154 #if defined(ENABLE_WEBRTC) |
156 #include "content/browser/media/webrtc_internals.h" | 155 #include "content/browser/media/webrtc_internals.h" |
157 #include "content/browser/renderer_host/media/media_stream_track_metrics_host.h" | 156 #include "content/browser/renderer_host/media/media_stream_track_metrics_host.h" |
158 #include "content/browser/renderer_host/media/webrtc_identity_service_host.h" | 157 #include "content/browser/renderer_host/media/webrtc_identity_service_host.h" |
159 #include "content/common/media/media_stream_messages.h" | 158 #include "content/common/media/media_stream_messages.h" |
160 #endif | 159 #endif |
161 | 160 |
162 // TODO(sky): remove, see header for details. | 161 #include "third_party/skia/include/core/SkBitmap.h" |
163 #if !defined(OS_MACOSX) | |
164 #include "content/common/mojo/mojo_channel_init.h" | |
165 #include "content/common/mojo/mojo_messages.h" | |
166 #include "mojo/system/embedder/platform_channel_pair.h" | |
167 #endif | |
168 | 162 |
169 extern bool g_exited_main_message_loop; | 163 extern bool g_exited_main_message_loop; |
170 | 164 |
171 static const char* kSiteProcessMapKeyName = "content_site_process_map"; | 165 static const char* kSiteProcessMapKeyName = "content_site_process_map"; |
172 | 166 |
173 namespace content { | 167 namespace content { |
174 namespace { | 168 namespace { |
175 | 169 |
176 void CacheShaderInfo(int32 id, base::FilePath path) { | 170 void CacheShaderInfo(int32 id, base::FilePath path) { |
177 ShaderCacheFactory::GetInstance()->SetCacheInfo(id, path); | 171 ShaderCacheFactory::GetInstance()->SetCacheInfo(id, path); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 return ipc_fd_; | 318 return ipc_fd_; |
325 } | 319 } |
326 #endif // OS_WIN | 320 #endif // OS_WIN |
327 | 321 |
328 private: | 322 private: |
329 #if defined(OS_POSIX) | 323 #if defined(OS_POSIX) |
330 int ipc_fd_; | 324 int ipc_fd_; |
331 #endif // OS_POSIX | 325 #endif // OS_POSIX |
332 }; | 326 }; |
333 | 327 |
334 // TODO(sky): remove, see header for details. | |
335 #if !defined(OS_MACOSX) | |
336 base::PlatformFile PlatformFileFromScopedPlatformHandle( | |
337 mojo::embedder::ScopedPlatformHandle handle) { | |
338 #if defined(OS_POSIX) | |
339 return handle.release().fd; | |
340 #elif defined(OS_WIN) | |
341 return handle.release().handle; | |
342 #endif | |
343 } | |
344 #endif | |
345 | |
346 } // namespace | 328 } // namespace |
347 | 329 |
348 RendererMainThreadFactoryFunction g_renderer_main_thread_factory = NULL; | 330 RendererMainThreadFactoryFunction g_renderer_main_thread_factory = NULL; |
349 | 331 |
350 void RenderProcessHost::RegisterRendererMainThreadFactory( | 332 void RenderProcessHost::RegisterRendererMainThreadFactory( |
351 RendererMainThreadFactoryFunction create) { | 333 RendererMainThreadFactoryFunction create) { |
352 g_renderer_main_thread_factory = create; | 334 g_renderer_main_thread_factory = create; |
353 } | 335 } |
354 | 336 |
355 base::MessageLoop* g_in_process_thread; | 337 base::MessageLoop* g_in_process_thread; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 storage_partition_impl_(storage_partition_impl), | 415 storage_partition_impl_(storage_partition_impl), |
434 sudden_termination_allowed_(true), | 416 sudden_termination_allowed_(true), |
435 ignore_input_events_(false), | 417 ignore_input_events_(false), |
436 supports_browser_plugin_(supports_browser_plugin), | 418 supports_browser_plugin_(supports_browser_plugin), |
437 is_guest_(is_guest), | 419 is_guest_(is_guest), |
438 gpu_observer_registered_(false), | 420 gpu_observer_registered_(false), |
439 delayed_cleanup_needed_(false), | 421 delayed_cleanup_needed_(false), |
440 within_process_died_observer_(false), | 422 within_process_died_observer_(false), |
441 power_monitor_broadcaster_(this), | 423 power_monitor_broadcaster_(this), |
442 geolocation_dispatcher_host_(NULL), | 424 geolocation_dispatcher_host_(NULL), |
| 425 weak_factory_(this), |
443 screen_orientation_dispatcher_host_(NULL), | 426 screen_orientation_dispatcher_host_(NULL), |
444 worker_ref_count_(0), | 427 worker_ref_count_(0) { |
445 weak_factory_(this) { | |
446 widget_helper_ = new RenderWidgetHelper(); | 428 widget_helper_ = new RenderWidgetHelper(); |
447 | 429 |
448 ChildProcessSecurityPolicyImpl::GetInstance()->Add(GetID()); | 430 ChildProcessSecurityPolicyImpl::GetInstance()->Add(GetID()); |
449 | 431 |
450 CHECK(!g_exited_main_message_loop); | 432 CHECK(!g_exited_main_message_loop); |
451 RegisterHost(GetID(), this); | 433 RegisterHost(GetID(), this); |
452 g_all_hosts.Get().set_check_on_null_data(true); | 434 g_all_hosts.Get().set_check_on_null_data(true); |
453 // Initialize |child_process_activity_time_| to a reasonable value. | 435 // Initialize |child_process_activity_time_| to a reasonable value. |
454 mark_child_process_activity_time(); | 436 mark_child_process_activity_time(); |
455 | 437 |
(...skipping 1692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2148 } | 2130 } |
2149 | 2131 |
2150 void RenderProcessHostImpl::DecrementWorkerRefCount() { | 2132 void RenderProcessHostImpl::DecrementWorkerRefCount() { |
2151 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 2133 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
2152 DCHECK_GT(worker_ref_count_, 0); | 2134 DCHECK_GT(worker_ref_count_, 0); |
2153 --worker_ref_count_; | 2135 --worker_ref_count_; |
2154 if (worker_ref_count_ == 0) | 2136 if (worker_ref_count_ == 0) |
2155 Cleanup(); | 2137 Cleanup(); |
2156 } | 2138 } |
2157 | 2139 |
2158 void RenderProcessHostImpl::CreateMojoChannel() { | |
2159 // TODO(sky): remove, see header for details. | |
2160 #if !defined(OS_MACOSX) | |
2161 if (mojo_channel_init_.get()) | |
2162 return; | |
2163 | |
2164 mojo::embedder::PlatformChannelPair channel_pair; | |
2165 mojo_channel_init_.reset(new MojoChannelInit); | |
2166 mojo_channel_init_->Init( | |
2167 PlatformFileFromScopedPlatformHandle(channel_pair.PassServerHandle()), | |
2168 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | |
2169 if (mojo_channel_init_->is_handle_valid()) { | |
2170 base::ProcessHandle process_handle = run_renderer_in_process() ? | |
2171 base::Process::Current().handle() : | |
2172 child_process_launcher_->GetHandle(); | |
2173 base::PlatformFile client_file = | |
2174 PlatformFileFromScopedPlatformHandle(channel_pair.PassClientHandle()); | |
2175 Send(new MojoMsg_ChannelCreated( | |
2176 IPC::GetFileHandleForProcess(client_file, process_handle, true))); | |
2177 } | |
2178 #endif | |
2179 } | |
2180 | |
2181 } // namespace content | 2140 } // namespace content |
OLD | NEW |