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 "mojo/edk/embedder/embedder.h" | |
16 #include "ppapi/nacl_irt/manifest_service.h" | 15 #include "ppapi/nacl_irt/manifest_service.h" |
17 #include "ppapi/shared_impl/ppb_audio_shared.h" | 16 #include "ppapi/shared_impl/ppb_audio_shared.h" |
18 | 17 |
19 namespace ppapi { | 18 namespace ppapi { |
20 namespace { | 19 namespace { |
21 | 20 |
22 IPC::ChannelHandle* g_nacl_browser_ipc_handle = nullptr; | 21 IPC::ChannelHandle* g_nacl_browser_ipc_handle = nullptr; |
23 IPC::ChannelHandle* g_nacl_renderer_ipc_handle = nullptr; | 22 IPC::ChannelHandle* g_nacl_renderer_ipc_handle = nullptr; |
24 IPC::ChannelHandle* g_manifest_service_handle = nullptr; | 23 IPC::ChannelHandle* g_manifest_service_handle = nullptr; |
25 | 24 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 g_nacl_browser_ipc_handle = new IPC::ChannelHandle(browser_ipc_handle); | 62 g_nacl_browser_ipc_handle = new IPC::ChannelHandle(browser_ipc_handle); |
64 g_nacl_renderer_ipc_handle = new IPC::ChannelHandle(renderer_ipc_handle); | 63 g_nacl_renderer_ipc_handle = new IPC::ChannelHandle(renderer_ipc_handle); |
65 g_manifest_service_handle = new IPC::ChannelHandle(manifest_service_handle); | 64 g_manifest_service_handle = new IPC::ChannelHandle(manifest_service_handle); |
66 } | 65 } |
67 | 66 |
68 void StartUpPlugin() { | 67 void StartUpPlugin() { |
69 // The start up must be called only once. | 68 // The start up must be called only once. |
70 DCHECK(!g_shutdown_event); | 69 DCHECK(!g_shutdown_event); |
71 DCHECK(!g_io_thread); | 70 DCHECK(!g_io_thread); |
72 | 71 |
73 // The Mojo EDK must be initialized before using IPC. | |
74 mojo::edk::Init(); | |
75 | |
76 g_shutdown_event = | 72 g_shutdown_event = |
77 new base::WaitableEvent(base::WaitableEvent::ResetPolicy::MANUAL, | 73 new base::WaitableEvent(base::WaitableEvent::ResetPolicy::MANUAL, |
78 base::WaitableEvent::InitialState::NOT_SIGNALED); | 74 base::WaitableEvent::InitialState::NOT_SIGNALED); |
79 g_io_thread = new base::Thread("Chrome_NaClIOThread"); | 75 g_io_thread = new base::Thread("Chrome_NaClIOThread"); |
80 g_io_thread->StartWithOptions( | 76 g_io_thread->StartWithOptions( |
81 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); | 77 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); |
82 | 78 |
83 if (IsValidChannelHandle(g_manifest_service_handle)) { | 79 if (IsValidChannelHandle(g_manifest_service_handle)) { |
84 // Manifest service must be created on IOThread so that the main message | 80 // Manifest service must be created on IOThread so that the main message |
85 // handling will be done on the thread, which has a message loop | 81 // handling will be done on the thread, which has a message loop |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 // The IOThread must be initialized in advance. | 115 // The IOThread must be initialized in advance. |
120 DCHECK(g_io_thread); | 116 DCHECK(g_io_thread); |
121 return g_io_thread; | 117 return g_io_thread; |
122 } | 118 } |
123 | 119 |
124 ManifestService* GetManifestService() { | 120 ManifestService* GetManifestService() { |
125 return g_manifest_service; | 121 return g_manifest_service; |
126 } | 122 } |
127 | 123 |
128 } // namespace ppapi | 124 } // namespace ppapi |
OLD | NEW |