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

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

Issue 8525014: Get all the resources relative to a single base. Currently the same base (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 * Copyright (c) 2011 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/manifest.h" 9 #include "native_client/src/trusted/plugin/manifest.h"
10 10
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 // "foo.txt": { 53 // "foo.txt": {
54 // "portable": {"url": "foo.txt"} 54 // "portable": {"url": "foo.txt"}
55 // }, 55 // },
56 // "bar.txt": { 56 // "bar.txt": {
57 // "x86-32": {"url": "x86-32/bar.txt"}, 57 // "x86-32": {"url": "x86-32/bar.txt"},
58 // "portable": {"url": "bar.txt"} 58 // "portable": {"url": "bar.txt"}
59 // } 59 // }
60 // } 60 // }
61 // } 61 // }
62 62
63 // TODO(jvoung): Remove these when we find a better way to store/install them.
64 const char* const kPnaclLlcKey = "pnacl-llc";
65 const char* const kPnaclLdKey = "pnacl-ld";
66
67 // Looks up |property_name| in the vector |valid_names| with length 63 // Looks up |property_name| in the vector |valid_names| with length
68 // |valid_name_count|. Returns true if |property_name| is found. 64 // |valid_name_count|. Returns true if |property_name| is found.
69 bool FindMatchingProperty(nacl::string property_name, 65 bool FindMatchingProperty(nacl::string property_name,
70 const char** valid_names, 66 const char** valid_names,
71 size_t valid_name_count) { 67 size_t valid_name_count) {
72 for (size_t i = 0; i < valid_name_count; ++i) { 68 for (size_t i = 0; i < valid_name_count; ++i) {
73 if (property_name == valid_names[i]) { 69 if (property_name == valid_names[i]) {
74 return true; 70 return true;
75 } 71 }
76 } 72 }
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 error_info->SetReport( 423 error_info->SetReport(
428 ERROR_MANIFEST_RESOLVE_URL, 424 ERROR_MANIFEST_RESOLVE_URL,
429 nacl::string("ResolveKey: no such \"files\" entry: ") + key); 425 nacl::string("ResolveKey: no such \"files\" entry: ") + key);
430 *is_portable = false; 426 *is_portable = false;
431 return false; 427 return false;
432 } 428 }
433 return GetKeyUrl(files, rest, sandbox_isa_, 429 return GetKeyUrl(files, rest, sandbox_isa_,
434 full_url, error_info, is_portable, this); 430 full_url, error_info, is_portable, this);
435 } 431 }
436 432
437 // TODO(jvoung): We won't need these if we figure out how to install llc and ld.
438 bool Manifest::GetLLCURL(nacl::string* full_url, ErrorInfo* error_info) {
439 if (full_url == NULL || error_info == NULL)
440 return false;
441
442 Json::Value pnacl_llc = dictionary_[kPnaclLlcKey];
443
444 nacl::string nexe_url;
445 nacl::string error_string;
446 bool is_portable;
447 if (!GetURLFromISADictionary(pnacl_llc,
448 sandbox_isa_,
449 &nexe_url,
450 &error_string,
451 &is_portable)) {
452 error_info->SetReport(ERROR_MANIFEST_GET_NEXE_URL,
453 nacl::string(kPnaclLlcKey) + ":" + sandbox_isa_ +
454 error_string);
455 return false;
456 }
457
458 if (is_portable) {
459 // Bootstrap problem -- we need this to translate portable programs!
460 error_info->SetReport(ERROR_MANIFEST_GET_NEXE_URL,
461 nacl::string(kPnaclLlcKey) +
462 " must be pre-translated for " + sandbox_isa_ + "!");
463 return false;
464 }
465
466 return ResolveURL(nexe_url, full_url, error_info);
467 }
468
469 bool Manifest::GetLDURL(nacl::string* full_url, ErrorInfo* error_info) {
470 if (full_url == NULL || error_info == NULL)
471 return false;
472
473 Json::Value pnacl_ld = dictionary_[kPnaclLdKey];
474
475 nacl::string nexe_url;
476 nacl::string error_string;
477 bool is_portable;
478 if (!GetURLFromISADictionary(pnacl_ld,
479 sandbox_isa_,
480 &nexe_url,
481 &error_string,
482 &is_portable)) {
483 error_info->SetReport(ERROR_MANIFEST_GET_NEXE_URL,
484 nacl::string(kPnaclLdKey) + ":" + sandbox_isa_ +
485 error_string);
486 return false;
487 }
488
489 if (is_portable) {
490 // Bootstrap problem -- we need this to translate portable programs!
491 error_info->SetReport(ERROR_MANIFEST_GET_NEXE_URL,
492 nacl::string(kPnaclLdKey) +
493 " must be pre-translated for " + sandbox_isa_ + "!");
494 return false;
495 }
496
497 return ResolveURL(nexe_url, full_url, error_info);
498 }
499
500 } // namespace plugin 433 } // namespace plugin
OLDNEW
« no previous file with comments | « ppapi/native_client/src/trusted/plugin/manifest.h ('k') | ppapi/native_client/src/trusted/plugin/plugin.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698