| 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 COMPONENTS_NACL_RENDERER_PLUGIN_PNACL_RESOURCES_H_ | 5 #ifndef COMPONENTS_NACL_RENDERER_PLUGIN_PNACL_RESOURCES_H_ |
| 6 #define COMPONENTS_NACL_RENDERER_PLUGIN_PNACL_RESOURCES_H_ | 6 #define COMPONENTS_NACL_RENDERER_PLUGIN_PNACL_RESOURCES_H_ |
| 7 | 7 |
| 8 #include <map> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "components/nacl/renderer/plugin/plugin_error.h" | |
| 12 #include "components/nacl/renderer/ppb_nacl_private.h" | 8 #include "components/nacl/renderer/ppb_nacl_private.h" |
| 13 #include "native_client/src/include/nacl_macros.h" | 9 #include "native_client/src/include/nacl_macros.h" |
| 14 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h" | 10 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h" |
| 15 #include "ppapi/cpp/completion_callback.h" | 11 #include "ppapi/cpp/completion_callback.h" |
| 16 | 12 |
| 17 namespace plugin { | 13 namespace plugin { |
| 18 | 14 |
| 19 class Plugin; | 15 class Plugin; |
| 20 | 16 |
| 17 // PNaCl tool files / resources, which are opened by the browser. |
| 18 struct PnaclResourceEntry { |
| 19 // The name of the tool that corresponds to the opened file. |
| 20 std::string tool_name; |
| 21 |
| 22 // File info for the executables, after they've been opened. |
| 23 // Only valid after StartLoad() has been called, and until |
| 24 // TakeFileInfo(ResourceType) is called. |
| 25 PP_NaClFileInfo file_info; |
| 26 }; |
| 27 |
| 21 // Loads a list of resources, providing a way to get file descriptors for | 28 // Loads a list of resources, providing a way to get file descriptors for |
| 22 // these resources. URLs for resources are resolved by the manifest | 29 // these resources. URLs for resources are resolved by the manifest |
| 23 // and point to pnacl component filesystem resources. | 30 // and point to PNaCl component filesystem resources. |
| 24 class PnaclResources { | 31 class PnaclResources { |
| 25 public: | 32 public: |
| 26 explicit PnaclResources(Plugin* plugin); | 33 PnaclResources(Plugin* plugin, bool use_subzero); |
| 27 virtual ~PnaclResources(); | 34 virtual ~PnaclResources(); |
| 28 | 35 |
| 29 // Read the resource info JSON file. This is the first step after | 36 // Read the resource info JSON file. This is the first step after |
| 30 // construction; it has to be completed before StartLoad is called. | 37 // construction; it has to be completed before StartLoad is called. |
| 31 bool ReadResourceInfo(); | 38 bool ReadResourceInfo(); |
| 32 | 39 |
| 33 // Start loading the resources. | 40 // Start loading the resources. |
| 34 bool StartLoad(); | 41 bool StartLoad(); |
| 35 | 42 |
| 36 const std::string& GetLlcUrl() { return llc_tool_name_; } | 43 enum ResourceType { LLC, LD, SUBZERO, NUM_TYPES }; |
| 37 const std::string& GetLdUrl() { return ld_tool_name_; } | |
| 38 | 44 |
| 39 PP_NaClFileInfo TakeLlcFileInfo(); | 45 const std::string& GetUrl(ResourceType type) const; |
| 40 PP_NaClFileInfo TakeLdFileInfo(); | 46 |
| 47 PP_NaClFileInfo TakeFileInfo(ResourceType type); |
| 41 | 48 |
| 42 private: | 49 private: |
| 43 NACL_DISALLOW_COPY_AND_ASSIGN(PnaclResources); | 50 NACL_DISALLOW_COPY_AND_ASSIGN(PnaclResources); |
| 44 | 51 |
| 45 // The plugin requesting the resource loading. | 52 // The plugin requesting the resource loading. |
| 46 Plugin* plugin_; | 53 Plugin* plugin_; |
| 54 bool use_subzero_; |
| 47 | 55 |
| 48 // Tool names for llc and ld; read from the resource info file. | 56 PnaclResourceEntry resources_[NUM_TYPES + 1]; |
| 49 std::string llc_tool_name_; | |
| 50 std::string ld_tool_name_; | |
| 51 | |
| 52 // File info for llc and ld executables, after they've been opened. | |
| 53 // Only valid after the callback for StartLoad() has been called, and until | |
| 54 // TakeLlcFileInfo()/TakeLdFileInfo() is called. | |
| 55 PP_NaClFileInfo llc_file_info_; | |
| 56 PP_NaClFileInfo ld_file_info_; | |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 } // namespace plugin | 59 } // namespace plugin |
| 60 #endif // COMPONENTS_NACL_RENDERER_PLUGIN_PNACL_RESOURCES_H_ | 60 #endif // COMPONENTS_NACL_RENDERER_PLUGIN_PNACL_RESOURCES_H_ |
| OLD | NEW |