OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/nacl/renderer/json_manifest.h" | 5 #include "components/nacl/renderer/json_manifest.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "components/nacl/common/nacl_types.h" |
11 #include "components/nacl/renderer/nexe_load_manager.h" | 12 #include "components/nacl/renderer/nexe_load_manager.h" |
12 #include "third_party/jsoncpp/source/include/json/reader.h" | 13 #include "third_party/jsoncpp/source/include/json/reader.h" |
13 #include "third_party/jsoncpp/source/include/json/value.h" | 14 #include "third_party/jsoncpp/source/include/json/value.h" |
14 #include "url/gurl.h" | 15 #include "url/gurl.h" |
15 | 16 |
16 namespace nacl { | 17 namespace nacl { |
17 | 18 |
18 namespace { | 19 namespace { |
19 // Top-level section name keys | 20 // Top-level section name keys |
20 const char* const kProgramKey = "program"; | 21 const char* const kProgramKey = "program"; |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 error_info->string = | 436 error_info->string = |
436 "could not resolve url '" + nexe_url + | 437 "could not resolve url '" + nexe_url + |
437 "' relative to manifest base url '" + manifest_base_url_.c_str() + | 438 "' relative to manifest base url '" + manifest_base_url_.c_str() + |
438 "'."; | 439 "'."; |
439 return false; | 440 return false; |
440 } | 441 } |
441 *full_url = resolved_gurl.possibly_invalid_spec(); | 442 *full_url = resolved_gurl.possibly_invalid_spec(); |
442 return true; | 443 return true; |
443 } | 444 } |
444 | 445 |
445 void JsonManifest::GetPrefetchableFiles(base::StringPairs* out_files) const { | 446 void JsonManifest::GetPrefetchableFiles( |
| 447 std::vector<NaClResourcePrefetchRequest>* out_files) const { |
446 const Json::Value& files = dictionary_[kFilesKey]; | 448 const Json::Value& files = dictionary_[kFilesKey]; |
447 if (!files.isObject()) | 449 if (!files.isObject()) |
448 return; | 450 return; |
449 | 451 |
450 Json::Value::Members keys = files.getMemberNames(); | 452 Json::Value::Members keys = files.getMemberNames(); |
451 for (size_t i = 0; i < keys.size(); ++i) { | 453 for (size_t i = 0; i < keys.size(); ++i) { |
452 std::string full_url; | 454 std::string full_url; |
453 PP_PNaClOptions unused_pnacl_options; // pnacl does not support "files". | 455 PP_PNaClOptions unused_pnacl_options; // pnacl does not support "files". |
454 // We skip invalid entries in "files". | 456 // We skip invalid entries in "files". |
455 if (GetKeyUrl(files, keys[i], &full_url, &unused_pnacl_options)) { | 457 if (GetKeyUrl(files, keys[i], &full_url, &unused_pnacl_options)) { |
456 if (GURL(full_url).SchemeIs("chrome-extension")) | 458 if (GURL(full_url).SchemeIs("chrome-extension")) |
457 out_files->push_back(std::make_pair(keys[i], full_url)); | 459 out_files->push_back(NaClResourcePrefetchRequest(keys[i], full_url)); |
458 } | 460 } |
459 } | 461 } |
460 } | 462 } |
461 | 463 |
462 bool JsonManifest::ResolveKey(const std::string& key, | 464 bool JsonManifest::ResolveKey(const std::string& key, |
463 std::string* full_url, | 465 std::string* full_url, |
464 PP_PNaClOptions* pnacl_options) const { | 466 PP_PNaClOptions* pnacl_options) const { |
465 if (full_url == NULL || pnacl_options == NULL) | 467 if (full_url == NULL || pnacl_options == NULL) |
466 return false; | 468 return false; |
467 | 469 |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 } else { | 646 } else { |
645 // NaCl | 647 // NaCl |
646 *url = isa_spec[kUrlKey].asString(); | 648 *url = isa_spec[kUrlKey].asString(); |
647 pnacl_options->translate = PP_FALSE; | 649 pnacl_options->translate = PP_FALSE; |
648 } | 650 } |
649 | 651 |
650 return true; | 652 return true; |
651 } | 653 } |
652 | 654 |
653 } // namespace nacl | 655 } // namespace nacl |
OLD | NEW |