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

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

Issue 195993010: Adds the ability for the renderer to create the mojo channel (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: use_mojo 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 | Annotate | Revision Log
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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
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"
141 #include "ui/base/ui_base_switches.h" 142 #include "ui/base/ui_base_switches.h"
142 #include "ui/events/event_switches.h" 143 #include "ui/events/event_switches.h"
143 #include "ui/gfx/switches.h" 144 #include "ui/gfx/switches.h"
144 #include "ui/gl/gl_switches.h" 145 #include "ui/gl/gl_switches.h"
145 #include "webkit/browser/fileapi/sandbox_file_system_backend.h" 146 #include "webkit/browser/fileapi/sandbox_file_system_backend.h"
146 #include "webkit/common/resource_type.h" 147 #include "webkit/common/resource_type.h"
147 148
148 #if defined(OS_WIN) 149 #if defined(OS_WIN)
149 #include "base/win/scoped_com_initializer.h" 150 #include "base/win/scoped_com_initializer.h"
150 #include "content/common/font_cache_dispatcher_win.h" 151 #include "content/common/font_cache_dispatcher_win.h"
151 #include "content/common/sandbox_win.h" 152 #include "content/common/sandbox_win.h"
152 #endif 153 #endif
153 154
154 #if defined(ENABLE_WEBRTC) 155 #if defined(ENABLE_WEBRTC)
155 #include "content/browser/media/webrtc_internals.h" 156 #include "content/browser/media/webrtc_internals.h"
156 #include "content/browser/renderer_host/media/media_stream_track_metrics_host.h" 157 #include "content/browser/renderer_host/media/media_stream_track_metrics_host.h"
157 #include "content/browser/renderer_host/media/webrtc_identity_service_host.h" 158 #include "content/browser/renderer_host/media/webrtc_identity_service_host.h"
158 #include "content/common/media/media_stream_messages.h" 159 #include "content/common/media/media_stream_messages.h"
159 #endif 160 #endif
160 161
161 #include "third_party/skia/include/core/SkBitmap.h" 162 #if defined(USE_MOJO)
163 #include "content/common/mojo/mojo_channel_init.h"
164 #include "content/common/mojo/mojo_messages.h"
165 #include "mojo/system/embedder/platform_channel_pair.h"
166 #endif
162 167
163 extern bool g_exited_main_message_loop; 168 extern bool g_exited_main_message_loop;
164 169
165 static const char* kSiteProcessMapKeyName = "content_site_process_map"; 170 static const char* kSiteProcessMapKeyName = "content_site_process_map";
166 171
167 namespace content { 172 namespace content {
168 namespace { 173 namespace {
169 174
170 void CacheShaderInfo(int32 id, base::FilePath path) { 175 void CacheShaderInfo(int32 id, base::FilePath path) {
171 ShaderCacheFactory::GetInstance()->SetCacheInfo(id, path); 176 ShaderCacheFactory::GetInstance()->SetCacheInfo(id, path);
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 return ipc_fd_; 323 return ipc_fd_;
319 } 324 }
320 #endif // OS_WIN 325 #endif // OS_WIN
321 326
322 private: 327 private:
323 #if defined(OS_POSIX) 328 #if defined(OS_POSIX)
324 int ipc_fd_; 329 int ipc_fd_;
325 #endif // OS_POSIX 330 #endif // OS_POSIX
326 }; 331 };
327 332
333 #if defined(USE_MOJO)
334 base::PlatformFile PlatformFileFromScopedPlatformHandle(
335 mojo::embedder::ScopedPlatformHandle handle) {
336 #if defined(OS_POSIX)
337 return handle.release().fd;
338 #elif defined(OS_WIN)
339 return handle.release().handle;
340 #endif
341 }
342 #endif
343
328 } // namespace 344 } // namespace
329 345
330 RendererMainThreadFactoryFunction g_renderer_main_thread_factory = NULL; 346 RendererMainThreadFactoryFunction g_renderer_main_thread_factory = NULL;
331 347
332 void RenderProcessHost::RegisterRendererMainThreadFactory( 348 void RenderProcessHost::RegisterRendererMainThreadFactory(
333 RendererMainThreadFactoryFunction create) { 349 RendererMainThreadFactoryFunction create) {
334 g_renderer_main_thread_factory = create; 350 g_renderer_main_thread_factory = create;
335 } 351 }
336 352
337 base::MessageLoop* g_in_process_thread; 353 base::MessageLoop* g_in_process_thread;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 storage_partition_impl_(storage_partition_impl), 431 storage_partition_impl_(storage_partition_impl),
416 sudden_termination_allowed_(true), 432 sudden_termination_allowed_(true),
417 ignore_input_events_(false), 433 ignore_input_events_(false),
418 supports_browser_plugin_(supports_browser_plugin), 434 supports_browser_plugin_(supports_browser_plugin),
419 is_guest_(is_guest), 435 is_guest_(is_guest),
420 gpu_observer_registered_(false), 436 gpu_observer_registered_(false),
421 delayed_cleanup_needed_(false), 437 delayed_cleanup_needed_(false),
422 within_process_died_observer_(false), 438 within_process_died_observer_(false),
423 power_monitor_broadcaster_(this), 439 power_monitor_broadcaster_(this),
424 geolocation_dispatcher_host_(NULL), 440 geolocation_dispatcher_host_(NULL),
425 weak_factory_(this),
426 screen_orientation_dispatcher_host_(NULL), 441 screen_orientation_dispatcher_host_(NULL),
427 worker_ref_count_(0) { 442 worker_ref_count_(0),
443 weak_factory_(this) {
428 widget_helper_ = new RenderWidgetHelper(); 444 widget_helper_ = new RenderWidgetHelper();
429 445
430 ChildProcessSecurityPolicyImpl::GetInstance()->Add(GetID()); 446 ChildProcessSecurityPolicyImpl::GetInstance()->Add(GetID());
431 447
432 CHECK(!g_exited_main_message_loop); 448 CHECK(!g_exited_main_message_loop);
433 RegisterHost(GetID(), this); 449 RegisterHost(GetID(), this);
434 g_all_hosts.Get().set_check_on_null_data(true); 450 g_all_hosts.Get().set_check_on_null_data(true);
435 // Initialize |child_process_activity_time_| to a reasonable value. 451 // Initialize |child_process_activity_time_| to a reasonable value.
436 mark_child_process_activity_time(); 452 mark_child_process_activity_time();
437 453
(...skipping 1693 matching lines...) Expand 10 before | Expand all | Expand 10 after
2131 } 2147 }
2132 2148
2133 void RenderProcessHostImpl::DecrementWorkerRefCount() { 2149 void RenderProcessHostImpl::DecrementWorkerRefCount() {
2134 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 2150 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
2135 DCHECK_GT(worker_ref_count_, 0); 2151 DCHECK_GT(worker_ref_count_, 0);
2136 --worker_ref_count_; 2152 --worker_ref_count_;
2137 if (worker_ref_count_ == 0) 2153 if (worker_ref_count_ == 0)
2138 Cleanup(); 2154 Cleanup();
2139 } 2155 }
2140 2156
2157 #if defined(USE_MOJO)
2158 void RenderProcessHostImpl::CreateMojoChannel() {
2159 if (mojo_channel_init_.get())
2160 return;
2161
2162 mojo::embedder::PlatformChannelPair channel_pair;
2163 mojo_channel_init_.reset(new MojoChannelInit);
2164 mojo_channel_init_->Init(
2165 PlatformFileFromScopedPlatformHandle(channel_pair.PassServerHandle()),
2166 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
2167 if (mojo_channel_init_->is_handle_valid()) {
2168 base::ProcessHandle process_handle = run_renderer_in_process() ?
2169 base::Process::Current().handle() :
2170 child_process_launcher_->GetHandle();
2171 base::PlatformFile client_file =
2172 PlatformFileFromScopedPlatformHandle(channel_pair.PassClientHandle());
2173 Send(new MojoMsg_ChannelCreated(
2174 IPC::GetFileHandleForProcess(client_file, process_handle, true)));
2175 }
2176 }
2177 #endif
2178
2141 } // namespace content 2179 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.h ('k') | content/common/content_message_generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698