• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2012 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef COMPONENTS_NACL_RENDERER_PLUGIN_PNACL_RESOURCES_H_
6 #define COMPONENTS_NACL_RENDERER_PLUGIN_PNACL_RESOURCES_H_
7 
8 #include "components/nacl/renderer/ppb_nacl_private.h"
9 #include "ppapi/cpp/completion_callback.h"
10 
11 namespace plugin {
12 
13 class Plugin;
14 
15 // PNaCl tool files / resources, which are opened by the browser.
16 struct PnaclResourceEntry {
17   // The name of the tool that corresponds to the opened file.
18   std::string tool_name;
19 
20   // File info for the executables, after they've been opened.
21   // Only valid after StartLoad() has been called, and until
22   // TakeFileInfo(ResourceType) is called.
23   PP_NaClFileInfo file_info;
24 };
25 
26 // Loads a list of resources, providing a way to get file descriptors for
27 // these resources.  URLs for resources are resolved by the manifest
28 // and point to PNaCl component filesystem resources.
29 class PnaclResources {
30  public:
31   PnaclResources(Plugin* plugin, bool use_subzero);
32 
33   PnaclResources(const PnaclResources&) = delete;
34   PnaclResources& operator=(const PnaclResources&) = delete;
35 
36   virtual ~PnaclResources();
37 
38   // Read the resource info JSON file.  This is the first step after
39   // construction; it has to be completed before StartLoad is called.
40   bool ReadResourceInfo();
41 
42   // Start loading the resources.
43   bool StartLoad();
44 
45   enum ResourceType { LLC, LD, SUBZERO, NUM_TYPES };
46 
47   const std::string& GetUrl(ResourceType type) const;
48 
49   PP_NaClFileInfo TakeFileInfo(ResourceType type);
50 
51  private:
52   // The plugin requesting the resource loading.
53   Plugin* plugin_;
54   bool use_subzero_;
55 
56   PnaclResourceEntry resources_[NUM_TYPES + 1];
57 };
58 
59 }  // namespace plugin
60 #endif  // COMPONENTS_NACL_RENDERER_PLUGIN_PNACL_RESOURCES_H_
61