| OLD | NEW |
| 1 // -*- c++ -*- | 1 // -*- c++ -*- |
| 2 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
| 4 // found in the LICENSE file. | 4 // found in the LICENSE file. |
| 5 | 5 |
| 6 // The portable representation of an instance and root scriptable object. | 6 // The portable representation of an instance and root scriptable object. |
| 7 // The PPAPI version of the plugin instantiates a subclass of this class. | 7 // The PPAPI version of the plugin instantiates a subclass of this class. |
| 8 | 8 |
| 9 #ifndef COMPONENTS_NACL_RENDERER_PLUGIN_PLUGIN_H_ | 9 #ifndef COMPONENTS_NACL_RENDERER_PLUGIN_PLUGIN_H_ |
| 10 #define COMPONENTS_NACL_RENDERER_PLUGIN_PLUGIN_H_ | 10 #define COMPONENTS_NACL_RENDERER_PLUGIN_PLUGIN_H_ |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 // event handlers should block until the module is ready before | 73 // event handlers should block until the module is ready before |
| 74 // trying to communicate with it, i.e., until nacl_ready_state is | 74 // trying to communicate with it, i.e., until nacl_ready_state is |
| 75 // DONE. | 75 // DONE. |
| 76 // | 76 // |
| 77 // NB: currently we do not time out, so if the untrusted code | 77 // NB: currently we do not time out, so if the untrusted code |
| 78 // does not signal that it is ready, then we will deadlock the main | 78 // does not signal that it is ready, then we will deadlock the main |
| 79 // thread of the renderer on this subsequent event delivery. We | 79 // thread of the renderer on this subsequent event delivery. We |
| 80 // should include a time-out at which point we declare the | 80 // should include a time-out at which point we declare the |
| 81 // nacl_ready_state to be done, and let the normal crash detection | 81 // nacl_ready_state to be done, and let the normal crash detection |
| 82 // mechanism(s) take over. | 82 // mechanism(s) take over. |
| 83 // Please note that a call to this function takes over ownership of the | 83 // This function takes over ownership of the file_info. |
| 84 // file_info pointer. | |
| 85 void LoadNaClModule(PP_NaClFileInfo file_info, | 84 void LoadNaClModule(PP_NaClFileInfo file_info, |
| 86 bool uses_nonsfi_mode, | 85 bool uses_nonsfi_mode, |
| 87 PP_NaClAppProcessType process_type); | 86 PP_NaClAppProcessType process_type); |
| 88 | 87 |
| 89 // Load support. | 88 // Load support. |
| 90 // A helper SRPC NaCl module can be loaded given a PP_NaClFileInfo. | 89 // A helper SRPC NaCl module can be loaded given a PP_NaClFileInfo. |
| 91 // Blocks until the helper module signals initialization is done. | |
| 92 // Does not update nacl_module_origin(). | 90 // Does not update nacl_module_origin(). |
| 93 // Returns NULL or the NaClSubprocess of the new helper NaCl module. | 91 // Uses the given NaClSubprocess to contain the new SelLdr process. |
| 94 // Please note that a call to this function takes over ownership of the | 92 // The given callback is called when the loading is complete. |
| 95 // file_info pointer. | 93 // This function takes over ownership of the file_info. |
| 96 NaClSubprocess* LoadHelperNaClModule(const std::string& helper_url, | 94 void LoadHelperNaClModule(const std::string& helper_url, |
| 97 PP_NaClFileInfo file_info, | 95 PP_NaClFileInfo file_info, |
| 98 ErrorInfo* error_info); | 96 NaClSubprocess* subprocess_to_init, |
| 97 pp::CompletionCallback callback); |
| 99 | 98 |
| 100 // Report an error that was encountered while loading a module. | 99 // Report an error that was encountered while loading a module. |
| 101 void ReportLoadError(const ErrorInfo& error_info); | 100 void ReportLoadError(const ErrorInfo& error_info); |
| 102 | 101 |
| 103 nacl::DescWrapperFactory* wrapper_factory() const { return wrapper_factory_; } | 102 nacl::DescWrapperFactory* wrapper_factory() const { return wrapper_factory_; } |
| 104 | 103 |
| 105 const PPB_NaCl_Private* nacl_interface() const { return nacl_interface_; } | 104 const PPB_NaCl_Private* nacl_interface() const { return nacl_interface_; } |
| 106 | 105 |
| 107 private: | 106 private: |
| 108 NACL_DISALLOW_COPY_AND_ASSIGN(Plugin); | 107 NACL_DISALLOW_COPY_AND_ASSIGN(Plugin); |
| 109 // The browser will invoke the destructor via the pp::Instance | 108 // The browser will invoke the destructor via the pp::Instance |
| 110 // pointer to this object, not from base's Delete(). | 109 // pointer to this object, not from base's Delete(). |
| 111 ~Plugin() override; | 110 ~Plugin() override; |
| 112 | 111 |
| 113 // Shuts down socket connection, service runtime, and receive thread, | 112 // Shuts down socket connection, service runtime, and receive thread, |
| 114 // in this order, for the main nacl subprocess. | 113 // in this order, for the main nacl subprocess. |
| 115 void ShutDownSubprocesses(); | 114 void ShutDownSubprocesses(); |
| 116 | 115 |
| 117 // Loads and starts a helper (e.g. llc, ld) NaCl module. | 116 // Start sel_ldr given the start params. This is invoked on the main thread. |
| 118 // Only to be used from a background (non-main) thread for the PNaCl | 117 void StartSelLdr(ServiceRuntime* service_runtime, |
| 119 // translator. This will fully initialize the |subprocess| if the load was | 118 const SelLdrStartParams& params, |
| 120 // successful. | 119 pp::CompletionCallback callback); |
| 121 bool LoadHelperNaClModuleInternal(NaClSubprocess* subprocess, | |
| 122 const SelLdrStartParams& params); | |
| 123 | |
| 124 // Start sel_ldr from the main thread, given the start params. | |
| 125 // |pp_error| is set by CallOnMainThread (should be PP_OK). | |
| 126 void StartSelLdrOnMainThread(int32_t pp_error, | |
| 127 ServiceRuntime* service_runtime, | |
| 128 const SelLdrStartParams& params, | |
| 129 pp::CompletionCallback callback); | |
| 130 | |
| 131 // Signals that StartSelLdr has finished. | |
| 132 // This is invoked on the main thread. | |
| 133 void SignalStartSelLdrDone(int32_t pp_error, | |
| 134 bool* started, | |
| 135 ServiceRuntime* service_runtime); | |
| 136 | 120 |
| 137 // This is invoked on the main thread. | 121 // This is invoked on the main thread. |
| 138 void StartNexe(int32_t pp_error, ServiceRuntime* service_runtime); | 122 void StartNexe(int32_t pp_error, ServiceRuntime* service_runtime); |
| 139 | 123 |
| 124 // Continuation for LoadHelperNaClModule. This is invoked on the main thread. |
| 125 void StartHelperNexe(int32_t pp_error, |
| 126 NaClSubprocess* subprocess_to_init, |
| 127 pp::CompletionCallback callback); |
| 128 |
| 140 // Callback used when getting the URL for the .nexe file. If the URL loading | 129 // Callback used when getting the URL for the .nexe file. If the URL loading |
| 141 // is successful, the file descriptor is opened and can be passed to sel_ldr | 130 // is successful, the file descriptor is opened and can be passed to sel_ldr |
| 142 // with the sandbox on. | 131 // with the sandbox on. |
| 143 void NexeFileDidOpen(int32_t pp_error); | 132 void NexeFileDidOpen(int32_t pp_error); |
| 144 | 133 |
| 145 // Callback used when a .nexe is translated from bitcode. If the translation | 134 // Callback used when a .nexe is translated from bitcode. If the translation |
| 146 // is successful, the file descriptor is opened and can be passed to sel_ldr | 135 // is successful, the file descriptor is opened and can be passed to sel_ldr |
| 147 // with the sandbox on. | 136 // with the sandbox on. |
| 148 void BitcodeDidTranslate(int32_t pp_error); | 137 void BitcodeDidTranslate(int32_t pp_error); |
| 149 | 138 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 174 | 163 |
| 175 PP_NaClFileInfo nexe_file_info_; | 164 PP_NaClFileInfo nexe_file_info_; |
| 176 | 165 |
| 177 const PPB_NaCl_Private* nacl_interface_; | 166 const PPB_NaCl_Private* nacl_interface_; |
| 178 pp::UMAPrivate uma_interface_; | 167 pp::UMAPrivate uma_interface_; |
| 179 }; | 168 }; |
| 180 | 169 |
| 181 } // namespace plugin | 170 } // namespace plugin |
| 182 | 171 |
| 183 #endif // COMPONENTS_NACL_RENDERER_PLUGIN_PLUGIN_H_ | 172 #endif // COMPONENTS_NACL_RENDERER_PLUGIN_PLUGIN_H_ |
| OLD | NEW |