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" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 IPC::ChannelHandle manifest_service_handle) { | 58 IPC::ChannelHandle manifest_service_handle) { |
59 // The initialization must be only once. | 59 // The initialization must be only once. |
60 DCHECK(!g_nacl_browser_ipc_handle); | 60 DCHECK(!g_nacl_browser_ipc_handle); |
61 DCHECK(!g_nacl_renderer_ipc_handle); | 61 DCHECK(!g_nacl_renderer_ipc_handle); |
62 DCHECK(!g_nacl_renderer_ipc_handle); | 62 DCHECK(!g_nacl_renderer_ipc_handle); |
63 g_nacl_browser_ipc_handle = new IPC::ChannelHandle(browser_ipc_handle); | 63 g_nacl_browser_ipc_handle = new IPC::ChannelHandle(browser_ipc_handle); |
64 g_nacl_renderer_ipc_handle = new IPC::ChannelHandle(renderer_ipc_handle); | 64 g_nacl_renderer_ipc_handle = new IPC::ChannelHandle(renderer_ipc_handle); |
65 g_manifest_service_handle = new IPC::ChannelHandle(manifest_service_handle); | 65 g_manifest_service_handle = new IPC::ChannelHandle(manifest_service_handle); |
66 } | 66 } |
67 | 67 |
68 void StartUpPlugin() { | 68 void StartUpPlugin(bool initialize_mojo) { |
69 // The start up must be called only once. | 69 // The start up must be called only once. |
70 DCHECK(!g_shutdown_event); | 70 DCHECK(!g_shutdown_event); |
71 DCHECK(!g_io_thread); | 71 DCHECK(!g_io_thread); |
72 | 72 |
73 // The Mojo EDK must be initialized before using IPC. | 73 // In some cases, Mojo has already been initialized, so we need to avoid |
74 mojo::edk::Init(); | 74 // double-initializing it. |
| 75 if (initialize_mojo) { |
| 76 // The Mojo EDK must be initialized before using IPC. |
| 77 mojo::edk::Init(); |
| 78 } |
75 | 79 |
76 g_shutdown_event = | 80 g_shutdown_event = |
77 new base::WaitableEvent(base::WaitableEvent::ResetPolicy::MANUAL, | 81 new base::WaitableEvent(base::WaitableEvent::ResetPolicy::MANUAL, |
78 base::WaitableEvent::InitialState::NOT_SIGNALED); | 82 base::WaitableEvent::InitialState::NOT_SIGNALED); |
79 g_io_thread = new base::Thread("Chrome_NaClIOThread"); | 83 g_io_thread = new base::Thread("Chrome_NaClIOThread"); |
80 g_io_thread->StartWithOptions( | 84 g_io_thread->StartWithOptions( |
81 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); | 85 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); |
82 | 86 |
83 if (IsValidChannelHandle(g_manifest_service_handle)) { | 87 if (IsValidChannelHandle(g_manifest_service_handle)) { |
84 // Manifest service must be created on IOThread so that the main message | 88 // Manifest service must be created on IOThread so that the main message |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 // The IOThread must be initialized in advance. | 123 // The IOThread must be initialized in advance. |
120 DCHECK(g_io_thread); | 124 DCHECK(g_io_thread); |
121 return g_io_thread; | 125 return g_io_thread; |
122 } | 126 } |
123 | 127 |
124 ManifestService* GetManifestService() { | 128 ManifestService* GetManifestService() { |
125 return g_manifest_service; | 129 return g_manifest_service; |
126 } | 130 } |
127 | 131 |
128 } // namespace ppapi | 132 } // namespace ppapi |
OLD | NEW |