| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 nacl::string url; | 61 nacl::string url; |
| 62 PP_NaClFileInfo file_info; | 62 PP_NaClFileInfo file_info; |
| 63 bool uses_irt; | 63 bool uses_irt; |
| 64 bool uses_ppapi; | 64 bool uses_ppapi; |
| 65 bool enable_dev_interfaces; | 65 bool enable_dev_interfaces; |
| 66 bool enable_dyncode_syscalls; | 66 bool enable_dyncode_syscalls; |
| 67 bool enable_exception_handling; | 67 bool enable_exception_handling; |
| 68 bool enable_crash_throttling; | 68 bool enable_crash_throttling; |
| 69 }; | 69 }; |
| 70 | 70 |
| 71 // Callback resources are essentially our continuation state. | |
| 72 struct OpenManifestEntryResource { | |
| 73 public: | |
| 74 OpenManifestEntryResource(const std::string& target_url, | |
| 75 struct NaClFileInfo* finfo, | |
| 76 bool* op_complete) | |
| 77 : url(target_url), | |
| 78 file_info(finfo), | |
| 79 op_complete_ptr(op_complete) {} | |
| 80 ~OpenManifestEntryResource(); | |
| 81 | |
| 82 std::string url; | |
| 83 struct NaClFileInfo* file_info; | |
| 84 PP_NaClFileInfo pp_file_info; | |
| 85 bool* op_complete_ptr; | |
| 86 }; | |
| 87 | |
| 88 // Do not invoke from the main thread, since the main methods will | 71 // Do not invoke from the main thread, since the main methods will |
| 89 // invoke CallOnMainThread and then wait on a condvar for the task to | 72 // invoke CallOnMainThread and then wait on a condvar for the task to |
| 90 // complete: if invoked from the main thread, the main method not | 73 // complete: if invoked from the main thread, the main method not |
| 91 // returning (and thus unblocking the main thread) means that the | 74 // returning (and thus unblocking the main thread) means that the |
| 92 // main-thread continuation methods will never get called, and thus | 75 // main-thread continuation methods will never get called, and thus |
| 93 // we'd get a deadlock. | 76 // we'd get a deadlock. |
| 94 class PluginReverseInterface: public nacl::ReverseInterface { | 77 class PluginReverseInterface: public nacl::ReverseInterface { |
| 95 public: | 78 public: |
| 96 PluginReverseInterface(nacl::WeakRefAnchor* anchor, | 79 PluginReverseInterface(PP_Instance pp_instance, |
| 97 PP_Instance pp_instance, | |
| 98 ServiceRuntime* service_runtime, | 80 ServiceRuntime* service_runtime, |
| 99 pp::CompletionCallback init_done_cb, | 81 pp::CompletionCallback init_done_cb, |
| 100 pp::CompletionCallback crash_cb); | 82 pp::CompletionCallback crash_cb); |
| 101 | 83 |
| 102 virtual ~PluginReverseInterface(); | 84 virtual ~PluginReverseInterface(); |
| 103 | 85 |
| 104 void ShutDown(); | 86 void ShutDown(); |
| 105 | 87 |
| 106 virtual void DoPostMessage(nacl::string message); | 88 virtual void DoPostMessage(nacl::string message); |
| 107 | 89 |
| 108 virtual void StartupInitializationComplete(); | 90 virtual void StartupInitializationComplete(); |
| 109 | 91 |
| 110 virtual bool OpenManifestEntry(nacl::string url_key, | 92 virtual bool OpenManifestEntry(nacl::string url_key, |
| 111 struct NaClFileInfo *info); | 93 struct NaClFileInfo *info); |
| 112 | 94 |
| 113 virtual void ReportCrash(); | 95 virtual void ReportCrash(); |
| 114 | 96 |
| 115 virtual void ReportExitStatus(int exit_status); | 97 virtual void ReportExitStatus(int exit_status); |
| 116 | 98 |
| 117 // TODO(teravest): Remove this method once it's gone from | 99 // TODO(teravest): Remove this method once it's gone from |
| 118 // nacl::ReverseInterface. | 100 // nacl::ReverseInterface. |
| 119 virtual int64_t RequestQuotaForWrite(nacl::string file_id, | 101 virtual int64_t RequestQuotaForWrite(nacl::string file_id, |
| 120 int64_t offset, | 102 int64_t offset, |
| 121 int64_t bytes_to_write); | 103 int64_t bytes_to_write); |
| 122 | 104 |
| 123 protected: | |
| 124 virtual void OpenManifestEntry_MainThreadContinuation( | |
| 125 OpenManifestEntryResource* p, | |
| 126 int32_t err); | |
| 127 | |
| 128 virtual void StreamAsFile_MainThreadContinuation( | |
| 129 OpenManifestEntryResource* p, | |
| 130 int32_t result); | |
| 131 | |
| 132 private: | 105 private: |
| 133 nacl::WeakRefAnchor* anchor_; // holds a ref | |
| 134 // Should be used only in main thread in WeakRef-protected callbacks. | |
| 135 PP_Instance pp_instance_; | 106 PP_Instance pp_instance_; |
| 136 ServiceRuntime* service_runtime_; | 107 ServiceRuntime* service_runtime_; |
| 137 NaClMutex mu_; | 108 NaClMutex mu_; |
| 138 NaClCondVar cv_; | 109 NaClCondVar cv_; |
| 139 bool shutting_down_; | 110 bool shutting_down_; |
| 140 | 111 |
| 141 pp::CompletionCallback init_done_cb_; | 112 pp::CompletionCallback init_done_cb_; |
| 142 pp::CompletionCallback crash_cb_; | 113 pp::CompletionCallback crash_cb_; |
| 143 }; | 114 }; |
| 144 | 115 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 void ReportLoadError(const ErrorInfo& error_info); | 186 void ReportLoadError(const ErrorInfo& error_info); |
| 216 | 187 |
| 217 NaClSrpcChannel command_channel_; | 188 NaClSrpcChannel command_channel_; |
| 218 Plugin* plugin_; | 189 Plugin* plugin_; |
| 219 PP_Instance pp_instance_; | 190 PP_Instance pp_instance_; |
| 220 bool main_service_runtime_; | 191 bool main_service_runtime_; |
| 221 bool uses_nonsfi_mode_; | 192 bool uses_nonsfi_mode_; |
| 222 nacl::ReverseService* reverse_service_; | 193 nacl::ReverseService* reverse_service_; |
| 223 nacl::scoped_ptr<SelLdrLauncherChrome> subprocess_; | 194 nacl::scoped_ptr<SelLdrLauncherChrome> subprocess_; |
| 224 | 195 |
| 225 nacl::WeakRefAnchor* anchor_; | |
| 226 | |
| 227 PluginReverseInterface* rev_interface_; | 196 PluginReverseInterface* rev_interface_; |
| 228 | 197 |
| 229 // Mutex and CondVar to protect start_sel_ldr_done_ and nexe_started_. | 198 // Mutex and CondVar to protect start_sel_ldr_done_ and nexe_started_. |
| 230 NaClMutex mu_; | 199 NaClMutex mu_; |
| 231 NaClCondVar cond_; | 200 NaClCondVar cond_; |
| 232 bool start_sel_ldr_done_; | 201 bool start_sel_ldr_done_; |
| 233 bool start_nexe_done_; | 202 bool start_nexe_done_; |
| 234 bool nexe_started_ok_; | 203 bool nexe_started_ok_; |
| 235 | 204 |
| 236 NaClHandle bootstrap_channel_; | 205 NaClHandle bootstrap_channel_; |
| 237 }; | 206 }; |
| 238 | 207 |
| 239 } // namespace plugin | 208 } // namespace plugin |
| 240 | 209 |
| 241 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SERVICE_RUNTIME_H_ | 210 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SERVICE_RUNTIME_H_ |
| OLD | NEW |