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

Side by Side Diff: ppapi/nacl_irt/plugin_startup.cc

Issue 2025763002: Use ChannelMojo in Pepper and NaCl processes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojo-utility-channel-mojo
Patch Set: iujbhirtughfbnjrthiubj Created 4 years, 6 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
« no previous file with comments | « ppapi/nacl_irt/plugin_startup.h ('k') | ppapi/proxy/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "ppapi/nacl_irt/plugin_startup.h" 5 #include "ppapi/nacl_irt/plugin_startup.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_descriptor_posix.h" 8 #include "base/file_descriptor_posix.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/single_thread_task_runner.h" 11 #include "base/single_thread_task_runner.h"
12 #include "base/synchronization/waitable_event.h" 12 #include "base/synchronization/waitable_event.h"
13 #include "base/threading/thread.h" 13 #include "base/threading/thread.h"
14 #include "ipc/ipc_channel_handle.h" 14 #include "ipc/ipc_channel_handle.h"
15 #include "ipc/mojo/scoped_ipc_support.h"
16 #include "mojo/edk/embedder/embedder.h"
15 #include "ppapi/nacl_irt/manifest_service.h" 17 #include "ppapi/nacl_irt/manifest_service.h"
16 #include "ppapi/shared_impl/ppb_audio_shared.h" 18 #include "ppapi/shared_impl/ppb_audio_shared.h"
17 19
18 namespace ppapi { 20 namespace ppapi {
19 namespace { 21 namespace {
20 22
21 int g_nacl_browser_ipc_fd = -1; 23 int g_nacl_browser_ipc_fd = -1;
22 int g_nacl_renderer_ipc_fd = -1; 24 int g_nacl_renderer_ipc_fd = -1;
23 int g_manifest_service_fd = -1; 25 int g_manifest_service_fd = -1;
26 int g_nacl_browser_mojo_fd = -1;
24 27
25 base::WaitableEvent* g_shutdown_event = NULL; 28 base::WaitableEvent* g_shutdown_event = NULL;
26 base::Thread* g_io_thread = NULL; 29 base::Thread* g_io_thread = NULL;
27 ManifestService* g_manifest_service = NULL; 30 ManifestService* g_manifest_service = NULL;
28 31
29 // Creates the manifest service on IO thread so that its Listener's thread and 32 // Creates the manifest service on IO thread so that its Listener's thread and
30 // IO thread are shared. Upon completion of the manifest service creation, 33 // IO thread are shared. Upon completion of the manifest service creation,
31 // event is signaled. 34 // event is signaled.
32 void StartUpManifestServiceOnIOThread(base::WaitableEvent* event) { 35 void StartUpManifestServiceOnIOThread(base::WaitableEvent* event) {
33 // The start up must be called only once. 36 // The start up must be called only once.
34 DCHECK(!g_manifest_service); 37 DCHECK(!g_manifest_service);
35 // manifest_service_fd must be set. 38 // manifest_service_fd must be set.
36 DCHECK_NE(g_manifest_service_fd, -1); 39 DCHECK_NE(g_manifest_service_fd, -1);
37 // IOThread and shutdown event must be initialized in advance. 40 // IOThread and shutdown event must be initialized in advance.
38 DCHECK(g_io_thread); 41 DCHECK(g_io_thread);
39 DCHECK(g_shutdown_event); 42 DCHECK(g_shutdown_event);
40 43
41 g_manifest_service = new ManifestService( 44 g_manifest_service = new ManifestService(
42 IPC::ChannelHandle("NaCl IPC", 45 IPC::ChannelHandle("NaCl IPC",
43 base::FileDescriptor(g_manifest_service_fd, false)), 46 base::FileDescriptor(g_manifest_service_fd, false)),
44 g_io_thread->task_runner(), g_shutdown_event); 47 g_io_thread->task_runner(), g_shutdown_event);
45 event->Signal(); 48 event->Signal();
46 } 49 }
47 50
48 } // namespace 51 } // namespace
49 52
50 void SetIPCFileDescriptors( 53 void SetIPCFileDescriptors(
51 int browser_ipc_fd, int renderer_ipc_fd, int manifest_service_fd) { 54 int browser_ipc_fd, int renderer_ipc_fd, int manifest_service_fd,
55 int browser_mojo_fd) {
52 // The initialization must be only once. 56 // The initialization must be only once.
53 DCHECK_EQ(g_nacl_browser_ipc_fd, -1); 57 DCHECK_EQ(g_nacl_browser_ipc_fd, -1);
54 DCHECK_EQ(g_nacl_renderer_ipc_fd, -1); 58 DCHECK_EQ(g_nacl_renderer_ipc_fd, -1);
55 DCHECK_EQ(g_manifest_service_fd, -1); 59 DCHECK_EQ(g_manifest_service_fd, -1);
60 DCHECK_EQ(g_nacl_browser_mojo_fd, -1);
56 g_nacl_browser_ipc_fd = browser_ipc_fd; 61 g_nacl_browser_ipc_fd = browser_ipc_fd;
57 g_nacl_renderer_ipc_fd = renderer_ipc_fd; 62 g_nacl_renderer_ipc_fd = renderer_ipc_fd;
58 g_manifest_service_fd = manifest_service_fd; 63 g_manifest_service_fd = manifest_service_fd;
64 g_nacl_browser_mojo_fd = browser_mojo_fd;
59 } 65 }
60 66
61 void StartUpPlugin() { 67 void StartUpPlugin() {
62 // The start up must be called only once. 68 // The start up must be called only once.
63 DCHECK(!g_shutdown_event); 69 DCHECK(!g_shutdown_event);
64 DCHECK(!g_io_thread); 70 DCHECK(!g_io_thread);
65 71
66 g_shutdown_event = new base::WaitableEvent(true, false); 72 g_shutdown_event = new base::WaitableEvent(true, false);
67 g_io_thread = new base::Thread("Chrome_NaClIOThread"); 73 g_io_thread = new base::Thread("Chrome_NaClIOThread");
68 g_io_thread->StartWithOptions( 74 g_io_thread->StartWithOptions(
69 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); 75 base::Thread::Options(base::MessageLoop::TYPE_IO, 0));
70 76
77 // Initialize Mojo.
78 mojo::edk::Init();
79 IPC::ScopedIPCSupport scoped_ipc_support(g_io_thread->task_runner());
80 if (g_nacl_browser_mojo_fd != -1) {
81 LOG(ERROR) << "Setting up Mojo channel in NaCl";
82 // mojo::edk::SetParentPipeHandle(mojo::edk::ScopedPlatformHandle(
83 // mojo::edk::PlatformHandle(g_nacl_browser_mojo_fd)));
84 }
85
71 if (g_manifest_service_fd != -1) { 86 if (g_manifest_service_fd != -1) {
72 // Manifest service must be created on IOThread so that the main message 87 // Manifest service must be created on IOThread so that the main message
73 // handling will be done on the thread, which has a message loop 88 // handling will be done on the thread, which has a message loop
74 // even before irt_ppapi_start invocation. 89 // even before irt_ppapi_start invocation.
75 // TODO(hidehiko,dmichael): This works, but is probably not well designed 90 // TODO(hidehiko,dmichael): This works, but is probably not well designed
76 // usage. Once a better approach is made, replace this by that way. 91 // usage. Once a better approach is made, replace this by that way.
77 // (crbug.com/364241). 92 // (crbug.com/364241).
78 base::WaitableEvent event(true, false); 93 base::WaitableEvent event(true, false);
79 g_io_thread->task_runner()->PostTask( 94 g_io_thread->task_runner()->PostTask(
80 FROM_HERE, base::Bind(StartUpManifestServiceOnIOThread, &event)); 95 FROM_HERE, base::Bind(StartUpManifestServiceOnIOThread, &event));
(...skipping 25 matching lines...) Expand all
106 // The IOThread must be initialized in advance. 121 // The IOThread must be initialized in advance.
107 DCHECK(g_io_thread); 122 DCHECK(g_io_thread);
108 return g_io_thread; 123 return g_io_thread;
109 } 124 }
110 125
111 ManifestService* GetManifestService() { 126 ManifestService* GetManifestService() {
112 return g_manifest_service; 127 return g_manifest_service;
113 } 128 }
114 129
115 } // namespace ppapi 130 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/nacl_irt/plugin_startup.h ('k') | ppapi/proxy/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698