Chromium Code Reviews| Index: components/nacl/renderer/nexe_load_manager.cc |
| diff --git a/components/nacl/renderer/nexe_load_manager.cc b/components/nacl/renderer/nexe_load_manager.cc |
| index df70a0608a6bee046e563055917b28da8c13925f..b8cf70b31761e51ab20f42b644474238118538db 100644 |
| --- a/components/nacl/renderer/nexe_load_manager.cc |
| +++ b/components/nacl/renderer/nexe_load_manager.cc |
| @@ -5,6 +5,8 @@ |
| #include "components/nacl/renderer/nexe_load_manager.h" |
| #include "base/command_line.h" |
| +#include "base/containers/scoped_ptr_hash_map.h" |
| +#include "base/lazy_instance.h" |
| #include "base/logging.h" |
| #include "base/metrics/histogram.h" |
| #include "base/strings/string_tokenizer.h" |
| @@ -39,6 +41,8 @@ |
| #include "third_party/WebKit/public/web/WebView.h" |
| #include "v8/include/v8.h" |
| +namespace nacl { |
| + |
| namespace { |
| const char* const kTypeAttribute = "type"; |
| @@ -76,9 +80,11 @@ std::string LookupAttribute(const std::map<std::string, std::string>& args, |
| return std::string(); |
| } |
| -} // namespace |
| +typedef base::ScopedPtrHashMap<PP_Instance, NexeLoadManager> NexeLoadManagerMap; |
| +base::LazyInstance<NexeLoadManagerMap> g_load_manager_map = |
| + LAZY_INSTANCE_INITIALIZER; |
| -namespace nacl { |
| +} // namespace |
| NexeLoadManager::NexeLoadManager( |
| PP_Instance pp_instance) |
| @@ -105,6 +111,27 @@ NexeLoadManager::~NexeLoadManager() { |
| } |
| } |
| +void NexeLoadManager::Create(PP_Instance instance) { |
| + scoped_ptr<NexeLoadManager> new_load_manager(new NexeLoadManager(instance)); |
| + NexeLoadManagerMap& map = g_load_manager_map.Get(); |
| + DLOG_IF(ERROR, map.count(instance) != 0) << "Instance count should be 0"; |
| + map.add(instance, new_load_manager.Pass()); |
| +} |
| + |
| +NexeLoadManager* NexeLoadManager::Get(PP_Instance instance) { |
| + NexeLoadManagerMap& map = g_load_manager_map.Get(); |
| + NexeLoadManagerMap::iterator iter = map.find(instance); |
| + if (iter != map.end()) |
| + return iter->second; |
| + return NULL; |
| +} |
| + |
| +void NexeLoadManager::Delete(PP_Instance instance) { |
| + NexeLoadManagerMap& map = g_load_manager_map.Get(); |
| + scoped_ptr<NexeLoadManager> temp(map.take(instance)); |
|
dmichael (off chromium)
2014/08/20 21:03:56
we lost the comment here about deleting it before
teravest
2014/08/20 21:08:15
Okay, I've added it back.
|
| + map.erase(instance); |
| +} |
| + |
| void NexeLoadManager::NexeFileDidOpen(int32_t pp_error, |
| const base::File& file, |
| int32_t http_status, |