cc: Added inline to Tile::IsReadyToDraw
[chromium-blink-merge.git] / ppapi / native_client / src / trusted / plugin / json_manifest.h
blob24dd28a1639be6cbe3445a8dddaec49a07bf0b0b
1 /*
2 * Copyright (c) 2012 The Chromium 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 */
7 // Manifest processing for JSON manifests.
9 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_JSON_MANIFEST_H_
10 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_JSON_MANIFEST_H_
12 #include <map>
13 #include <set>
14 #include <string>
16 #include "native_client/src/include/nacl_macros.h"
17 #include "native_client/src/include/nacl_string.h"
18 #include "ppapi/native_client/src/trusted/plugin/manifest.h"
19 #include "third_party/jsoncpp/source/include/json/value.h"
21 namespace pp {
22 class URLUtil_Dev;
23 } // namespace pp
25 namespace plugin {
27 class ErrorInfo;
28 class PnaclOptions;
30 class JsonManifest : public Manifest {
31 public:
32 JsonManifest(const pp::URLUtil_Dev* url_util,
33 const nacl::string& manifest_base_url,
34 const nacl::string& sandbox_isa)
35 : url_util_(url_util),
36 manifest_base_url_(manifest_base_url),
37 sandbox_isa_(sandbox_isa),
38 dictionary_(Json::nullValue) { }
39 virtual ~JsonManifest() { }
41 // Initialize the manifest object for use by later lookups. The return
42 // value is true if the manifest parses correctly and matches the schema.
43 bool Init(const nacl::string& json, ErrorInfo* error_info);
45 // Gets the full program URL for the current sandbox ISA from the
46 // manifest file.
47 virtual bool GetProgramURL(nacl::string* full_url,
48 PnaclOptions* pnacl_options,
49 ErrorInfo* error_info) const;
51 // Resolves a URL relative to the manifest base URL
52 virtual bool ResolveURL(const nacl::string& relative_url,
53 nacl::string* full_url,
54 ErrorInfo* error_info) const;
56 // Gets the file names from the "files" section of the manifest. No
57 // checking that the keys' values are proper ISA dictionaries -- it
58 // is assumed that other consistency checks take care of that, and
59 // that the keys are appropriate for use with ResolveKey.
60 virtual bool GetFileKeys(std::set<nacl::string>* keys) const;
62 // Resolves a key from the "files" section to a fully resolved URL,
63 // i.e., relative URL values are fully expanded relative to the
64 // manifest's URL (via ResolveURL).
65 // If there was an error, details are reported via error_info.
66 virtual bool ResolveKey(const nacl::string& key,
67 nacl::string* full_url,
68 PnaclOptions* pnacl_options,
69 ErrorInfo* error_info) const;
71 private:
72 NACL_DISALLOW_COPY_AND_ASSIGN(JsonManifest);
74 // Checks that |dictionary_| is a valid manifest, according to the schema.
75 // Returns true on success, and sets |error_info| to a detailed message
76 // if not.
77 bool MatchesSchema(ErrorInfo* error_info);
79 const pp::URLUtil_Dev* url_util_;
80 nacl::string manifest_base_url_;
81 nacl::string sandbox_isa_;
83 Json::Value dictionary_;
87 } // namespace plugin
89 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_JSON_MANIFEST_H_