summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authorteravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-29 20:12:43 +0000
committerteravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-29 20:12:43 +0000
commit2a292cf49ab2acaec2ea1da591a5f8cdd3fd62e0 (patch)
tree369d9cc6c18cff0757d6499b80542191468d90d3 /ppapi
parent3b167405adca5fc8cc69f07f55517fe4950bf039 (diff)
downloadchromium_src-2a292cf49ab2acaec2ea1da591a5f8cdd3fd62e0.zip
chromium_src-2a292cf49ab2acaec2ea1da591a5f8cdd3fd62e0.tar.gz
chromium_src-2a292cf49ab2acaec2ea1da591a5f8cdd3fd62e0.tar.bz2
Trusted plugin: Miscellaneous cleanup.
This removes some unnecessary code in the trusted plugin. I broke this out to its own change while fixing up other things. BUG=239656 R=dmichael@chromium.org Review URL: https://codereview.chromium.org/260053008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@266945 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/native_client/src/trusted/plugin/module_ppapi.cc2
-rw-r--r--ppapi/native_client/src/trusted/plugin/plugin.cc37
-rw-r--r--ppapi/native_client/src/trusted/plugin/plugin.h12
3 files changed, 15 insertions, 36 deletions
diff --git a/ppapi/native_client/src/trusted/plugin/module_ppapi.cc b/ppapi/native_client/src/trusted/plugin/module_ppapi.cc
index bc7a2c5..5839ba6 100644
--- a/ppapi/native_client/src/trusted/plugin/module_ppapi.cc
+++ b/ppapi/native_client/src/trusted/plugin/module_ppapi.cc
@@ -72,7 +72,7 @@ pp::Instance* ModulePpapi::CreateInstance(PP_Instance pp_instance) {
MODULE_PRINTF(("ModulePpapi::CreateInstance (pp_instance=%" NACL_PRId32
")\n",
pp_instance));
- Plugin* plugin = Plugin::New(pp_instance);
+ Plugin* plugin = new Plugin(pp_instance);
MODULE_PRINTF(("ModulePpapi::CreateInstance (return %p)\n",
static_cast<void* >(plugin)));
return plugin;
diff --git a/ppapi/native_client/src/trusted/plugin/plugin.cc b/ppapi/native_client/src/trusted/plugin/plugin.cc
index eace438..c2fcbd8 100644
--- a/ppapi/native_client/src/trusted/plugin/plugin.cc
+++ b/ppapi/native_client/src/trusted/plugin/plugin.cc
@@ -354,23 +354,12 @@ NaClSubprocess* Plugin::LoadHelperNaClModule(const nacl::string& helper_url,
return nacl_subprocess.release();
}
-Plugin* Plugin::New(PP_Instance pp_instance) {
- PLUGIN_PRINTF(("Plugin::New (pp_instance=%" NACL_PRId32 ")\n", pp_instance));
- Plugin* plugin = new Plugin(pp_instance);
- PLUGIN_PRINTF(("Plugin::New (plugin=%p)\n", static_cast<void*>(plugin)));
- return plugin;
-}
-
// All failures of this function will show up as "Missing Plugin-in", so
// there is no need to log to JS console that there was an initialization
// failure. Note that module loading functions will log their own errors.
bool Plugin::Init(uint32_t argc, const char* argn[], const char* argv[]) {
PLUGIN_PRINTF(("Plugin::Init (argc=%" NACL_PRIu32 ")\n", argc));
nacl_interface_->InitializePlugin(pp_instance(), argc, argn, argv);
- url_util_ = pp::URLUtil_Dev::Get();
- if (url_util_ == NULL)
- return false;
-
wrapper_factory_ = new nacl::DescWrapperFactory();
pp::Var manifest_url(pp::PASS_REF, nacl_interface_->GetManifestURLArgument(
pp_instance()));
@@ -654,15 +643,13 @@ void Plugin::NaClManifestFileDidOpen(int32_t pp_error) {
void Plugin::ProcessNaClManifest(const nacl::string& manifest_json) {
HistogramSizeKB("NaCl.Perf.Size.Manifest",
static_cast<int32_t>(manifest_json.length() / 1024));
- ErrorInfo error_info;
- if (!SetManifestObject(manifest_json, &error_info)) {
- ReportLoadError(error_info);
+ if (!SetManifestObject(manifest_json))
return;
- }
nacl::string program_url;
PP_PNaClOptions pnacl_options = {PP_FALSE, PP_FALSE, 2};
bool uses_nonsfi_mode;
+ ErrorInfo error_info;
if (manifest_->GetProgramURL(
&program_url, &pnacl_options, &uses_nonsfi_mode, &error_info)) {
// TODO(teravest): Make ProcessNaClManifest take responsibility for more of
@@ -742,12 +729,11 @@ void Plugin::RequestNaClManifest(const nacl::string& url) {
}
-bool Plugin::SetManifestObject(const nacl::string& manifest_json,
- ErrorInfo* error_info) {
+bool Plugin::SetManifestObject(const nacl::string& manifest_json) {
PLUGIN_PRINTF(("Plugin::SetManifestObject(): manifest_json='%s'.\n",
manifest_json.c_str()));
- if (error_info == NULL)
- return false;
+ ErrorInfo error_info;
+
// Determine whether lookups should use portable (i.e., pnacl versions)
// rather than platform-specific files.
bool is_pnacl = nacl_interface_->IsPNaCl(pp_instance());
@@ -760,12 +746,13 @@ bool Plugin::SetManifestObject(const nacl::string& manifest_json,
manifest_base_url_str.c_str());
const char* sandbox_isa = nacl_interface_->GetSandboxArch();
nacl::scoped_ptr<JsonManifest> json_manifest(
- new JsonManifest(url_util_,
+ new JsonManifest(pp::URLUtil_Dev::Get(),
manifest_base_url_str,
(is_pnacl ? kPortableArch : sandbox_isa),
nonsfi_mode_enabled,
pnacl_debug));
- if (!json_manifest->Init(manifest_json, error_info)) {
+ if (!json_manifest->Init(manifest_json, &error_info)) {
+ ReportLoadError(error_info);
return false;
}
manifest_.reset(json_manifest.release());
@@ -790,9 +777,8 @@ void Plugin::UrlDidOpenForStreamAsFile(
} else if (info->get_desc() > NACL_NO_FILE_DESC) {
std::map<nacl::string, NaClFileInfoAutoCloser*>::iterator it =
url_file_info_map_.find(url_downloader->url());
- if (it != url_file_info_map_.end()) {
+ if (it != url_file_info_map_.end())
delete it->second;
- }
url_file_info_map_[url_downloader->url()] = info;
callback.Run(PP_OK);
} else {
@@ -974,8 +960,9 @@ bool Plugin::OpenURLFast(const nacl::string& url,
}
bool Plugin::DocumentCanRequest(const std::string& url) {
- CHECK(url_util_ != NULL);
- return url_util_->DocumentCanRequest(this, pp::Var(url));
+ CHECK(pp::Module::Get()->core()->IsMainThread());
+ CHECK(pp::URLUtil_Dev::Get() != NULL);
+ return pp::URLUtil_Dev::Get()->DocumentCanRequest(this, pp::Var(url));
}
void Plugin::set_exit_status(int exit_status) {
diff --git a/ppapi/native_client/src/trusted/plugin/plugin.h b/ppapi/native_client/src/trusted/plugin/plugin.h
index 870c38a..717812a 100644
--- a/ppapi/native_client/src/trusted/plugin/plugin.h
+++ b/ppapi/native_client/src/trusted/plugin/plugin.h
@@ -52,8 +52,7 @@ class Manifest;
class Plugin : public pp::Instance {
public:
- // Factory method for creation.
- static Plugin* New(PP_Instance instance);
+ explicit Plugin(PP_Instance instance);
// ----- Methods inherited from pp::Instance:
@@ -166,7 +165,6 @@ class Plugin : public pp::Instance {
bool DocumentCanRequest(const std::string& url);
Manifest const* manifest() const { return manifest_.get(); }
- const pp::URLUtil_Dev* url_util() const { return url_util_; }
// set_exit_status may be called off the main thread.
void set_exit_status(int exit_status);
@@ -176,9 +174,6 @@ class Plugin : public pp::Instance {
private:
NACL_DISALLOW_COPY_AND_ASSIGN(Plugin);
- // Prevent construction and destruction from outside the class:
- // must use factory New() method instead.
- explicit Plugin(PP_Instance instance);
// The browser will invoke the destructor via the pp::Instance
// pointer to this object, not from base's Delete().
~Plugin();
@@ -274,8 +269,7 @@ class Plugin : public pp::Instance {
// On success, |true| is returned and |manifest_| is updated to
// contain a Manifest that is used by SelectNexeURLFromManifest.
// On failure, |false| is returned, and |manifest_| is unchanged.
- bool SetManifestObject(const nacl::string& manifest_json,
- ErrorInfo* error_info);
+ bool SetManifestObject(const nacl::string& manifest_json);
// Logs timing information to a UMA histogram, and also logs the same timing
// information divided by the size of the nexe to another histogram.
@@ -314,8 +308,6 @@ class Plugin : public pp::Instance {
// The manifest dictionary. Used for looking up resources to be loaded.
nacl::scoped_ptr<Manifest> manifest_;
- // URL processing interface for use in looking up resources in manifests.
- const pp::URLUtil_Dev* url_util_;
// Keep track of the FileDownloaders created to fetch urls.
std::set<FileDownloader*> url_downloaders_;