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

Side by Side Diff: ppapi/native_client/src/trusted/plugin/json_manifest.cc

Issue 14069002: Allow to have different files for different ISAs in NaCl manifest. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "native_client/src/trusted/plugin/json_manifest.h" 9 #include "native_client/src/trusted/plugin/json_manifest.h"
10 10
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 // Could be "arch/portable" : URLSpec, or 240 // Could be "arch/portable" : URLSpec, or
241 // it could be "arch/portable" : { "pnacl-translate": URLSpec } 241 // it could be "arch/portable" : { "pnacl-translate": URLSpec }
242 // for executables that need to be translated. 242 // for executables that need to be translated.
243 Json::Value property_value = dictionary[property_name]; 243 Json::Value property_value = dictionary[property_name];
244 nacl::string error_string; 244 nacl::string error_string;
245 if (!IsValidUrlSpec(property_value, property_name, parent_key, 245 if (!IsValidUrlSpec(property_value, property_name, parent_key,
246 &error_string) && 246 &error_string) &&
247 !IsValidPnaclTranslateSpec(property_value, property_name, 247 !IsValidPnaclTranslateSpec(property_value, property_name,
248 parent_key, &error_string)) { 248 parent_key, &error_string)) {
249 error_info->SetReport(ERROR_MANIFEST_SCHEMA_VALIDATE, 249 error_info->SetReport(ERROR_MANIFEST_SCHEMA_VALIDATE,
250 nacl::string("manifiest: ") + error_string); 250 nacl::string("manifest: ") + error_string);
251 return false; 251 return false;
252 } 252 }
253 } 253 }
254 254
255 // TODO(elijahtaylor) add ISA resolver here if we expand ISAs to include 255 if (!sandbox_isa.empty()) {
256 // micro-architectures that can resolve to multiple valid sandboxes. 256 // TODO(elijahtaylor) add ISA resolver here if we expand ISAs to include
257 bool has_isa = dictionary.isMember(sandbox_isa); 257 // micro-architectures that can resolve to multiple valid sandboxes.
258 bool has_portable = dictionary.isMember(kPortableKey); 258 bool has_isa = dictionary.isMember(sandbox_isa);
259 bool has_portable = dictionary.isMember(kPortableKey);
259 260
260 if (!has_isa && !has_portable) { 261 if (!has_isa && !has_portable) {
261 error_info->SetReport( 262 error_info->SetReport(
262 ERROR_MANIFEST_PROGRAM_MISSING_ARCH, 263 ERROR_MANIFEST_PROGRAM_MISSING_ARCH,
263 nacl::string("manifest: no version of ") + parent_key + 264 nacl::string("manifest: no version of ") + parent_key +
264 " given for current arch and no portable version found."); 265 " given for current arch and no portable version found.");
265 return false; 266 return false;
267 }
266 } 268 }
267 269
268 return true; 270 return true;
269 } 271 }
270 272
271 void GrabUrlAndPnaclOptions(const Json::Value& url_spec, 273 void GrabUrlAndPnaclOptions(const Json::Value& url_spec,
272 nacl::string* url, 274 nacl::string* url,
273 PnaclOptions* pnacl_options) { 275 PnaclOptions* pnacl_options) {
274 *url = url_spec[kUrlKey].asString(); 276 *url = url_spec[kUrlKey].asString();
275 if (url_spec.isMember(kCacheIdentityKey)) { 277 if (url_spec.isMember(kCacheIdentityKey)) {
(...skipping 15 matching lines...) Expand all
291 bool GetURLFromISADictionary(const Json::Value& dictionary, 293 bool GetURLFromISADictionary(const Json::Value& dictionary,
292 const nacl::string& parent_key, 294 const nacl::string& parent_key,
293 const nacl::string& sandbox_isa, 295 const nacl::string& sandbox_isa,
294 bool prefer_portable, 296 bool prefer_portable,
295 nacl::string* url, 297 nacl::string* url,
296 PnaclOptions* pnacl_options, 298 PnaclOptions* pnacl_options,
297 ErrorInfo* error_info) { 299 ErrorInfo* error_info) {
298 if (url == NULL || pnacl_options == NULL || error_info == NULL) 300 if (url == NULL || pnacl_options == NULL || error_info == NULL)
299 return false; 301 return false;
300 302
301 if (!IsValidISADictionary(dictionary, parent_key, sandbox_isa, error_info)) 303 if (!IsValidISADictionary(dictionary, parent_key, sandbox_isa, error_info)) {
304 error_info->SetReport(ERROR_MANIFEST_RESOLVE_URL,
305 "architecture " + sandbox_isa +
306 " is not found for file " + parent_key);
302 return false; 307 return false;
308 }
303 309
304 *url = ""; 310 *url = "";
305 311
306 // The call to IsValidISADictionary() above guarantees that either 312 // The call to IsValidISADictionary() above guarantees that either
307 // sandbox_isa or kPortableKey is present in the dictionary. 313 // sandbox_isa or kPortableKey is present in the dictionary.
308 bool has_portable = dictionary.isMember(kPortableKey); 314 bool has_portable = dictionary.isMember(kPortableKey);
309 bool has_isa = dictionary.isMember(sandbox_isa); 315 bool has_isa = dictionary.isMember(sandbox_isa);
310 nacl::string chosen_isa; 316 nacl::string chosen_isa;
311 if ((has_portable && prefer_portable) || !has_isa) { 317 if ((has_portable && prefer_portable) || !has_isa) {
312 chosen_isa = kPortableKey; 318 chosen_isa = kPortableKey;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 if (!files.isObject()) { 433 if (!files.isObject()) {
428 error_info->SetReport( 434 error_info->SetReport(
429 ERROR_MANIFEST_SCHEMA_VALIDATE, 435 ERROR_MANIFEST_SCHEMA_VALIDATE,
430 nacl::string("manifest: '") + kFilesKey + "' is not a dictionary."); 436 nacl::string("manifest: '") + kFilesKey + "' is not a dictionary.");
431 } 437 }
432 Json::Value::Members members = files.getMemberNames(); 438 Json::Value::Members members = files.getMemberNames();
433 for (size_t i = 0; i < members.size(); ++i) { 439 for (size_t i = 0; i < members.size(); ++i) {
434 nacl::string file_name = members[i]; 440 nacl::string file_name = members[i];
435 if (!IsValidISADictionary(files[file_name], 441 if (!IsValidISADictionary(files[file_name],
436 file_name, 442 file_name,
437 sandbox_isa_, 443 nacl::string(),
438 error_info)) { 444 error_info)) {
439 return false; 445 return false;
440 } 446 }
441 } 447 }
442 } 448 }
443 449
444 return true; 450 return true;
445 } 451 }
446 452
447 bool JsonManifest::ResolveURL(const nacl::string& relative_url, 453 bool JsonManifest::ResolveURL(const nacl::string& relative_url,
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 error_info->SetReport( 552 error_info->SetReport(
547 ERROR_MANIFEST_RESOLVE_URL, 553 ERROR_MANIFEST_RESOLVE_URL,
548 nacl::string("ResolveKey: no such \"files\" entry: ") + key); 554 nacl::string("ResolveKey: no such \"files\" entry: ") + key);
549 return false; 555 return false;
550 } 556 }
551 return GetKeyUrl(files, rest, sandbox_isa_, this, prefer_portable_, 557 return GetKeyUrl(files, rest, sandbox_isa_, this, prefer_portable_,
552 full_url, pnacl_options, error_info); 558 full_url, pnacl_options, error_info);
553 } 559 }
554 560
555 } // namespace plugin 561 } // namespace plugin
OLDNEW
« no previous file with comments | « no previous file | ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698