OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_RESOURCES_H_ | 5 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_RESOURCES_H_ |
6 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_RESOURCES_H_ | 6 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_RESOURCES_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 28 matching lines...) Expand all Loading... |
39 }; | 39 }; |
40 | 40 |
41 // Loads a list of resources, providing a way to get file descriptors for | 41 // Loads a list of resources, providing a way to get file descriptors for |
42 // these resources. URLs for resources are resolved by the manifest | 42 // these resources. URLs for resources are resolved by the manifest |
43 // and point to pnacl component filesystem resources. | 43 // and point to pnacl component filesystem resources. |
44 class PnaclResources { | 44 class PnaclResources { |
45 public: | 45 public: |
46 PnaclResources(Plugin* plugin, | 46 PnaclResources(Plugin* plugin, |
47 PnaclCoordinator* coordinator) | 47 PnaclCoordinator* coordinator) |
48 : plugin_(plugin), | 48 : plugin_(plugin), |
49 coordinator_(coordinator) { | 49 coordinator_(coordinator), |
| 50 llc_file_handle_(PP_kInvalidFileHandle), |
| 51 ld_file_handle_(PP_kInvalidFileHandle) { |
50 } | 52 } |
51 virtual ~PnaclResources(); | 53 virtual ~PnaclResources(); |
52 | 54 |
53 // Read the resource info JSON file. This is the first step after | 55 // Read the resource info JSON file. This is the first step after |
54 // construction; it has to be completed before StartLoad is called. | 56 // construction; it has to be completed before StartLoad is called. |
55 virtual void ReadResourceInfo( | 57 virtual void ReadResourceInfo( |
56 const nacl::string& resource_info_url, | 58 const nacl::string& resource_info_url, |
57 const pp::CompletionCallback& resource_info_read_cb); | 59 const pp::CompletionCallback& resource_info_read_cb); |
58 | 60 |
59 // Start loading the resources. | 61 // Start loading the resources. |
60 virtual void StartLoad( | 62 virtual void StartLoad( |
61 const pp::CompletionCallback& all_loaded_callback); | 63 const pp::CompletionCallback& all_loaded_callback); |
62 | 64 |
63 const nacl::string& GetLlcUrl() { return llc_tool_name_; } | 65 const nacl::string& GetLlcUrl() { return llc_tool_name_; } |
64 const nacl::string& GetLdUrl() { return ld_tool_name_; } | 66 const nacl::string& GetLdUrl() { return ld_tool_name_; } |
65 | 67 |
66 nacl::string GetFullUrl(const nacl::string& partial_url, | 68 PP_FileHandle TakeLlcFileHandle(); |
67 const nacl::string& sandbox_arch) const; | 69 PP_FileHandle TakeLdFileHandle(); |
68 | |
69 // Get file descs by name. Only valid after StartLoad's completion callback | |
70 // fired. | |
71 nacl::DescWrapper* WrapperForUrl(const nacl::string& url); | |
72 | |
73 static int32_t GetPnaclFD(Plugin* plugin, const char* filename); | |
74 | 70 |
75 private: | 71 private: |
76 NACL_DISALLOW_COPY_AND_ASSIGN(PnaclResources); | 72 NACL_DISALLOW_COPY_AND_ASSIGN(PnaclResources); |
77 | 73 |
78 // The plugin requesting the resource loading. | 74 // The plugin requesting the resource loading. |
79 Plugin* plugin_; | 75 Plugin* plugin_; |
80 // The coordinator responsible for reporting errors, etc. | 76 // The coordinator responsible for reporting errors, etc. |
81 PnaclCoordinator* coordinator_; | 77 PnaclCoordinator* coordinator_; |
82 // The descriptor wrappers for the downloaded URLs. Only valid | |
83 // once all_loaded_callback_ has been invoked. | |
84 std::map<nacl::string, nacl::DescWrapper*> resource_wrappers_; | |
85 | 78 |
86 // Tool names for llc and ld; read from the resource info file. | 79 // Tool names for llc and ld; read from the resource info file. |
87 nacl::string llc_tool_name_; | 80 nacl::string llc_tool_name_; |
88 nacl::string ld_tool_name_; | 81 nacl::string ld_tool_name_; |
| 82 |
| 83 // File handles for llc and ld executables, after they've been opened. |
| 84 // Only valid after the callback for StartLoad() has been called, and until |
| 85 // TakeLlcFileHandle()/TakeLdFileHandle() is called. |
| 86 PP_FileHandle llc_file_handle_; |
| 87 PP_FileHandle ld_file_handle_; |
89 }; | 88 }; |
90 | 89 |
91 } // namespace plugin; | 90 } // namespace plugin; |
92 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_RESOURCES_H_ | 91 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_RESOURCES_H_ |
OLD | NEW |