OLD | NEW |
1 /* -*- c++ -*- */ | 1 /* -*- c++ -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2012 The Chromium Authors. All rights reserved. | 3 * Copyright (c) 2012 The Chromium Authors. All rights reserved. |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 // A class containing information regarding a socket connection to a | 8 // A class containing information regarding a socket connection to a |
9 // service runtime instance. | 9 // service runtime instance. |
10 | 10 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 // Do not invoke from the main thread, since the main methods will | 93 // Do not invoke from the main thread, since the main methods will |
94 // invoke CallOnMainThread and then wait on a condvar for the task to | 94 // invoke CallOnMainThread and then wait on a condvar for the task to |
95 // complete: if invoked from the main thread, the main method not | 95 // complete: if invoked from the main thread, the main method not |
96 // returning (and thus unblocking the main thread) means that the | 96 // returning (and thus unblocking the main thread) means that the |
97 // main-thread continuation methods will never get called, and thus | 97 // main-thread continuation methods will never get called, and thus |
98 // we'd get a deadlock. | 98 // we'd get a deadlock. |
99 class PluginReverseInterface: public nacl::ReverseInterface { | 99 class PluginReverseInterface: public nacl::ReverseInterface { |
100 public: | 100 public: |
101 PluginReverseInterface(nacl::WeakRefAnchor* anchor, | 101 PluginReverseInterface(nacl::WeakRefAnchor* anchor, |
102 Plugin* plugin, | 102 Plugin* plugin, |
103 int32_t manifest_id, | |
104 ServiceRuntime* service_runtime, | 103 ServiceRuntime* service_runtime, |
105 pp::CompletionCallback init_done_cb, | 104 pp::CompletionCallback init_done_cb, |
106 pp::CompletionCallback crash_cb); | 105 pp::CompletionCallback crash_cb); |
107 | 106 |
108 virtual ~PluginReverseInterface(); | 107 virtual ~PluginReverseInterface(); |
109 | 108 |
110 void ShutDown(); | 109 void ShutDown(); |
111 | 110 |
112 virtual void DoPostMessage(nacl::string message); | 111 virtual void DoPostMessage(nacl::string message); |
113 | 112 |
(...skipping 29 matching lines...) Expand all Loading... |
143 int32_t err); | 142 int32_t err); |
144 | 143 |
145 virtual void StreamAsFile_MainThreadContinuation( | 144 virtual void StreamAsFile_MainThreadContinuation( |
146 OpenManifestEntryResource* p, | 145 OpenManifestEntryResource* p, |
147 int32_t result); | 146 int32_t result); |
148 | 147 |
149 private: | 148 private: |
150 nacl::WeakRefAnchor* anchor_; // holds a ref | 149 nacl::WeakRefAnchor* anchor_; // holds a ref |
151 Plugin* plugin_; // value may be copied, but should be used only in | 150 Plugin* plugin_; // value may be copied, but should be used only in |
152 // main thread in WeakRef-protected callbacks. | 151 // main thread in WeakRef-protected callbacks. |
153 int32_t manifest_id_; | |
154 ServiceRuntime* service_runtime_; | 152 ServiceRuntime* service_runtime_; |
155 NaClMutex mu_; | 153 NaClMutex mu_; |
156 NaClCondVar cv_; | 154 NaClCondVar cv_; |
157 bool shutting_down_; | 155 bool shutting_down_; |
158 | 156 |
159 pp::CompletionCallback init_done_cb_; | 157 pp::CompletionCallback init_done_cb_; |
160 pp::CompletionCallback crash_cb_; | 158 pp::CompletionCallback crash_cb_; |
161 }; | 159 }; |
162 | 160 |
163 // ServiceRuntime abstracts a NativeClient sel_ldr instance. | 161 // ServiceRuntime abstracts a NativeClient sel_ldr instance. |
164 class ServiceRuntime { | 162 class ServiceRuntime { |
165 public: | 163 public: |
166 // TODO(sehr): This class should also implement factory methods, using the | 164 // TODO(sehr): This class should also implement factory methods, using the |
167 // Start method below. | 165 // Start method below. |
168 ServiceRuntime(Plugin* plugin, | 166 ServiceRuntime(Plugin* plugin, |
169 int32_t manifest_id, | |
170 bool main_service_runtime, | 167 bool main_service_runtime, |
171 bool uses_nonsfi_mode, | 168 bool uses_nonsfi_mode, |
172 pp::CompletionCallback init_done_cb, | 169 pp::CompletionCallback init_done_cb, |
173 pp::CompletionCallback crash_cb); | 170 pp::CompletionCallback crash_cb); |
174 // The destructor terminates the sel_ldr process. | 171 // The destructor terminates the sel_ldr process. |
175 ~ServiceRuntime(); | 172 ~ServiceRuntime(); |
176 | 173 |
177 // Spawn the sel_ldr instance. | 174 // Spawn the sel_ldr instance. |
178 void StartSelLdr(const SelLdrStartParams& params, | 175 void StartSelLdr(const SelLdrStartParams& params, |
179 pp::CompletionCallback callback); | 176 pp::CompletionCallback callback); |
(...skipping 25 matching lines...) Expand all Loading... |
205 | 202 |
206 // exit_status is -1 when invalid; when we set it, we will ensure | 203 // exit_status is -1 when invalid; when we set it, we will ensure |
207 // that it is non-negative (the portion of the exit status from the | 204 // that it is non-negative (the portion of the exit status from the |
208 // nexe that is transferred is the low 8 bits of the argument to the | 205 // nexe that is transferred is the low 8 bits of the argument to the |
209 // exit syscall). | 206 // exit syscall). |
210 int exit_status(); // const, but grabs mutex etc. | 207 int exit_status(); // const, but grabs mutex etc. |
211 void set_exit_status(int exit_status); | 208 void set_exit_status(int exit_status); |
212 | 209 |
213 nacl::string GetCrashLogOutput(); | 210 nacl::string GetCrashLogOutput(); |
214 | 211 |
| 212 bool main_service_runtime() const { return main_service_runtime_; } |
| 213 |
215 private: | 214 private: |
216 NACL_DISALLOW_COPY_AND_ASSIGN(ServiceRuntime); | 215 NACL_DISALLOW_COPY_AND_ASSIGN(ServiceRuntime); |
217 bool SetupCommandChannel(); | 216 bool SetupCommandChannel(); |
218 bool LoadModule(PP_NaClFileInfo file_info); | 217 bool LoadModule(PP_NaClFileInfo file_info); |
219 bool InitReverseService(); | 218 bool InitReverseService(); |
220 bool StartModule(); | 219 bool StartModule(); |
221 | 220 |
222 NaClSrpcChannel command_channel_; | 221 NaClSrpcChannel command_channel_; |
223 Plugin* plugin_; | 222 Plugin* plugin_; |
224 bool main_service_runtime_; | 223 bool main_service_runtime_; |
225 bool uses_nonsfi_mode_; | 224 bool uses_nonsfi_mode_; |
226 nacl::ReverseService* reverse_service_; | 225 nacl::ReverseService* reverse_service_; |
227 nacl::scoped_ptr<nacl::SelLdrLauncherBase> subprocess_; | 226 nacl::scoped_ptr<nacl::SelLdrLauncherBase> subprocess_; |
228 | 227 |
229 nacl::WeakRefAnchor* anchor_; | 228 nacl::WeakRefAnchor* anchor_; |
230 | 229 |
231 PluginReverseInterface* rev_interface_; | 230 PluginReverseInterface* rev_interface_; |
232 | 231 |
233 // Mutex and CondVar to protect start_sel_ldr_done_. | 232 // Mutex and CondVar to protect start_sel_ldr_done_. |
234 NaClMutex mu_; | 233 NaClMutex mu_; |
235 NaClCondVar cond_; | 234 NaClCondVar cond_; |
236 bool start_sel_ldr_done_; | 235 bool start_sel_ldr_done_; |
237 }; | 236 }; |
238 | 237 |
239 } // namespace plugin | 238 } // namespace plugin |
240 | 239 |
241 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SERVICE_RUNTIME_H_ | 240 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SERVICE_RUNTIME_H_ |
OLD | NEW |