OLD | NEW |
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 "ppapi/nacl_irt/manifest_service.h" | 15 #include "ppapi/nacl_irt/manifest_service.h" |
16 #include "ppapi/shared_impl/ppb_audio_shared.h" | 16 #include "ppapi/shared_impl/ppb_audio_shared.h" |
17 | 17 |
18 namespace ppapi { | 18 namespace ppapi { |
19 namespace { | 19 namespace { |
20 | 20 |
21 IPC::ChannelHandle* g_nacl_browser_ipc_handle = nullptr; | 21 IPC::ChannelHandle* g_nacl_browser_ipc_handle = nullptr; |
22 IPC::ChannelHandle* g_nacl_renderer_ipc_handle = nullptr; | 22 IPC::ChannelHandle* g_nacl_renderer_ipc_handle = nullptr; |
23 IPC::ChannelHandle* g_manifest_service_handle = nullptr; | 23 IPC::ChannelHandle* g_manifest_service_handle = nullptr; |
24 | 24 |
25 base::WaitableEvent* g_shutdown_event = NULL; | 25 base::WaitableEvent* g_shutdown_event = NULL; |
26 base::Thread* g_io_thread = NULL; | 26 base::Thread* g_io_thread = NULL; |
27 ManifestService* g_manifest_service = NULL; | 27 ManifestService* g_manifest_service = NULL; |
28 | 28 |
29 bool IsValidChannelHandle(IPC::ChannelHandle* handle) { | 29 bool IsValidChannelHandle(IPC::ChannelHandle* handle) { |
30 // ChannelMojo not yet supported. | 30 // In SFI mode the underlying handle is wrapped by a NaClIPCAdapter, which is |
31 return handle && handle->socket.fd != -1 && !handle->mojo_handle.is_valid(); | 31 // exposed as an FD. Otherwise, the handle is the underlying mojo message |
| 32 // pipe. |
| 33 return handle && |
| 34 #if defined(OS_NACL_SFI) |
| 35 handle->socket.fd != -1; |
| 36 #else |
| 37 handle->is_mojo_channel_handle(); |
| 38 #endif |
32 } | 39 } |
33 | 40 |
34 // Creates the manifest service on IO thread so that its Listener's thread and | 41 // Creates the manifest service on IO thread so that its Listener's thread and |
35 // IO thread are shared. Upon completion of the manifest service creation, | 42 // IO thread are shared. Upon completion of the manifest service creation, |
36 // event is signaled. | 43 // event is signaled. |
37 void StartUpManifestServiceOnIOThread(base::WaitableEvent* event) { | 44 void StartUpManifestServiceOnIOThread(base::WaitableEvent* event) { |
38 // The start up must be called only once. | 45 // The start up must be called only once. |
39 DCHECK(!g_manifest_service); | 46 DCHECK(!g_manifest_service); |
40 // manifest_service_handle must be set. | 47 // manifest_service_handle must be set. |
41 DCHECK(IsValidChannelHandle(g_manifest_service_handle)); | 48 DCHECK(IsValidChannelHandle(g_manifest_service_handle)); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 // The IOThread must be initialized in advance. | 122 // The IOThread must be initialized in advance. |
116 DCHECK(g_io_thread); | 123 DCHECK(g_io_thread); |
117 return g_io_thread; | 124 return g_io_thread; |
118 } | 125 } |
119 | 126 |
120 ManifestService* GetManifestService() { | 127 ManifestService* GetManifestService() { |
121 return g_manifest_service; | 128 return g_manifest_service; |
122 } | 129 } |
123 | 130 |
124 } // namespace ppapi | 131 } // namespace ppapi |
OLD | NEW |