Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Unified Diff: ppapi/native_client/src/trusted/plugin/json_manifest.cc

Issue 9355051: Plumb through cache_identity from manifest for first sketch of pnacl cache. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: compile Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ppapi/native_client/src/trusted/plugin/json_manifest.cc
diff --git a/ppapi/native_client/src/trusted/plugin/json_manifest.cc b/ppapi/native_client/src/trusted/plugin/json_manifest.cc
index af38a2fc3ea9dd3f6ff163eb3ff417515853633d..d0c63bd5c7390b4d88b478e5fc5e72f019d5755f 100644
--- a/ppapi/native_client/src/trusted/plugin/json_manifest.cc
+++ b/ppapi/native_client/src/trusted/plugin/json_manifest.cc
@@ -39,13 +39,21 @@ const char* const kPortableKey = "portable";
const char* const kPnaclTranslateKey = "pnacl-translate";
const char* const kUrlKey = "url";
+// Cache support keys
+const char* const kCacheIdentityKey = "sha256";
+
// Sample manifest file:
// {
// "program": {
// "x86-32": {"url": "myprogram_x86-32.nexe"},
// "x86-64": {"url": "myprogram_x86-64.nexe"},
// "arm": {"url": "myprogram_arm.nexe"},
-// "portable": {"pnacl-translate": {"url": "myprogram.pexe"} }
+// "portable": {
+// "pnacl-translate": {
+// "url": "myprogram.pexe",
+// "sha256": "..."
+// }
+// }
// },
// "interpreter": {
// "x86-32": {"url": "interpreter_x86-32.nexe"},
@@ -137,7 +145,8 @@ bool IsValidUrlSpec(const Json::Value& url_spec,
const nacl::string& parent_key,
nacl::string* error_string) {
static const char* kManifestUrlSpecProperties[] = {
- kUrlKey
+ kUrlKey,
+ kCacheIdentityKey,
};
if (!IsValidDictionary(url_spec, container_key, parent_key,
kManifestUrlSpecProperties,
@@ -246,19 +255,34 @@ bool IsValidISADictionary(const Json::Value& dictionary,
return true;
}
+bool GrabUrlAndCacheIdentity(const Json::Value& url_spec,
+ nacl::string* url,
+ nacl::string* cache_identity) {
+ *url = url_spec[kUrlKey].asString();
+ if (url_spec.isMember(kCacheIdentityKey)) {
+ *cache_identity = url_spec[kCacheIdentityKey].asString();
+ }
+}
+
bool GetURLFromISADictionary(const Json::Value& dictionary,
const nacl::string& parent_key,
const nacl::string& sandbox_isa,
bool prefer_portable,
nacl::string* url,
+ nacl::string* cache_identity,
nacl::string* error_string,
bool* pnacl_translate) {
- if (url == NULL || error_string == NULL || pnacl_translate == NULL)
+ if (url == NULL || cache_identity == NULL ||
+ error_string == NULL || pnacl_translate == NULL)
return false;
if (!IsValidISADictionary(dictionary, parent_key, sandbox_isa, error_string))
return false;
+ *url = "";
+ *cache_identity = "";
+ *pnacl_translate = false;
+
// The call to IsValidISADictionary() above guarantees that either
// sandbox_isa or kPortableKey is present in the dictionary.
bool has_portable = dictionary.isMember(kPortableKey);
@@ -273,12 +297,13 @@ bool GetURLFromISADictionary(const Json::Value& dictionary,
// Check if this requires a pnacl-translate, otherwise just grab the URL.
// We may have pnacl-translate for isa-specific bitcode for CPU tuning.
if (isa_spec.isMember(kPnaclTranslateKey)) {
- *url = isa_spec[kPnaclTranslateKey][kUrlKey].asString();
+ GrabUrlAndCacheIdentity(isa_spec[kPnaclTranslateKey], url, cache_identity);
*pnacl_translate = true;
} else {
- *url = isa_spec[kUrlKey].asString();
+ GrabUrlAndCacheIdentity(isa_spec[kPnaclTranslateKey], url, cache_identity);
sehr (please use chromium) 2012/02/22 19:30:37 The if guard makes sure that the dictionary index
jvoung - send to chromium... 2012/02/22 19:45:37 Good catch thanks! Copy-paste bug =(
*pnacl_translate = false;
}
+
return true;
}
@@ -288,11 +313,10 @@ bool GetKeyUrl(const Json::Value& dictionary,
const Manifest* manifest,
bool prefer_portable,
nacl::string* full_url,
+ nacl::string* cache_identity,
ErrorInfo* error_info,
bool* pnacl_translate) {
CHECK(full_url != NULL && error_info != NULL);
- *full_url = "";
- *pnacl_translate = false;
if (!dictionary.isMember(key)) {
error_info->SetReport(ERROR_MANIFEST_RESOLVE_URL,
"file key not found in manifest");
@@ -302,7 +326,8 @@ bool GetKeyUrl(const Json::Value& dictionary,
nacl::string error_string;
nacl::string relative_url;
if (!GetURLFromISADictionary(isa_dict, key, sandbox_isa, prefer_portable,
- &relative_url, &error_string, pnacl_translate)) {
+ &relative_url, cache_identity,
+ &error_string, pnacl_translate)) {
error_info->SetReport(ERROR_MANIFEST_RESOLVE_URL,
key + nacl::string(" manifest resolution error: ") +
error_string);
@@ -437,9 +462,11 @@ bool JsonManifest::ResolveURL(const nacl::string& relative_url,
}
bool JsonManifest::GetProgramURL(nacl::string* full_url,
+ nacl::string* cache_identity,
ErrorInfo* error_info,
bool* pnacl_translate) const {
- if (full_url == NULL || error_info == NULL || pnacl_translate == NULL)
+ if (full_url == NULL || cache_identity == NULL ||
+ error_info == NULL || pnacl_translate == NULL)
return false;
Json::Value program = dictionary_[kProgramKey];
@@ -452,6 +479,7 @@ bool JsonManifest::GetProgramURL(nacl::string* full_url,
sandbox_isa_,
prefer_portable_,
&nexe_url,
+ cache_identity,
&error_string,
pnacl_translate)) {
error_info->SetReport(ERROR_MANIFEST_GET_NEXE_URL,
@@ -479,19 +507,19 @@ bool JsonManifest::GetFileKeys(std::set<nacl::string>* keys) const {
bool JsonManifest::ResolveKey(const nacl::string& key,
nacl::string* full_url,
+ nacl::string* cache_identity,
ErrorInfo* error_info,
bool* pnacl_translate) const {
NaClLog(3, "JsonManifest::ResolveKey(%s)\n", key.c_str());
// key must be one of kProgramKey or kFileKey '/' file-section-key
- if (full_url == NULL || error_info == NULL || pnacl_translate == NULL)
+ if (full_url == NULL || cache_identity == NULL ||
+ error_info == NULL || pnacl_translate == NULL)
return false;
- *full_url = "";
- *pnacl_translate = false;
if (key == kProgramKey) {
return GetKeyUrl(dictionary_, key, sandbox_isa_, this, prefer_portable_,
- full_url, error_info, pnacl_translate);
+ full_url, cache_identity, error_info, pnacl_translate);
}
nacl::string::const_iterator p = find(key.begin(), key.end(), '/');
if (p == key.end()) {
@@ -526,7 +554,7 @@ bool JsonManifest::ResolveKey(const nacl::string& key,
return false;
}
return GetKeyUrl(files, rest, sandbox_isa_, this, prefer_portable_,
- full_url, error_info, pnacl_translate);
+ full_url, cache_identity, error_info, pnacl_translate);
}
} // namespace plugin

Powered by Google App Engine
This is Rietveld 408576698