| 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/containers/scoped_ptr_hash_map.h" | |
| 10 #include "base/lazy_instance.h" | |
| 11 #include "base/logging.h" | 9 #include "base/logging.h" |
| 12 #include "base/macros.h" | 10 #include "base/macros.h" |
| 13 #include "components/nacl/renderer/nexe_load_manager.h" | 11 #include "components/nacl/renderer/nexe_load_manager.h" |
| 14 #include "third_party/jsoncpp/source/include/json/reader.h" | 12 #include "third_party/jsoncpp/source/include/json/reader.h" |
| 15 #include "third_party/jsoncpp/source/include/json/value.h" | 13 #include "third_party/jsoncpp/source/include/json/value.h" |
| 16 #include "url/gurl.h" | 14 #include "url/gurl.h" |
| 17 | 15 |
| 18 namespace nacl { | 16 namespace nacl { |
| 19 | 17 |
| 20 namespace { | 18 namespace { |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 // Currently only allow 0 or 2, since that is what we test. | 371 // Currently only allow 0 or 2, since that is what we test. |
| 374 if (opt_raw <= 0) | 372 if (opt_raw <= 0) |
| 375 pnacl_options->opt_level = 0; | 373 pnacl_options->opt_level = 0; |
| 376 else | 374 else |
| 377 pnacl_options->opt_level = 2; | 375 pnacl_options->opt_level = 2; |
| 378 } | 376 } |
| 379 } | 377 } |
| 380 | 378 |
| 381 } // namespace | 379 } // namespace |
| 382 | 380 |
| 383 typedef base::ScopedPtrHashMap<PP_Instance, nacl::JsonManifest> JsonManifestMap; | |
| 384 base::LazyInstance<JsonManifestMap> g_manifest_map = LAZY_INSTANCE_INITIALIZER; | |
| 385 | |
| 386 void AddJsonManifest(PP_Instance instance, scoped_ptr<JsonManifest> manifest) { | |
| 387 g_manifest_map.Get().add(instance, manifest.Pass()); | |
| 388 } | |
| 389 | |
| 390 JsonManifest* GetJsonManifest(PP_Instance instance) { | |
| 391 return g_manifest_map.Get().get(instance); | |
| 392 } | |
| 393 | |
| 394 void DeleteJsonManifest(PP_Instance instance) { | |
| 395 g_manifest_map.Get().erase(instance); | |
| 396 } | |
| 397 | |
| 398 JsonManifest::JsonManifest(const std::string& manifest_base_url, | 381 JsonManifest::JsonManifest(const std::string& manifest_base_url, |
| 399 const std::string& sandbox_isa, | 382 const std::string& sandbox_isa, |
| 400 bool nonsfi_enabled, | 383 bool nonsfi_enabled, |
| 401 bool pnacl_debug) | 384 bool pnacl_debug) |
| 402 : manifest_base_url_(manifest_base_url), | 385 : manifest_base_url_(manifest_base_url), |
| 403 sandbox_isa_(sandbox_isa), | 386 sandbox_isa_(sandbox_isa), |
| 404 nonsfi_enabled_(nonsfi_enabled), | 387 nonsfi_enabled_(nonsfi_enabled), |
| 405 pnacl_debug_(pnacl_debug) { } | 388 pnacl_debug_(pnacl_debug) { } |
| 406 | 389 |
| 407 bool JsonManifest::Init(const std::string& manifest_json, | 390 bool JsonManifest::Init(const std::string& manifest_json, |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 } else { | 645 } else { |
| 663 // NaCl | 646 // NaCl |
| 664 *url = isa_spec[kUrlKey].asString(); | 647 *url = isa_spec[kUrlKey].asString(); |
| 665 pnacl_options->translate = PP_FALSE; | 648 pnacl_options->translate = PP_FALSE; |
| 666 } | 649 } |
| 667 | 650 |
| 668 return true; | 651 return true; |
| 669 } | 652 } |
| 670 | 653 |
| 671 } // namespace nacl | 654 } // namespace nacl |
| OLD | NEW |