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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/render_process_host_impl.cc
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
index 0ef9339e298f5330e551709f6a85d9be3c1d1fa5..b604ddcc9e6947a8782a69dfd12760b191005696 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -138,6 +138,7 @@
#include "media/base/media_switches.h"
#include "net/url_request/url_request_context_getter.h"
#include "ppapi/shared_impl/ppapi_switches.h"
+#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/ui_base_switches.h"
#include "ui/events/event_switches.h"
#include "ui/gfx/switches.h"
@@ -158,7 +159,11 @@
#include "content/common/media/media_stream_messages.h"
#endif
-#include "third_party/skia/include/core/SkBitmap.h"
+#if defined(USE_MOJO)
+#include "content/common/mojo/mojo_channel_init.h"
+#include "content/common/mojo/mojo_messages.h"
+#include "mojo/system/embedder/platform_channel_pair.h"
+#endif
extern bool g_exited_main_message_loop;
@@ -325,6 +330,17 @@ class RendererSandboxedProcessLauncherDelegate
#endif // OS_POSIX
};
+#if defined(USE_MOJO)
+base::PlatformFile PlatformFileFromScopedPlatformHandle(
+ mojo::embedder::ScopedPlatformHandle handle) {
+#if defined(OS_POSIX)
+ return handle.release().fd;
+#elif defined(OS_WIN)
+ return handle.release().handle;
+#endif
+}
+#endif
+
} // namespace
RendererMainThreadFactoryFunction g_renderer_main_thread_factory = NULL;
@@ -422,9 +438,9 @@ RenderProcessHostImpl::RenderProcessHostImpl(
within_process_died_observer_(false),
power_monitor_broadcaster_(this),
geolocation_dispatcher_host_(NULL),
- weak_factory_(this),
screen_orientation_dispatcher_host_(NULL),
- worker_ref_count_(0) {
+ worker_ref_count_(0),
+ weak_factory_(this) {
widget_helper_ = new RenderWidgetHelper();
ChildProcessSecurityPolicyImpl::GetInstance()->Add(GetID());
@@ -2138,4 +2154,26 @@ void RenderProcessHostImpl::DecrementWorkerRefCount() {
Cleanup();
}
+#if defined(USE_MOJO)
+void RenderProcessHostImpl::CreateMojoChannel() {
+ if (mojo_channel_init_.get())
+ return;
+
+ mojo::embedder::PlatformChannelPair channel_pair;
+ mojo_channel_init_.reset(new MojoChannelInit);
+ mojo_channel_init_->Init(
+ PlatformFileFromScopedPlatformHandle(channel_pair.PassServerHandle()),
+ BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
+ if (mojo_channel_init_->is_handle_valid()) {
+ base::ProcessHandle process_handle = run_renderer_in_process() ?
+ base::Process::Current().handle() :
+ child_process_launcher_->GetHandle();
+ base::PlatformFile client_file =
+ PlatformFileFromScopedPlatformHandle(channel_pair.PassClientHandle());
+ Send(new MojoMsg_ChannelCreated(
+ IPC::GetFileHandleForProcess(client_file, process_handle, true)));
+ }
+}
+#endif
+
} // namespace content
« 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