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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 nacl::DescWrapperFactory* wrapper_factory() const { return wrapper_factory_; } | 142 nacl::DescWrapperFactory* wrapper_factory() const { return wrapper_factory_; } |
143 | 143 |
144 // Requests a NaCl manifest download from a |url| relative to the page origin. | 144 // Requests a NaCl manifest download from a |url| relative to the page origin. |
145 void RequestNaClManifest(const nacl::string& url); | 145 void RequestNaClManifest(const nacl::string& url); |
146 | 146 |
147 // Called back by CallOnMainThread. Dispatches the first enqueued progress | 147 // Called back by CallOnMainThread. Dispatches the first enqueued progress |
148 // event. | 148 // event. |
149 void DispatchProgressEvent(int32_t result); | 149 void DispatchProgressEvent(int32_t result); |
150 | 150 |
151 // Requests a URL asynchronously resulting in a call to pp_callback with | 151 // Requests a URL asynchronously resulting in a call to pp_callback with |
152 // a PP_Error indicating status. On success an open file descriptor | 152 // a PP_Error indicating status. |
153 // corresponding to the url body is recorded for further lookup. | |
154 bool StreamAsFile(const nacl::string& url, | 153 bool StreamAsFile(const nacl::string& url, |
| 154 NaClFileInfo *out_file_info, |
155 const pp::CompletionCallback& callback); | 155 const pp::CompletionCallback& callback); |
156 | 156 |
157 // Returns rich information for a file retrieved by StreamAsFile(). This info | |
158 // contains a file descriptor. The caller must take ownership of this | |
159 // descriptor. | |
160 struct NaClFileInfo GetFileInfo(const nacl::string& url); | |
161 | |
162 // A helper function that indicates if |url| can be requested by the document | 157 // 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 | 158 // 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. | 159 // document to request the URL using CORS even if this function returns false. |
165 bool DocumentCanRequest(const std::string& url); | 160 bool DocumentCanRequest(const std::string& url); |
166 | 161 |
167 // set_exit_status may be called off the main thread. | 162 // set_exit_status may be called off the main thread. |
168 void set_exit_status(int exit_status); | 163 void set_exit_status(int exit_status); |
169 | 164 |
170 const PPB_NaCl_Private* nacl_interface() const { return nacl_interface_; } | 165 const PPB_NaCl_Private* nacl_interface() const { return nacl_interface_; } |
171 pp::UMAPrivate& uma_interface() { return uma_interface_; } | 166 pp::UMAPrivate& uma_interface() { return uma_interface_; } |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 void ProcessNaClManifest(const nacl::string& manifest_json); | 243 void ProcessNaClManifest(const nacl::string& manifest_json); |
249 | 244 |
250 // Logs timing information to a UMA histogram, and also logs the same timing | 245 // Logs timing information to a UMA histogram, and also logs the same timing |
251 // information divided by the size of the nexe to another histogram. | 246 // information divided by the size of the nexe to another histogram. |
252 void HistogramStartupTimeSmall(const std::string& name, float dt); | 247 void HistogramStartupTimeSmall(const std::string& name, float dt); |
253 void HistogramStartupTimeMedium(const std::string& name, float dt); | 248 void HistogramStartupTimeMedium(const std::string& name, float dt); |
254 | 249 |
255 // Callback used when loading a URL for SRPC-based StreamAsFile(). | 250 // Callback used when loading a URL for SRPC-based StreamAsFile(). |
256 void UrlDidOpenForStreamAsFile(int32_t pp_error, | 251 void UrlDidOpenForStreamAsFile(int32_t pp_error, |
257 FileDownloader* url_downloader, | 252 FileDownloader* url_downloader, |
| 253 NaClFileInfo* out_file_info, |
258 pp::CompletionCallback pp_callback); | 254 pp::CompletionCallback pp_callback); |
259 | 255 |
260 // Open an app file by requesting a file descriptor from the browser. This | 256 // Open an app file by requesting a file descriptor from the browser. This |
261 // method first checks that the url is for an installed file before making the | 257 // method first checks that the url is for an installed file before making the |
262 // request so it won't slow down non-installed file downloads. | 258 // request so it won't slow down non-installed file downloads. |
263 bool OpenURLFast(const nacl::string& url, FileDownloader* downloader); | 259 bool OpenURLFast(const nacl::string& url, FileDownloader* downloader); |
264 | 260 |
265 void SetExitStatusOnMainThread(int32_t pp_error, int exit_status); | 261 void SetExitStatusOnMainThread(int32_t pp_error, int exit_status); |
266 | 262 |
267 // Keep track of the NaCl module subprocess that was spun up in the plugin. | 263 // Keep track of the NaCl module subprocess that was spun up in the plugin. |
268 NaClSubprocess main_subprocess_; | 264 NaClSubprocess main_subprocess_; |
269 | 265 |
270 bool uses_nonsfi_mode_; | 266 bool uses_nonsfi_mode_; |
271 | 267 |
272 nacl::DescWrapperFactory* wrapper_factory_; | 268 nacl::DescWrapperFactory* wrapper_factory_; |
273 | 269 |
274 // Original, unresolved URL for the .nexe program to load. | 270 // Original, unresolved URL for the .nexe program to load. |
275 std::string program_url_; | 271 std::string program_url_; |
276 | 272 |
277 pp::CompletionCallbackFactory<Plugin> callback_factory_; | 273 pp::CompletionCallbackFactory<Plugin> callback_factory_; |
278 | 274 |
279 nacl::scoped_ptr<PnaclCoordinator> pnacl_coordinator_; | 275 nacl::scoped_ptr<PnaclCoordinator> pnacl_coordinator_; |
280 | 276 |
281 // Keep track of the FileDownloaders created to fetch urls. | 277 // Keep track of the FileDownloaders created to fetch urls. |
282 std::set<FileDownloader*> url_downloaders_; | 278 std::set<FileDownloader*> url_downloaders_; |
283 // Keep track of file descriptors opened by StreamAsFile(). | |
284 // These are owned by the browser. | |
285 std::map<nacl::string, NaClFileInfoAutoCloser*> url_file_info_map_; | |
286 | 279 |
287 // Callback to receive .nexe and .dso download progress notifications. | 280 // Callback to receive .nexe and .dso download progress notifications. |
288 static void UpdateDownloadProgress( | 281 static void UpdateDownloadProgress( |
289 PP_Instance pp_instance, | 282 PP_Instance pp_instance, |
290 PP_Resource pp_resource, | 283 PP_Resource pp_resource, |
291 int64_t bytes_sent, | 284 int64_t bytes_sent, |
292 int64_t total_bytes_to_be_sent, | 285 int64_t total_bytes_to_be_sent, |
293 int64_t bytes_received, | 286 int64_t bytes_received, |
294 int64_t total_bytes_to_be_received); | 287 int64_t total_bytes_to_be_received); |
295 | 288 |
296 // Finds the file downloader which owns the given URL loader. This is used | 289 // Finds the file downloader which owns the given URL loader. This is used |
297 // in UpdateDownloadProgress to map a url loader back to the URL being | 290 // in UpdateDownloadProgress to map a url loader back to the URL being |
298 // downloaded. | 291 // downloaded. |
299 const FileDownloader* FindFileDownloader(PP_Resource url_loader) const; | 292 const FileDownloader* FindFileDownloader(PP_Resource url_loader) const; |
300 | 293 |
301 int64_t time_of_last_progress_event_; | 294 int64_t time_of_last_progress_event_; |
302 int exit_status_; | 295 int exit_status_; |
303 | 296 |
304 int32_t manifest_id_; | 297 int32_t manifest_id_; |
305 | 298 |
306 PP_FileHandle nexe_handle_; | 299 PP_FileHandle nexe_handle_; |
307 | 300 |
308 const PPB_NaCl_Private* nacl_interface_; | 301 const PPB_NaCl_Private* nacl_interface_; |
309 pp::UMAPrivate uma_interface_; | 302 pp::UMAPrivate uma_interface_; |
310 }; | 303 }; |
311 | 304 |
312 } // namespace plugin | 305 } // namespace plugin |
313 | 306 |
314 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PLUGIN_H_ | 307 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PLUGIN_H_ |
OLD | NEW |