Chromium Code Reviews| Index: components/nacl/renderer/ppb_nacl_private_impl.cc |
| diff --git a/components/nacl/renderer/ppb_nacl_private_impl.cc b/components/nacl/renderer/ppb_nacl_private_impl.cc |
| index 539c7104d6e4cdaecce2ac3b161290f44eafaff1..d1bf95748414537f4f87f3a7947537c68ea25c18 100644 |
| --- a/components/nacl/renderer/ppb_nacl_private_impl.cc |
| +++ b/components/nacl/renderer/ppb_nacl_private_impl.cc |
| @@ -102,19 +102,11 @@ typedef base::ScopedPtrHashMap<PP_Instance, NexeLoadManager> |
| base::LazyInstance<NexeLoadManagerMap> g_load_manager_map = |
| LAZY_INSTANCE_INITIALIZER; |
| -typedef base::ScopedPtrHashMap<int32_t, nacl::JsonManifest> JsonManifestMap; |
| +typedef base::ScopedPtrHashMap<PP_Instance, nacl::JsonManifest> JsonManifestMap; |
| base::LazyInstance<JsonManifestMap> g_manifest_map = |
| LAZY_INSTANCE_INITIALIZER; |
| -base::LazyInstance<int32_t> g_next_manifest_id = |
| - LAZY_INSTANCE_INITIALIZER; |
| - |
| -// We have to define a method here since we can't use a static initializer. |
| -int32_t GetPNaClManifestId() { |
| - return std::numeric_limits<int32_t>::max(); |
| -} |
| - |
| nacl::NexeLoadManager* GetNexeLoadManager(PP_Instance instance) { |
| NexeLoadManagerMap& map = g_load_manager_map.Get(); |
| NexeLoadManagerMap::iterator iter = map.find(instance); |
| @@ -746,6 +738,8 @@ void InstanceCreated(PP_Instance instance) { |
| } |
| void InstanceDestroyed(PP_Instance instance) { |
| + g_manifest_map.Get().erase(instance); |
| + |
| NexeLoadManagerMap& map = g_load_manager_map.Get(); |
| DLOG_IF(ERROR, map.count(instance) == 0) << "Could not find instance ID"; |
| // The erase may call NexeLoadManager's destructor prior to removing it from |
| @@ -832,7 +826,6 @@ int64_t GetNexeSize(PP_Instance instance) { |
| } |
| void DownloadManifestToBuffer(PP_Instance instance, |
| - int32_t* out_manifest_id, |
| struct PP_CompletionCallback callback); |
| int32_t CreateJsonManifest(PP_Instance instance, |
| @@ -841,7 +834,6 @@ int32_t CreateJsonManifest(PP_Instance instance, |
| void RequestNaClManifest(PP_Instance instance, |
| const char* url, |
| - int32_t* out_manifest_id, |
| PP_CompletionCallback callback) { |
| NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
| DCHECK(load_manager); |
| @@ -871,7 +863,7 @@ void RequestNaClManifest(PP_Instance instance, |
| if (net::DataURL::Parse(gurl, &mime_type, &charset, &data)) { |
| if (data.size() <= ManifestDownloader::kNaClManifestMaxFileBytes) { |
| error = PP_OK; |
| - *out_manifest_id = CreateJsonManifest(instance, base_url.spec(), data); |
| + CreateJsonManifest(instance, base_url.spec(), data); |
| } else { |
| load_manager->ReportLoadError(PP_NACL_ERROR_MANIFEST_TOO_LARGE, |
| "manifest file too large."); |
| @@ -884,7 +876,7 @@ void RequestNaClManifest(PP_Instance instance, |
| FROM_HERE, |
| base::Bind(callback.func, callback.user_data, error)); |
| } else { |
| - DownloadManifestToBuffer(instance, out_manifest_id, callback); |
| + DownloadManifestToBuffer(instance, callback); |
| } |
| } |
| @@ -923,13 +915,11 @@ PP_Bool DevInterfacesEnabled(PP_Instance instance) { |
| void DownloadManifestToBufferCompletion(PP_Instance instance, |
| struct PP_CompletionCallback callback, |
| - int32_t* out_manifest_id, |
| base::Time start_time, |
| PP_NaClError pp_nacl_error, |
| const std::string& data); |
| void DownloadManifestToBuffer(PP_Instance instance, |
| - int32_t* out_manifest_id, |
| struct PP_CompletionCallback callback) { |
| nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
| DCHECK(load_manager); |
| @@ -954,13 +944,12 @@ void DownloadManifestToBuffer(PP_Instance instance, |
| url_loader.Pass(), |
| load_manager->is_installed(), |
| base::Bind(DownloadManifestToBufferCompletion, |
| - instance, callback, out_manifest_id, base::Time::Now())); |
| + instance, callback, base::Time::Now())); |
| manifest_downloader->Load(request); |
| } |
| void DownloadManifestToBufferCompletion(PP_Instance instance, |
| struct PP_CompletionCallback callback, |
| - int32_t* out_manifest_id, |
| base::Time start_time, |
| PP_NaClError pp_nacl_error, |
| const std::string& data) { |
| @@ -1003,15 +992,11 @@ void DownloadManifestToBufferCompletion(PP_Instance instance, |
| if (pp_error == PP_OK) { |
| std::string base_url = load_manager->manifest_base_url().spec(); |
| - *out_manifest_id = CreateJsonManifest(instance, base_url, data); |
| + CreateJsonManifest(instance, base_url, data); |
| } |
| callback.func(callback.user_data, pp_error); |
| } |
| -int32_t CreatePNaClManifest(PP_Instance /* instance */) { |
| - return GetPNaClManifestId(); |
| -} |
| - |
| int32_t CreateJsonManifest(PP_Instance instance, |
|
dmichael (off chromium)
2014/05/29 16:10:18
You don't seem to use the return value anymore, ca
teravest
2014/05/29 16:14:02
I changed this to use bool and cleaned up the erro
|
| const std::string& manifest_url, |
| const std::string& manifest_data) { |
| @@ -1021,8 +1006,6 @@ int32_t CreateJsonManifest(PP_Instance instance, |
| nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
| if (!load_manager) |
| return -1; |
| - int32_t manifest_id = g_next_manifest_id.Get(); |
| - g_next_manifest_id.Get()++; |
| const char* isa_type; |
| if (load_manager->IsPNaCl()) |
| @@ -1038,36 +1021,20 @@ int32_t CreateJsonManifest(PP_Instance instance, |
| PP_ToBool(NaClDebugEnabledForURL(manifest_url.c_str())))); |
| JsonManifest::ErrorInfo error_info; |
| if (j->Init(manifest_data.c_str(), &error_info)) { |
| - g_manifest_map.Get().add(manifest_id, j.Pass()); |
| - return manifest_id; |
| + g_manifest_map.Get().add(instance, j.Pass()); |
| + return instance; |
| } |
| load_manager->ReportLoadError(error_info.error, error_info.string); |
| return -1; |
| } |
| -void DestroyManifest(PP_Instance /* instance */, |
| - int32_t manifest_id) { |
| - if (manifest_id == GetPNaClManifestId()) |
| - return; |
| - g_manifest_map.Get().erase(manifest_id); |
| -} |
| - |
| PP_Bool ManifestGetProgramURL(PP_Instance instance, |
| - int32_t manifest_id, |
| PP_Var* pp_full_url, |
| PP_PNaClOptions* pnacl_options, |
| PP_Bool* pp_uses_nonsfi_mode) { |
| nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
| - if (manifest_id == GetPNaClManifestId()) { |
| - if (load_manager) { |
| - load_manager->ReportLoadError( |
| - PP_NACL_ERROR_MANIFEST_GET_NEXE_URL, |
| - "pnacl manifest does not contain a program."); |
| - } |
| - return PP_FALSE; |
| - } |
| - JsonManifestMap::iterator it = g_manifest_map.Get().find(manifest_id); |
| + JsonManifestMap::iterator it = g_manifest_map.Get().find(instance); |
| if (it == g_manifest_map.Get().end()) |
| return PP_FALSE; |
| @@ -1087,11 +1054,13 @@ PP_Bool ManifestGetProgramURL(PP_Instance instance, |
| } |
| PP_Bool ManifestResolveKey(PP_Instance instance, |
| - int32_t manifest_id, |
| + PP_Bool helper_process, |
|
dmichael (off chromium)
2014/05/29 16:10:18
nit: is_helper_process?
teravest
2014/05/29 16:14:02
Done.
|
| const char* key, |
| PP_Var* pp_full_url, |
| PP_PNaClOptions* pnacl_options) { |
| - if (manifest_id == GetPNaClManifestId()) { |
| + // For "helper" processes (llc and ld), we resolve keys manually as there is |
| + // no existing .nmf file to parse. |
| + if (PP_ToBool(helper_process)) { |
| pnacl_options->translate = PP_FALSE; |
| // We can only resolve keys in the files/ namespace. |
| const std::string kFilesPrefix = "files/"; |
| @@ -1111,7 +1080,7 @@ PP_Bool ManifestResolveKey(PP_Instance instance, |
| return PP_TRUE; |
| } |
| - JsonManifestMap::iterator it = g_manifest_map.Get().find(manifest_id); |
| + JsonManifestMap::iterator it = g_manifest_map.Get().find(instance); |
| if (it == g_manifest_map.Get().end()) |
| return PP_FALSE; |
| @@ -1542,8 +1511,6 @@ const PPB_NaCl_Private nacl_interface = { |
| &ProcessNaClManifest, |
| &GetManifestURLArgument, |
| &DevInterfacesEnabled, |
| - &CreatePNaClManifest, |
| - &DestroyManifest, |
| &ManifestGetProgramURL, |
| &ManifestResolveKey, |
| &GetPNaClResourceInfo, |