Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Unified Diff: trunk/src/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc

Issue 265393004: Revert 268280 "Pepper: Move manifest logic to components/nacl." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: trunk/src/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc
===================================================================
--- trunk/src/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc (revision 268294)
+++ trunk/src/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc (working copy)
@@ -16,6 +16,7 @@
#include "ppapi/c/pp_errors.h"
#include "ppapi/c/private/ppb_uma_private.h"
+#include "ppapi/native_client/src/trusted/plugin/manifest.h"
#include "ppapi/native_client/src/trusted/plugin/plugin.h"
#include "ppapi/native_client/src/trusted/plugin/plugin_error.h"
#include "ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.h"
@@ -25,6 +26,62 @@
namespace plugin {
//////////////////////////////////////////////////////////////////////
+// Pnacl-specific manifest support.
+//////////////////////////////////////////////////////////////////////
+
+// The PNaCl linker gets file descriptors via the service runtime's
+// reverse service lookup. The reverse service lookup requires a manifest.
+// Normally, that manifest is an NMF containing mappings for shared libraries.
+// Here, we provide a manifest that redirects to PNaCl component files
+// that are part of Chrome.
+class PnaclManifest : public Manifest {
+ public:
+ PnaclManifest(const nacl::string& sandbox_arch)
+ : sandbox_arch_(sandbox_arch) { }
+
+ virtual ~PnaclManifest() { }
+
+ virtual bool GetProgramURL(nacl::string* full_url,
+ PP_PNaClOptions* pnacl_options,
+ bool* uses_nonsfi_mode,
+ ErrorInfo* error_info) const {
+ // Does not contain program urls.
+ UNREFERENCED_PARAMETER(full_url);
+ UNREFERENCED_PARAMETER(pnacl_options);
+ UNREFERENCED_PARAMETER(uses_nonsfi_mode);
+ UNREFERENCED_PARAMETER(error_info);
+ PLUGIN_PRINTF(("PnaclManifest does not contain a program\n"));
+ error_info->SetReport(PP_NACL_ERROR_MANIFEST_GET_NEXE_URL,
+ "pnacl manifest does not contain a program.");
+ return false;
+ }
+
+ virtual bool ResolveKey(const nacl::string& key,
+ nacl::string* full_url,
+ PP_PNaClOptions* pnacl_options) const {
+ // All of the component files are native (do not require pnacl translate).
+ pnacl_options->translate = PP_FALSE;
+ // We can only resolve keys in the files/ namespace.
+ const nacl::string kFilesPrefix = "files/";
+ size_t files_prefix_pos = key.find(kFilesPrefix);
+ if (files_prefix_pos == nacl::string::npos) {
+ PLUGIN_PRINTF(("key did not start with files/"));
+ return false;
+ }
+ // Resolve the full URL to the file. Provide it with a platform-specific
+ // prefix.
+ nacl::string key_basename = key.substr(kFilesPrefix.length());
+ *full_url = PnaclUrls::GetBaseUrl() + sandbox_arch_ + "/" + key_basename;
+ return true;
+ }
+
+ private:
+ NACL_DISALLOW_COPY_AND_ASSIGN(PnaclManifest);
+
+ nacl::string sandbox_arch_;
+};
+
+//////////////////////////////////////////////////////////////////////
// UMA stat helpers.
//////////////////////////////////////////////////////////////////////
@@ -123,10 +180,10 @@
new PnaclCoordinator(plugin, pexe_url,
pnacl_options,
translate_notify_callback);
- PLUGIN_PRINTF(("PnaclCoordinator::BitcodeToNative (manifest_id=%d)\n",
- coordinator->manifest_id_));
+ coordinator->pnacl_init_time_ = NaClGetTimeOfDayMicroseconds();
+ PLUGIN_PRINTF(("PnaclCoordinator::BitcodeToNative (manifest=%p, ",
+ reinterpret_cast<const void*>(coordinator->manifest_.get())));
- coordinator->pnacl_init_time_ = NaClGetTimeOfDayMicroseconds();
int cpus = plugin->nacl_interface()->GetNumberOfProcessors();
coordinator->split_module_count_ = std::min(4, std::max(1, cpus));
@@ -147,8 +204,7 @@
plugin_(plugin),
translate_notify_callback_(translate_notify_callback),
translation_finished_reported_(false),
- manifest_id_(
- GetNaClInterface()->CreatePnaclManifest(plugin->pp_instance())),
+ manifest_(new PnaclManifest(plugin->nacl_interface()->GetSandboxArch())),
pexe_url_(pexe_url),
pnacl_options_(pnacl_options),
split_module_count_(1),
@@ -612,7 +668,7 @@
CHECK(translate_thread_ != NULL);
translate_thread_->RunTranslate(report_translate_finished,
- manifest_id_,
+ manifest_.get(),
&obj_files_,
temp_nexe_file_.get(),
invalid_desc_wrapper_.get(),

Powered by Google App Engine
This is Rietveld 408576698