| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ppapi/native_client/src/trusted/plugin/pnacl_resources.h" | 5 #include "ppapi/native_client/src/trusted/plugin/pnacl_resources.h" |
| 6 | 6 |
| 7 #include "native_client/src/include/portability_io.h" | 7 #include "native_client/src/include/portability_io.h" |
| 8 #include "native_client/src/shared/platform/nacl_check.h" | 8 #include "native_client/src/shared/platform/nacl_check.h" |
| 9 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h" | 9 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h" |
| 10 #include "ppapi/c/pp_errors.h" | 10 #include "ppapi/c/pp_errors.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 nacl::DescWrapper* PnaclResources::WrapperForUrl(const nacl::string& url) { | 89 nacl::DescWrapper* PnaclResources::WrapperForUrl(const nacl::string& url) { |
| 90 CHECK(resource_wrappers_.find(url) != resource_wrappers_.end()); | 90 CHECK(resource_wrappers_.find(url) != resource_wrappers_.end()); |
| 91 return resource_wrappers_[url]; | 91 return resource_wrappers_[url]; |
| 92 } | 92 } |
| 93 | 93 |
| 94 void PnaclResources::ReadResourceInfo( | 94 void PnaclResources::ReadResourceInfo( |
| 95 const nacl::string& resource_info_url, | 95 const nacl::string& resource_info_url, |
| 96 const pp::CompletionCallback& resource_info_read_cb) { | 96 const pp::CompletionCallback& resource_info_read_cb) { |
| 97 PLUGIN_PRINTF(("PnaclResources::ReadResourceInfo\n")); | 97 PLUGIN_PRINTF(("PnaclResources::ReadResourceInfo\n")); |
| 98 | 98 |
| 99 nacl::string full_url; | 99 nacl::string full_url = PnaclUrls::GetBaseUrl() + resource_info_url; |
| 100 ErrorInfo error_info; | |
| 101 if (!manifest_->ResolveURL(resource_info_url, &full_url, &error_info)) { | |
| 102 ReadResourceInfoError(nacl::string("failed to resolve ") + | |
| 103 resource_info_url + ": " + | |
| 104 error_info.message() + "."); | |
| 105 return; | |
| 106 } | |
| 107 PLUGIN_PRINTF(("Resolved resources info url: %s\n", full_url.c_str())); | 100 PLUGIN_PRINTF(("Resolved resources info url: %s\n", full_url.c_str())); |
| 108 nacl::string resource_info_filename = | 101 nacl::string resource_info_filename = |
| 109 PnaclUrls::PnaclComponentURLToFilename(full_url); | 102 PnaclUrls::PnaclComponentURLToFilename(full_url); |
| 110 | 103 |
| 111 PLUGIN_PRINTF(("Pnacl-converted resources info url: %s\n", | 104 PLUGIN_PRINTF(("Pnacl-converted resources info url: %s\n", |
| 112 resource_info_filename.c_str())); | 105 resource_info_filename.c_str())); |
| 113 | 106 |
| 114 int32_t fd = GetPnaclFD(plugin_, resource_info_filename.c_str()); | 107 int32_t fd = GetPnaclFD(plugin_, resource_info_filename.c_str()); |
| 115 if (fd < 0) { | 108 if (fd < 0) { |
| 116 // File-open failed. Assume this means that the file is | 109 // File-open failed. Assume this means that the file is |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 ld_tool_name = json_name.asString(); | 172 ld_tool_name = json_name.asString(); |
| 180 PLUGIN_PRINTF(("Set ld_tool_name=%s\n", ld_tool_name.c_str())); | 173 PLUGIN_PRINTF(("Set ld_tool_name=%s\n", ld_tool_name.c_str())); |
| 181 } | 174 } |
| 182 } | 175 } |
| 183 | 176 |
| 184 return true; | 177 return true; |
| 185 } | 178 } |
| 186 | 179 |
| 187 nacl::string PnaclResources::GetFullUrl( | 180 nacl::string PnaclResources::GetFullUrl( |
| 188 const nacl::string& partial_url, const nacl::string& sandbox_arch) const { | 181 const nacl::string& partial_url, const nacl::string& sandbox_arch) const { |
| 189 nacl::string full_url; | |
| 190 ErrorInfo error_info; | |
| 191 const nacl::string& url_with_platform_prefix = | 182 const nacl::string& url_with_platform_prefix = |
| 192 sandbox_arch + "/" + partial_url; | 183 sandbox_arch + "/" + partial_url; |
| 193 if (!manifest_->ResolveURL(url_with_platform_prefix, | 184 nacl::string full_url = PnaclUrls::GetBaseUrl() + url_with_platform_prefix; |
| 194 &full_url, | |
| 195 &error_info)) { | |
| 196 PLUGIN_PRINTF(("PnaclResources::GetFullUrl failed: %s.\n", | |
| 197 error_info.message().c_str())); | |
| 198 return ""; | |
| 199 } | |
| 200 return full_url; | 185 return full_url; |
| 201 } | 186 } |
| 202 | 187 |
| 203 void PnaclResources::StartLoad( | 188 void PnaclResources::StartLoad( |
| 204 const pp::CompletionCallback& all_loaded_callback) { | 189 const pp::CompletionCallback& all_loaded_callback) { |
| 205 PLUGIN_PRINTF(("PnaclResources::StartLoad\n")); | 190 PLUGIN_PRINTF(("PnaclResources::StartLoad\n")); |
| 206 | 191 |
| 207 std::vector<nacl::string> resource_urls; | 192 std::vector<nacl::string> resource_urls; |
| 208 resource_urls.push_back(GetLlcUrl()); | 193 resource_urls.push_back(GetLlcUrl()); |
| 209 resource_urls.push_back(GetLdUrl()); | 194 resource_urls.push_back(GetLdUrl()); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 238 resource_wrappers_[resource_urls[i]] = | 223 resource_wrappers_[resource_urls[i]] = |
| 239 plugin_->wrapper_factory()->MakeFileDesc(fd, O_RDONLY); | 224 plugin_->wrapper_factory()->MakeFileDesc(fd, O_RDONLY); |
| 240 } | 225 } |
| 241 } | 226 } |
| 242 // We're done! Queue the callback. | 227 // We're done! Queue the callback. |
| 243 pp::Core* core = pp::Module::Get()->core(); | 228 pp::Core* core = pp::Module::Get()->core(); |
| 244 core->CallOnMainThread(0, all_loaded_callback, result); | 229 core->CallOnMainThread(0, all_loaded_callback, result); |
| 245 } | 230 } |
| 246 | 231 |
| 247 } // namespace plugin | 232 } // namespace plugin |
| OLD | NEW |