| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (c) 2011 The Native Client Authors. All rights reserved. | |
| 3 * Use of this source code is governed by a BSD-style license that can be | |
| 4 * found in the LICENSE file. | |
| 5 */ | |
| 6 | |
| 7 // Manifest file processing class. | |
| 8 | |
| 9 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_MANIFEST_H_ | |
| 10 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_MANIFEST_H_ | |
| 11 | |
| 12 #include <map> | |
| 13 #include <set> | |
| 14 #include <string> | |
| 15 | |
| 16 #include "native_client/src/include/nacl_macros.h" | |
| 17 #include "native_client/src/include/nacl_string.h" | |
| 18 #include "native_client/src/third_party_mod/jsoncpp/include/json/value.h" | |
| 19 | |
| 20 namespace pp { | |
| 21 class URLUtil_Dev; | |
| 22 } // namespace pp | |
| 23 | |
| 24 namespace plugin { | |
| 25 | |
| 26 class ErrorInfo; | |
| 27 | |
| 28 class Manifest { | |
| 29 public: | |
| 30 Manifest(const pp::URLUtil_Dev* url_util, | |
| 31 const nacl::string& manifest_base_url, | |
| 32 const nacl::string& sandbox_isa) | |
| 33 : url_util_(url_util), | |
| 34 manifest_base_url_(manifest_base_url), | |
| 35 sandbox_isa_(sandbox_isa), | |
| 36 dictionary_(Json::nullValue) { } | |
| 37 ~Manifest() { } | |
| 38 | |
| 39 // Determines whether portable programs are chosen in manifest files over | |
| 40 // native programs. Normally the native version is selected if available. | |
| 41 static bool PreferPortable(); | |
| 42 | |
| 43 // Initialize the manifest object for use by later lookups. The return | |
| 44 // value is true if the manifest parses correctly and matches the schema. | |
| 45 bool Init(const nacl::string& json, ErrorInfo* error_info); | |
| 46 | |
| 47 // Gets the full program URL for the current sandbox ISA from the | |
| 48 // manifest file. Sets |is_portable| to |true| if the program is | |
| 49 // portable bitcode. | |
| 50 bool GetProgramURL(nacl::string* full_url, | |
| 51 ErrorInfo* error_info, | |
| 52 bool* is_portable); | |
| 53 | |
| 54 // TODO(jvoung): Get rid of these when we find a better way to | |
| 55 // store / install these. | |
| 56 // Gets the full nexe URL for the LLC nexe from the manifest file. | |
| 57 bool GetLLCURL(nacl::string* full_url, ErrorInfo* error_info); | |
| 58 | |
| 59 // Gets the full nexe URL for the LD nexe from the manifest file. | |
| 60 bool GetLDURL(nacl::string* full_url, ErrorInfo* error_info); | |
| 61 // end TODO(jvoung) | |
| 62 | |
| 63 // Resolves a URL relative to the manifest base URL | |
| 64 bool ResolveURL(const nacl::string& relative_url, | |
| 65 nacl::string* full_url, | |
| 66 ErrorInfo* error_info) const; | |
| 67 | |
| 68 // Gets the file names from the "files" section of the manifest. No | |
| 69 // checking that the keys' values are proper ISA dictionaries -- it | |
| 70 // is assumed that other consistency checks take care of that, and | |
| 71 // that the keys are appropriate for use with ResolveKey. | |
| 72 bool GetFileKeys(std::set<nacl::string>* keys) const; | |
| 73 | |
| 74 // Resolves a key from the "files" section to a fully resolved URL, | |
| 75 // i.e., relative URL values are fully expanded relative to the | |
| 76 // manifest's URL (via ResolveURL). If there was an error, details | |
| 77 // are reported via error_info, and is_portable, if non-NULL, tells | |
| 78 // the caller whether the resolution used the portable | |
| 79 // representation or an ISA-specific version of the file. | |
| 80 bool ResolveKey(const nacl::string& key, | |
| 81 nacl::string* full_url, | |
| 82 ErrorInfo* error_info, | |
| 83 bool* is_portable) const; | |
| 84 | |
| 85 private: | |
| 86 const pp::URLUtil_Dev* url_util_; | |
| 87 nacl::string manifest_base_url_; | |
| 88 nacl::string sandbox_isa_; | |
| 89 Json::Value dictionary_; | |
| 90 | |
| 91 // Checks that |dictionary_| is a valid manifest, according to the schema. | |
| 92 // Returns true on success, and sets |error_info| to a detailed message | |
| 93 // if not. | |
| 94 bool MatchesSchema(ErrorInfo* error_info); | |
| 95 | |
| 96 NACL_DISALLOW_COPY_AND_ASSIGN(Manifest); | |
| 97 }; | |
| 98 | |
| 99 | |
| 100 } // namespace plugin | |
| 101 | |
| 102 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_MANIFEST_H_ | |
| OLD | NEW |