| 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 "native_client/src/trusted/plugin/pnacl_coordinator.h" | 5 #include "native_client/src/trusted/plugin/pnacl_coordinator.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "native_client/src/include/portability_io.h" | 10 #include "native_client/src/include/portability_io.h" |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 UNREFERENCED_PARAMETER(error_info); | 191 UNREFERENCED_PARAMETER(error_info); |
| 192 UNREFERENCED_PARAMETER(is_portable); | 192 UNREFERENCED_PARAMETER(is_portable); |
| 193 PLUGIN_PRINTF(("ExtensionManifest does not contain a program\n")); | 193 PLUGIN_PRINTF(("ExtensionManifest does not contain a program\n")); |
| 194 error_info->SetReport(ERROR_MANIFEST_GET_NEXE_URL, | 194 error_info->SetReport(ERROR_MANIFEST_GET_NEXE_URL, |
| 195 "pnacl manifest does not contain a program."); | 195 "pnacl manifest does not contain a program."); |
| 196 return false; | 196 return false; |
| 197 } | 197 } |
| 198 | 198 |
| 199 virtual bool ResolveURL(const nacl::string& relative_url, | 199 virtual bool ResolveURL(const nacl::string& relative_url, |
| 200 nacl::string* full_url, | 200 nacl::string* full_url, |
| 201 bool* permit_extension_url, | |
| 202 ErrorInfo* error_info) const { | 201 ErrorInfo* error_info) const { |
| 203 // Does not do general URL resolution, simply appends relative_url to | 202 // Does not do general URL resolution, simply appends relative_url to |
| 204 // the end of manifest_base_url_. | 203 // the end of manifest_base_url_. |
| 205 UNREFERENCED_PARAMETER(error_info); | 204 UNREFERENCED_PARAMETER(error_info); |
| 206 *full_url = manifest_base_url_ + relative_url; | 205 *full_url = manifest_base_url_ + relative_url; |
| 207 // Since the pnacl coordinator manifest provides access to resources | |
| 208 // in the chrome extension, lookups will need to access resources in their | |
| 209 // extension origin rather than the plugin's origin. | |
| 210 *permit_extension_url = true; | |
| 211 return true; | 206 return true; |
| 212 } | 207 } |
| 213 | 208 |
| 214 virtual bool GetFileKeys(std::set<nacl::string>* keys) const { | 209 virtual bool GetFileKeys(std::set<nacl::string>* keys) const { |
| 215 // Does not support enumeration. | 210 // Does not support enumeration. |
| 216 PLUGIN_PRINTF(("ExtensionManifest does not support key enumeration\n")); | 211 PLUGIN_PRINTF(("ExtensionManifest does not support key enumeration\n")); |
| 217 UNREFERENCED_PARAMETER(keys); | 212 UNREFERENCED_PARAMETER(keys); |
| 218 return false; | 213 return false; |
| 219 } | 214 } |
| 220 | 215 |
| 221 virtual bool ResolveKey(const nacl::string& key, | 216 virtual bool ResolveKey(const nacl::string& key, |
| 222 nacl::string* full_url, | 217 nacl::string* full_url, |
| 223 bool* permit_extension_url, | |
| 224 ErrorInfo* error_info, | 218 ErrorInfo* error_info, |
| 225 bool* is_portable) const { | 219 bool* is_portable) const { |
| 226 *is_portable = false; | 220 *is_portable = false; |
| 227 // We can only resolve keys in the files/ namespace. | 221 // We can only resolve keys in the files/ namespace. |
| 228 const nacl::string kFilesPrefix = "files/"; | 222 const nacl::string kFilesPrefix = "files/"; |
| 229 size_t files_prefix_pos = key.find(kFilesPrefix); | 223 size_t files_prefix_pos = key.find(kFilesPrefix); |
| 230 if (files_prefix_pos == nacl::string::npos) { | 224 if (files_prefix_pos == nacl::string::npos) { |
| 231 error_info->SetReport(ERROR_MANIFEST_RESOLVE_URL, | 225 error_info->SetReport(ERROR_MANIFEST_RESOLVE_URL, |
| 232 "key did not start with files/"); | 226 "key did not start with files/"); |
| 233 return false; | 227 return false; |
| 234 } | 228 } |
| 235 // Append what follows files to the pnacl URL prefix. | 229 // Append what follows files to the pnacl URL prefix. |
| 236 nacl::string key_basename = key.substr(kFilesPrefix.length()); | 230 nacl::string key_basename = key.substr(kFilesPrefix.length()); |
| 237 return ResolveURL(key_basename, full_url, permit_extension_url, error_info); | 231 return ResolveURL(key_basename, full_url, error_info); |
| 238 } | 232 } |
| 239 | 233 |
| 240 private: | 234 private: |
| 241 NACL_DISALLOW_COPY_AND_ASSIGN(ExtensionManifest); | 235 NACL_DISALLOW_COPY_AND_ASSIGN(ExtensionManifest); |
| 242 | 236 |
| 243 const pp::URLUtil_Dev* url_util_; | 237 const pp::URLUtil_Dev* url_util_; |
| 244 nacl::string manifest_base_url_; | 238 nacl::string manifest_base_url_; |
| 245 }; | 239 }; |
| 246 | 240 |
| 247 // TEMPORARY: ld needs to look up dynamic libraries in the nexe's manifest | 241 // TEMPORARY: ld needs to look up dynamic libraries in the nexe's manifest |
| (...skipping 17 matching lines...) Expand all Loading... |
| 265 bool* is_portable) const { | 259 bool* is_portable) const { |
| 266 if (nexe_manifest_->GetProgramURL(full_url, error_info, is_portable)) { | 260 if (nexe_manifest_->GetProgramURL(full_url, error_info, is_portable)) { |
| 267 return true; | 261 return true; |
| 268 } | 262 } |
| 269 return extension_manifest_->GetProgramURL(full_url, error_info, | 263 return extension_manifest_->GetProgramURL(full_url, error_info, |
| 270 is_portable); | 264 is_portable); |
| 271 } | 265 } |
| 272 | 266 |
| 273 virtual bool ResolveURL(const nacl::string& relative_url, | 267 virtual bool ResolveURL(const nacl::string& relative_url, |
| 274 nacl::string* full_url, | 268 nacl::string* full_url, |
| 275 bool* permit_extension_url, | |
| 276 ErrorInfo* error_info) const { | 269 ErrorInfo* error_info) const { |
| 277 if (nexe_manifest_->ResolveURL(relative_url, full_url, | 270 if (nexe_manifest_->ResolveURL(relative_url, full_url, error_info)) { |
| 278 permit_extension_url, error_info)) { | |
| 279 return true; | 271 return true; |
| 280 } | 272 } |
| 281 return extension_manifest_->ResolveURL(relative_url, full_url, | 273 return extension_manifest_->ResolveURL(relative_url, full_url, error_info); |
| 282 permit_extension_url, error_info); | |
| 283 } | 274 } |
| 284 | 275 |
| 285 virtual bool GetFileKeys(std::set<nacl::string>* keys) const { | 276 virtual bool GetFileKeys(std::set<nacl::string>* keys) const { |
| 286 if (nexe_manifest_->GetFileKeys(keys)) { | 277 if (nexe_manifest_->GetFileKeys(keys)) { |
| 287 return true; | 278 return true; |
| 288 } | 279 } |
| 289 return extension_manifest_->GetFileKeys(keys); | 280 return extension_manifest_->GetFileKeys(keys); |
| 290 } | 281 } |
| 291 | 282 |
| 292 virtual bool ResolveKey(const nacl::string& key, | 283 virtual bool ResolveKey(const nacl::string& key, |
| 293 nacl::string* full_url, | 284 nacl::string* full_url, |
| 294 bool* permit_extension_url, | |
| 295 ErrorInfo* error_info, | 285 ErrorInfo* error_info, |
| 296 bool* is_portable) const { | 286 bool* is_portable) const { |
| 297 if (nexe_manifest_->ResolveKey(key, full_url, permit_extension_url, | 287 if (nexe_manifest_->ResolveKey(key, full_url, error_info, is_portable)) { |
| 298 error_info, is_portable)) { | |
| 299 return true; | 288 return true; |
| 300 } | 289 } |
| 301 return extension_manifest_->ResolveKey(key, full_url, permit_extension_url, | 290 return extension_manifest_->ResolveKey(key, full_url, |
| 302 error_info, is_portable); | 291 error_info, is_portable); |
| 303 } | 292 } |
| 304 | 293 |
| 305 private: | 294 private: |
| 306 NACL_DISALLOW_COPY_AND_ASSIGN(PnaclLDManifest); | 295 NACL_DISALLOW_COPY_AND_ASSIGN(PnaclLDManifest); |
| 307 | 296 |
| 308 const Manifest* nexe_manifest_; | 297 const Manifest* nexe_manifest_; |
| 309 const Manifest* extension_manifest_; | 298 const Manifest* extension_manifest_; |
| 310 }; | 299 }; |
| 311 | 300 |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 PLUGIN_PRINTF(("PnaclCoordinator::NexePairDidOpen (pp_error=%" | 492 PLUGIN_PRINTF(("PnaclCoordinator::NexePairDidOpen (pp_error=%" |
| 504 NACL_PRId32")\n", pp_error)); | 493 NACL_PRId32")\n", pp_error)); |
| 505 if (pp_error != PP_OK) { | 494 if (pp_error != PP_OK) { |
| 506 ReportPpapiError(pp_error); | 495 ReportPpapiError(pp_error); |
| 507 return; | 496 return; |
| 508 } | 497 } |
| 509 // Load the pexe file and get the translation started. | 498 // Load the pexe file and get the translation started. |
| 510 pp::CompletionCallback cb = | 499 pp::CompletionCallback cb = |
| 511 callback_factory_.NewCallback(&PnaclCoordinator::RunTranslate); | 500 callback_factory_.NewCallback(&PnaclCoordinator::RunTranslate); |
| 512 | 501 |
| 513 // "false" here indicates the pexe must be in user's manifest file origin. | 502 if (!plugin_->StreamAsFile(pexe_url_, cb.pp_completion_callback())) { |
| 514 if (!plugin_->StreamAsFile(pexe_url_, false, cb.pp_completion_callback())) { | |
| 515 ReportNonPpapiError(nacl::string("failed to download ") + pexe_url_ + "."); | 503 ReportNonPpapiError(nacl::string("failed to download ") + pexe_url_ + "."); |
| 516 } | 504 } |
| 517 } | 505 } |
| 518 | 506 |
| 519 void PnaclCoordinator::RunTranslate(int32_t pp_error) { | 507 void PnaclCoordinator::RunTranslate(int32_t pp_error) { |
| 520 PLUGIN_PRINTF(("PnaclCoordinator::RunTranslate (pp_error=%" | 508 PLUGIN_PRINTF(("PnaclCoordinator::RunTranslate (pp_error=%" |
| 521 NACL_PRId32")\n", pp_error)); | 509 NACL_PRId32")\n", pp_error)); |
| 522 int32_t fd = GetLoadedFileDesc(pp_error, pexe_url_, "pexe"); | 510 int32_t fd = GetLoadedFileDesc(pp_error, pexe_url_, "pexe"); |
| 523 if (fd < 0) { | 511 if (fd < 0) { |
| 524 return; | 512 return; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 nacl::MutexLocker ml(&subprocess_mu_); | 621 nacl::MutexLocker ml(&subprocess_mu_); |
| 634 return subprocesses_should_die_; | 622 return subprocesses_should_die_; |
| 635 } | 623 } |
| 636 | 624 |
| 637 void PnaclCoordinator::SetSubprocessesShouldDie(bool subprocesses_should_die) { | 625 void PnaclCoordinator::SetSubprocessesShouldDie(bool subprocesses_should_die) { |
| 638 nacl::MutexLocker ml(&subprocess_mu_); | 626 nacl::MutexLocker ml(&subprocess_mu_); |
| 639 subprocesses_should_die_ = subprocesses_should_die; | 627 subprocesses_should_die_ = subprocesses_should_die; |
| 640 } | 628 } |
| 641 | 629 |
| 642 } // namespace plugin | 630 } // namespace plugin |
| OLD | NEW |