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 30 matching lines...) Expand all Loading... |
41 private: | 41 private: |
42 static const char kResourceInfoUrl[]; | 42 static const char kResourceInfoUrl[]; |
43 }; | 43 }; |
44 | 44 |
45 // Loads a list of resources, providing a way to get file descriptors for | 45 // Loads a list of resources, providing a way to get file descriptors for |
46 // these resources. URLs for resources are resolved by the manifest | 46 // these resources. URLs for resources are resolved by the manifest |
47 // and point to pnacl component filesystem resources. | 47 // and point to pnacl component filesystem resources. |
48 class PnaclResources { | 48 class PnaclResources { |
49 public: | 49 public: |
50 PnaclResources(Plugin* plugin, | 50 PnaclResources(Plugin* plugin, |
51 PnaclCoordinator* coordinator, | 51 PnaclCoordinator* coordinator) |
52 const Manifest* manifest) | |
53 : plugin_(plugin), | 52 : plugin_(plugin), |
54 coordinator_(coordinator), | 53 coordinator_(coordinator) { |
55 manifest_(manifest) { | |
56 } | 54 } |
57 virtual ~PnaclResources(); | 55 virtual ~PnaclResources(); |
58 | 56 |
59 // Read the resource info JSON file. This is the first step after | 57 // Read the resource info JSON file. This is the first step after |
60 // construction; it has to be completed before StartLoad is called. | 58 // construction; it has to be completed before StartLoad is called. |
61 virtual void ReadResourceInfo( | 59 virtual void ReadResourceInfo( |
62 const nacl::string& resource_info_url, | 60 const nacl::string& resource_info_url, |
63 const pp::CompletionCallback& resource_info_read_cb); | 61 const pp::CompletionCallback& resource_info_read_cb); |
64 | 62 |
65 // Start loading the resources. | 63 // Start loading the resources. |
(...skipping 17 matching lines...) Expand all Loading... |
83 | 81 |
84 static int32_t GetPnaclFD(Plugin* plugin, const char* filename); | 82 static int32_t GetPnaclFD(Plugin* plugin, const char* filename); |
85 | 83 |
86 private: | 84 private: |
87 NACL_DISALLOW_COPY_AND_ASSIGN(PnaclResources); | 85 NACL_DISALLOW_COPY_AND_ASSIGN(PnaclResources); |
88 | 86 |
89 // The plugin requesting the resource loading. | 87 // The plugin requesting the resource loading. |
90 Plugin* plugin_; | 88 Plugin* plugin_; |
91 // The coordinator responsible for reporting errors, etc. | 89 // The coordinator responsible for reporting errors, etc. |
92 PnaclCoordinator* coordinator_; | 90 PnaclCoordinator* coordinator_; |
93 // The manifest for looking up resource URLs. | |
94 const Manifest* manifest_; | |
95 // The descriptor wrappers for the downloaded URLs. Only valid | 91 // The descriptor wrappers for the downloaded URLs. Only valid |
96 // once all_loaded_callback_ has been invoked. | 92 // once all_loaded_callback_ has been invoked. |
97 std::map<nacl::string, nacl::DescWrapper*> resource_wrappers_; | 93 std::map<nacl::string, nacl::DescWrapper*> resource_wrappers_; |
98 | 94 |
99 // Tool names for llc and ld; read from the resource info file. | 95 // Tool names for llc and ld; read from the resource info file. |
100 nacl::string llc_tool_name; | 96 nacl::string llc_tool_name; |
101 nacl::string ld_tool_name; | 97 nacl::string ld_tool_name; |
102 | 98 |
103 // Parses resource info json data in |buf|. Returns true if successful. | 99 // Parses resource info json data in |buf|. Returns true if successful. |
104 // Otherwise returns false and places an error message in |errmsg|. | 100 // Otherwise returns false and places an error message in |errmsg|. |
105 bool ParseResourceInfo(const nacl::string& buf, nacl::string& errmsg); | 101 bool ParseResourceInfo(const nacl::string& buf, nacl::string& errmsg); |
106 | 102 |
107 // Convenience function for reporting an error while reading the resource | 103 // Convenience function for reporting an error while reading the resource |
108 // info file. | 104 // info file. |
109 void ReadResourceInfoError(const nacl::string& msg); | 105 void ReadResourceInfoError(const nacl::string& msg); |
110 }; | 106 }; |
111 | 107 |
112 } // namespace plugin; | 108 } // namespace plugin; |
113 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_RESOURCES_H_ | 109 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_RESOURCES_H_ |
OLD | NEW |