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 NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PLUGIN_H_ | 9 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PLUGIN_H_ |
10 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PLUGIN_H_ | 10 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PLUGIN_H_ |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 // main-thread-only operations such as file processing. | 104 // main-thread-only operations such as file processing. |
105 bool LoadNaClModuleContinuation(int32_t pp_error); | 105 bool LoadNaClModuleContinuation(int32_t pp_error); |
106 | 106 |
107 // Load support. | 107 // Load support. |
108 // A helper SRPC NaCl module can be loaded given a DescWrapper. | 108 // A helper SRPC NaCl module can be loaded given a DescWrapper. |
109 // Blocks until the helper module signals initialization is done. | 109 // Blocks until the helper module signals initialization is done. |
110 // Does not update nacl_module_origin(). | 110 // Does not update nacl_module_origin(). |
111 // Returns NULL or the NaClSubprocess of the new helper NaCl module. | 111 // Returns NULL or the NaClSubprocess of the new helper NaCl module. |
112 NaClSubprocess* LoadHelperNaClModule(const nacl::string& helper_url, | 112 NaClSubprocess* LoadHelperNaClModule(const nacl::string& helper_url, |
113 nacl::DescWrapper* wrapper, | 113 nacl::DescWrapper* wrapper, |
114 const Manifest* manifest, | 114 int32_t manifest_id, |
115 ErrorInfo* error_info); | 115 ErrorInfo* error_info); |
116 | 116 |
117 enum LengthComputable { | 117 enum LengthComputable { |
118 LENGTH_IS_NOT_COMPUTABLE = 0, | 118 LENGTH_IS_NOT_COMPUTABLE = 0, |
119 LENGTH_IS_COMPUTABLE = 1 | 119 LENGTH_IS_COMPUTABLE = 1 |
120 }; | 120 }; |
121 // Report successful loading of a module. | 121 // Report successful loading of a module. |
122 void ReportLoadSuccess(uint64_t loaded_bytes, uint64_t total_bytes); | 122 void ReportLoadSuccess(uint64_t loaded_bytes, uint64_t total_bytes); |
123 // Report an error that was encountered while loading a module. | 123 // Report an error that was encountered while loading a module. |
124 void ReportLoadError(const ErrorInfo& error_info); | 124 void ReportLoadError(const ErrorInfo& error_info); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 // Returns rich information for a file retrieved by StreamAsFile(). This info | 157 // Returns rich information for a file retrieved by StreamAsFile(). This info |
158 // contains a file descriptor. The caller must take ownership of this | 158 // contains a file descriptor. The caller must take ownership of this |
159 // descriptor. | 159 // descriptor. |
160 struct NaClFileInfo GetFileInfo(const nacl::string& url); | 160 struct NaClFileInfo GetFileInfo(const nacl::string& url); |
161 | 161 |
162 // A helper function that indicates if |url| can be requested by the document | 162 // A helper function that indicates if |url| can be requested by the document |
163 // under the same-origin policy. Strictly speaking, it may be possible for the | 163 // under the same-origin policy. Strictly speaking, it may be possible for the |
164 // document to request the URL using CORS even if this function returns false. | 164 // document to request the URL using CORS even if this function returns false. |
165 bool DocumentCanRequest(const std::string& url); | 165 bool DocumentCanRequest(const std::string& url); |
166 | 166 |
167 Manifest const* manifest() const { return manifest_.get(); } | |
168 | |
169 // set_exit_status may be called off the main thread. | 167 // set_exit_status may be called off the main thread. |
170 void set_exit_status(int exit_status); | 168 void set_exit_status(int exit_status); |
171 | 169 |
172 const PPB_NaCl_Private* nacl_interface() const { return nacl_interface_; } | 170 const PPB_NaCl_Private* nacl_interface() const { return nacl_interface_; } |
173 pp::UMAPrivate& uma_interface() { return uma_interface_; } | 171 pp::UMAPrivate& uma_interface() { return uma_interface_; } |
174 | 172 |
175 private: | 173 private: |
176 NACL_DISALLOW_COPY_AND_ASSIGN(Plugin); | 174 NACL_DISALLOW_COPY_AND_ASSIGN(Plugin); |
177 // The browser will invoke the destructor via the pp::Instance | 175 // The browser will invoke the destructor via the pp::Instance |
178 // pointer to this object, not from base's Delete(). | 176 // pointer to this object, not from base's Delete(). |
(...skipping 20 matching lines...) Expand all Loading... |
199 int out_of_range_replacement); | 197 int out_of_range_replacement); |
200 void HistogramEnumerateLoadStatus(PP_NaClError error_code); | 198 void HistogramEnumerateLoadStatus(PP_NaClError error_code); |
201 void HistogramEnumerateSelLdrLoadStatus(NaClErrorCode error_code); | 199 void HistogramEnumerateSelLdrLoadStatus(NaClErrorCode error_code); |
202 void HistogramHTTPStatusCode(const std::string& name, int status); | 200 void HistogramHTTPStatusCode(const std::string& name, int status); |
203 | 201 |
204 // Load a nacl module from the file specified in wrapper. | 202 // Load a nacl module from the file specified in wrapper. |
205 // Only to be used from a background (non-main) thread. | 203 // Only to be used from a background (non-main) thread. |
206 // This will fully initialize the |subprocess| if the load was successful. | 204 // This will fully initialize the |subprocess| if the load was successful. |
207 bool LoadNaClModuleFromBackgroundThread(nacl::DescWrapper* wrapper, | 205 bool LoadNaClModuleFromBackgroundThread(nacl::DescWrapper* wrapper, |
208 NaClSubprocess* subprocess, | 206 NaClSubprocess* subprocess, |
209 const Manifest* manifest, | 207 int32_t manifest_id, |
210 const SelLdrStartParams& params); | 208 const SelLdrStartParams& params); |
211 | 209 |
212 // Start sel_ldr from the main thread, given the start params. | 210 // Start sel_ldr from the main thread, given the start params. |
213 // |pp_error| is set by CallOnMainThread (should be PP_OK). | 211 // |pp_error| is set by CallOnMainThread (should be PP_OK). |
214 void StartSelLdrOnMainThread(int32_t pp_error, | 212 void StartSelLdrOnMainThread(int32_t pp_error, |
215 ServiceRuntime* service_runtime, | 213 ServiceRuntime* service_runtime, |
216 const SelLdrStartParams& params, | 214 const SelLdrStartParams& params, |
217 pp::CompletionCallback callback); | 215 pp::CompletionCallback callback); |
218 | 216 |
219 // Signals that StartSelLdr has finished. | 217 // Signals that StartSelLdr has finished. |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 // callback to run when the file has been downloaded and is opened for | 295 // callback to run when the file has been downloaded and is opened for |
298 // reading. We use one downloader for all URL downloads to prevent issuing | 296 // reading. We use one downloader for all URL downloads to prevent issuing |
299 // multiple GETs that might arrive out of order. For example, this will | 297 // multiple GETs that might arrive out of order. For example, this will |
300 // prevent a GET of a NaCl manifest while a .nexe GET is pending. Note that | 298 // prevent a GET of a NaCl manifest while a .nexe GET is pending. Note that |
301 // this will also prevent simultaneous handling of multiple .nexes on a page. | 299 // this will also prevent simultaneous handling of multiple .nexes on a page. |
302 FileDownloader nexe_downloader_; | 300 FileDownloader nexe_downloader_; |
303 pp::CompletionCallbackFactory<Plugin> callback_factory_; | 301 pp::CompletionCallbackFactory<Plugin> callback_factory_; |
304 | 302 |
305 nacl::scoped_ptr<PnaclCoordinator> pnacl_coordinator_; | 303 nacl::scoped_ptr<PnaclCoordinator> pnacl_coordinator_; |
306 | 304 |
307 // The manifest dictionary. Used for looking up resources to be loaded. | |
308 nacl::scoped_ptr<Manifest> manifest_; | |
309 | |
310 // Keep track of the FileDownloaders created to fetch urls. | 305 // Keep track of the FileDownloaders created to fetch urls. |
311 std::set<FileDownloader*> url_downloaders_; | 306 std::set<FileDownloader*> url_downloaders_; |
312 // Keep track of file descriptors opened by StreamAsFile(). | 307 // Keep track of file descriptors opened by StreamAsFile(). |
313 // These are owned by the browser. | 308 // These are owned by the browser. |
314 std::map<nacl::string, NaClFileInfoAutoCloser*> url_file_info_map_; | 309 std::map<nacl::string, NaClFileInfoAutoCloser*> url_file_info_map_; |
315 | 310 |
316 // Callback to receive .nexe and .dso download progress notifications. | 311 // Callback to receive .nexe and .dso download progress notifications. |
317 static void UpdateDownloadProgress( | 312 static void UpdateDownloadProgress( |
318 PP_Instance pp_instance, | 313 PP_Instance pp_instance, |
319 PP_Resource pp_resource, | 314 PP_Resource pp_resource, |
320 int64_t bytes_sent, | 315 int64_t bytes_sent, |
321 int64_t total_bytes_to_be_sent, | 316 int64_t total_bytes_to_be_sent, |
322 int64_t bytes_received, | 317 int64_t bytes_received, |
323 int64_t total_bytes_to_be_received); | 318 int64_t total_bytes_to_be_received); |
324 | 319 |
325 // Finds the file downloader which owns the given URL loader. This is used | 320 // Finds the file downloader which owns the given URL loader. This is used |
326 // in UpdateDownloadProgress to map a url loader back to the URL being | 321 // in UpdateDownloadProgress to map a url loader back to the URL being |
327 // downloaded. | 322 // downloaded. |
328 const FileDownloader* FindFileDownloader(PP_Resource url_loader) const; | 323 const FileDownloader* FindFileDownloader(PP_Resource url_loader) const; |
329 | 324 |
330 int64_t time_of_last_progress_event_; | 325 int64_t time_of_last_progress_event_; |
331 int exit_status_; | 326 int exit_status_; |
332 | 327 |
333 // Open times are in microseconds. | 328 // Open times are in microseconds. |
334 int64_t nexe_open_time_; | 329 int64_t nexe_open_time_; |
335 | 330 |
336 PP_Var manifest_data_var_; | 331 PP_Var manifest_data_var_; |
| 332 int32_t manifest_id_; |
337 | 333 |
338 const PPB_NaCl_Private* nacl_interface_; | 334 const PPB_NaCl_Private* nacl_interface_; |
339 pp::UMAPrivate uma_interface_; | 335 pp::UMAPrivate uma_interface_; |
340 }; | 336 }; |
341 | 337 |
342 } // namespace plugin | 338 } // namespace plugin |
343 | 339 |
344 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PLUGIN_H_ | 340 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PLUGIN_H_ |
OLD | NEW |