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_ |
11 | 11 |
12 #include <stdio.h> | 12 #include <stdio.h> |
13 | 13 |
14 #include <map> | 14 #include <map> |
15 #include <queue> | 15 #include <queue> |
16 #include <set> | 16 #include <set> |
17 #include <string> | 17 #include <string> |
18 | 18 |
19 #include "native_client/src/include/nacl_macros.h" | 19 #include "native_client/src/include/nacl_macros.h" |
20 #include "native_client/src/include/nacl_scoped_ptr.h" | 20 #include "native_client/src/include/nacl_scoped_ptr.h" |
21 #include "native_client/src/include/nacl_string.h" | 21 #include "native_client/src/include/nacl_string.h" |
22 #include "native_client/src/trusted/plugin/file_downloader.h" | 22 #include "native_client/src/trusted/plugin/file_downloader.h" |
23 #include "native_client/src/trusted/plugin/nacl_subprocess.h" | 23 #include "native_client/src/trusted/plugin/nacl_subprocess.h" |
24 #include "native_client/src/trusted/plugin/pnacl_coordinator.h" | 24 #include "native_client/src/trusted/plugin/pnacl_coordinator.h" |
25 #include "native_client/src/trusted/plugin/service_runtime.h" | 25 #include "native_client/src/trusted/plugin/service_runtime.h" |
26 #include "native_client/src/trusted/plugin/utility.h" | 26 #include "native_client/src/trusted/plugin/utility.h" |
| 27 #include "native_client/src/trusted/reverse_service/nacl_file_info.h" |
27 | 28 |
28 #include "ppapi/c/private/ppb_nacl_private.h" | 29 #include "ppapi/c/private/ppb_nacl_private.h" |
29 #include "ppapi/cpp/private/var_private.h" | 30 #include "ppapi/cpp/private/var_private.h" |
30 // for pp::VarPrivate | 31 // for pp::VarPrivate |
31 #include "ppapi/cpp/private/instance_private.h" | 32 #include "ppapi/cpp/private/instance_private.h" |
32 #include "ppapi/cpp/rect.h" | 33 #include "ppapi/cpp/rect.h" |
33 #include "ppapi/cpp/url_loader.h" | 34 #include "ppapi/cpp/url_loader.h" |
34 #include "ppapi/cpp/var.h" | 35 #include "ppapi/cpp/var.h" |
35 #include "ppapi/cpp/view.h" | 36 #include "ppapi/cpp/view.h" |
36 | 37 |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 | 246 |
246 // Called back by CallOnMainThread. Dispatches the first enqueued progress | 247 // Called back by CallOnMainThread. Dispatches the first enqueued progress |
247 // event. | 248 // event. |
248 void DispatchProgressEvent(int32_t result); | 249 void DispatchProgressEvent(int32_t result); |
249 | 250 |
250 // Requests a URL asynchronously resulting in a call to pp_callback with | 251 // Requests a URL asynchronously resulting in a call to pp_callback with |
251 // a PP_Error indicating status. On success an open file descriptor | 252 // a PP_Error indicating status. On success an open file descriptor |
252 // corresponding to the url body is recorded for further lookup. | 253 // corresponding to the url body is recorded for further lookup. |
253 bool StreamAsFile(const nacl::string& url, | 254 bool StreamAsFile(const nacl::string& url, |
254 PP_CompletionCallback pp_callback); | 255 PP_CompletionCallback pp_callback); |
255 // Returns an open POSIX file descriptor retrieved by StreamAsFile() | 256 |
256 // or NACL_NO_FILE_DESC. The caller must take ownership of the descriptor. | 257 // Returns rich information for a file retrieved by StreamAsFile(). This info |
257 int32_t GetPOSIXFileDesc(const nacl::string& url); | 258 // contains a file descriptor. The caller must take ownership of this |
| 259 // descriptor. |
| 260 struct NaClFileInfo GetFileInfo(const nacl::string& url); |
258 | 261 |
259 // A helper function that gets the scheme type for |url|. Uses URLUtil_Dev | 262 // A helper function that gets the scheme type for |url|. Uses URLUtil_Dev |
260 // interface which this class has as a member. | 263 // interface which this class has as a member. |
261 UrlSchemeType GetUrlScheme(const std::string& url); | 264 UrlSchemeType GetUrlScheme(const std::string& url); |
262 | 265 |
263 // A helper function that indicates if |url| can be requested by the document | 266 // A helper function that indicates if |url| can be requested by the document |
264 // under the same-origin policy. Strictly speaking, it may be possible for the | 267 // under the same-origin policy. Strictly speaking, it may be possible for the |
265 // document to request the URL using CORS even if this function returns false. | 268 // document to request the URL using CORS even if this function returns false. |
266 bool DocumentCanRequest(const std::string& url); | 269 bool DocumentCanRequest(const std::string& url); |
267 | 270 |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 // it and replay it to nexe after it's loaded. We need to replay when this | 471 // it and replay it to nexe after it's loaded. We need to replay when this |
469 // URLLoader resource is non-is_null(). | 472 // URLLoader resource is non-is_null(). |
470 pp::URLLoader document_load_to_replay_; | 473 pp::URLLoader document_load_to_replay_; |
471 | 474 |
472 nacl::string mime_type_; | 475 nacl::string mime_type_; |
473 | 476 |
474 // Keep track of the FileDownloaders created to fetch urls. | 477 // Keep track of the FileDownloaders created to fetch urls. |
475 std::set<FileDownloader*> url_downloaders_; | 478 std::set<FileDownloader*> url_downloaders_; |
476 // Keep track of file descriptors opened by StreamAsFile(). | 479 // Keep track of file descriptors opened by StreamAsFile(). |
477 // These are owned by the browser. | 480 // These are owned by the browser. |
478 std::map<nacl::string, int32_t> url_fd_map_; | 481 std::map<nacl::string, struct NaClFileInfo> url_file_info_map_; |
479 | 482 |
480 // Pending progress events. | 483 // Pending progress events. |
481 std::queue<ProgressEvent*> progress_events_; | 484 std::queue<ProgressEvent*> progress_events_; |
482 | 485 |
483 // Used for NexeFileDidOpenContinuation | 486 // Used for NexeFileDidOpenContinuation |
484 int64_t load_start_; | 487 int64_t load_start_; |
485 | 488 |
486 int64_t init_time_; | 489 int64_t init_time_; |
487 int64_t ready_time_; | 490 int64_t ready_time_; |
488 size_t nexe_size_; | 491 size_t nexe_size_; |
(...skipping 13 matching lines...) Expand all Loading... |
502 const FileDownloader* FindFileDownloader(PP_Resource url_loader) const; | 505 const FileDownloader* FindFileDownloader(PP_Resource url_loader) const; |
503 | 506 |
504 int64_t time_of_last_progress_event_; | 507 int64_t time_of_last_progress_event_; |
505 | 508 |
506 const PPB_NaCl_Private* nacl_interface_; | 509 const PPB_NaCl_Private* nacl_interface_; |
507 }; | 510 }; |
508 | 511 |
509 } // namespace plugin | 512 } // namespace plugin |
510 | 513 |
511 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PLUGIN_H_ | 514 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PLUGIN_H_ |
OLD | NEW |