| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 int browser_ipc_fd, int renderer_ipc_fd, int manifest_service_fd) { | 52 int browser_ipc_fd, int renderer_ipc_fd, int manifest_service_fd) { |
| 53 // The initialization must be only once. | 53 // The initialization must be only once. |
| 54 DCHECK_EQ(g_nacl_browser_ipc_fd, -1); | 54 DCHECK_EQ(g_nacl_browser_ipc_fd, -1); |
| 55 DCHECK_EQ(g_nacl_renderer_ipc_fd, -1); | 55 DCHECK_EQ(g_nacl_renderer_ipc_fd, -1); |
| 56 DCHECK_EQ(g_manifest_service_fd, -1); | 56 DCHECK_EQ(g_manifest_service_fd, -1); |
| 57 g_nacl_browser_ipc_fd = browser_ipc_fd; | 57 g_nacl_browser_ipc_fd = browser_ipc_fd; |
| 58 g_nacl_renderer_ipc_fd = renderer_ipc_fd; | 58 g_nacl_renderer_ipc_fd = renderer_ipc_fd; |
| 59 g_manifest_service_fd = manifest_service_fd; | 59 g_manifest_service_fd = manifest_service_fd; |
| 60 } | 60 } |
| 61 | 61 |
| 62 void StartUpPlugin() { | 62 void StartUpPlugin(bool initialize_mojo) { |
| 63 // The start up must be called only once. | 63 // The start up must be called only once. |
| 64 DCHECK(!g_shutdown_event); | 64 DCHECK(!g_shutdown_event); |
| 65 DCHECK(!g_io_thread); | 65 DCHECK(!g_io_thread); |
| 66 | 66 |
| 67 // The Mojo EDK must be initialized before using IPC. | 67 // In some cases, Mojo has already been initialized, so we need to avoid |
| 68 mojo::edk::Init(); | 68 // double-initializing it. |
| 69 if (initialize_mojo) { |
| 70 // The Mojo EDK must be initialized before using IPC. |
| 71 mojo::edk::Init(); |
| 72 } |
| 69 | 73 |
| 70 g_shutdown_event = | 74 g_shutdown_event = |
| 71 new base::WaitableEvent(base::WaitableEvent::ResetPolicy::MANUAL, | 75 new base::WaitableEvent(base::WaitableEvent::ResetPolicy::MANUAL, |
| 72 base::WaitableEvent::InitialState::NOT_SIGNALED); | 76 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 73 g_io_thread = new base::Thread("Chrome_NaClIOThread"); | 77 g_io_thread = new base::Thread("Chrome_NaClIOThread"); |
| 74 g_io_thread->StartWithOptions( | 78 g_io_thread->StartWithOptions( |
| 75 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); | 79 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); |
| 76 | 80 |
| 77 if (g_manifest_service_fd != -1) { | 81 if (g_manifest_service_fd != -1) { |
| 78 // Manifest service must be created on IOThread so that the main message | 82 // 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... |
| 113 // The IOThread must be initialized in advance. | 117 // The IOThread must be initialized in advance. |
| 114 DCHECK(g_io_thread); | 118 DCHECK(g_io_thread); |
| 115 return g_io_thread; | 119 return g_io_thread; |
| 116 } | 120 } |
| 117 | 121 |
| 118 ManifestService* GetManifestService() { | 122 ManifestService* GetManifestService() { |
| 119 return g_manifest_service; | 123 return g_manifest_service; |
| 120 } | 124 } |
| 121 | 125 |
| 122 } // namespace ppapi | 126 } // namespace ppapi |
| OLD | NEW |