summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authorteravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-12 22:41:13 +0000
committerteravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-12 22:41:13 +0000
commit5feb6cd669becf277e46be1995601874846eff30 (patch)
treed9348bf6509b25eaffa7b6cbfdc3064b6a832041 /ppapi
parent2bd1fcf0d9c29762b83d73839b6f016b09d66d62 (diff)
downloadchromium_src-5feb6cd669becf277e46be1995601874846eff30.zip
chromium_src-5feb6cd669becf277e46be1995601874846eff30.tar.gz
chromium_src-5feb6cd669becf277e46be1995601874846eff30.tar.bz2
Trusted plugin: Remove ScriptablePlugin.
ScriptablePlugin no longer provides anything from the plugin element in the DOM since properties were moved in r237604. BUG=239656 R=dmichael@chromium.org Review URL: https://codereview.chromium.org/160533002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@250811 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/native_client/src/trusted/plugin/plugin.cc32
-rw-r--r--ppapi/native_client/src/trusted/plugin/plugin.gypi1
-rw-r--r--ppapi/native_client/src/trusted/plugin/plugin.h16
-rw-r--r--ppapi/native_client/src/trusted/plugin/scriptable_plugin.cc191
-rw-r--r--ppapi/native_client/src/trusted/plugin/scriptable_plugin.h111
5 files changed, 5 insertions, 346 deletions
diff --git a/ppapi/native_client/src/trusted/plugin/plugin.cc b/ppapi/native_client/src/trusted/plugin/plugin.cc
index 701851d..4eac81b 100644
--- a/ppapi/native_client/src/trusted/plugin/plugin.cc
+++ b/ppapi/native_client/src/trusted/plugin/plugin.cc
@@ -44,7 +44,6 @@
#include "ppapi/native_client/src/trusted/plugin/nacl_subprocess.h"
#include "ppapi/native_client/src/trusted/plugin/nexe_arch.h"
#include "ppapi/native_client/src/trusted/plugin/plugin_error.h"
-#include "ppapi/native_client/src/trusted/plugin/scriptable_plugin.h"
#include "ppapi/native_client/src/trusted/plugin/service_runtime.h"
#include "ppapi/native_client/src/trusted/plugin/utility.h"
@@ -537,14 +536,6 @@ bool Plugin::Init(uint32_t argc, const char* argn[], const char* argv[]) {
PLUGIN_PRINTF(("Plugin::Init (argc=%" NACL_PRIu32 ")\n", argc));
HistogramEnumerateOsArch(GetSandboxISA());
init_time_ = NaClGetTimeOfDayMicroseconds();
-
- ScriptablePlugin* scriptable_plugin = ScriptablePlugin::NewPlugin(this);
- if (scriptable_plugin == NULL)
- return false;
-
- set_scriptable_plugin(scriptable_plugin);
- PLUGIN_PRINTF(("Plugin::Init (scriptable_handle=%p)\n",
- static_cast<void*>(scriptable_plugin_)));
url_util_ = pp::URLUtil_Dev::Get();
if (url_util_ == NULL)
return false;
@@ -607,8 +598,7 @@ bool Plugin::Init(uint32_t argc, const char* argn[], const char* argv[]) {
}
Plugin::Plugin(PP_Instance pp_instance)
- : pp::InstancePrivate(pp_instance),
- scriptable_plugin_(NULL),
+ : pp::Instance(pp_instance),
argc_(-1),
argn_(NULL),
argv_(NULL),
@@ -641,9 +631,8 @@ Plugin::Plugin(PP_Instance pp_instance)
Plugin::~Plugin() {
int64_t shutdown_start = NaClGetTimeOfDayMicroseconds();
- PLUGIN_PRINTF(("Plugin::~Plugin (this=%p, scriptable_plugin=%p)\n",
- static_cast<void*>(this),
- static_cast<void*>(scriptable_plugin())));
+ PLUGIN_PRINTF(("Plugin::~Plugin (this=%p)\n",
+ static_cast<void*>(this)));
// Destroy the coordinator while the rest of the data is still there
pnacl_coordinator_.reset(NULL);
@@ -661,9 +650,6 @@ Plugin::~Plugin() {
}
url_downloaders_.erase(url_downloaders_.begin(), url_downloaders_.end());
- ScriptablePlugin* scriptable_plugin_ = scriptable_plugin();
- ScriptablePlugin::Unref(&scriptable_plugin_);
-
// ShutDownSubprocesses shuts down the main subprocess, which shuts
// down the main ServiceRuntime object, which kills the subprocess.
// As a side effect of the subprocess being killed, the reverse
@@ -711,18 +697,6 @@ bool Plugin::HandleDocumentLoad(const pp::URLLoader& url_loader) {
return true;
}
-pp::Var Plugin::GetInstanceObject() {
- PLUGIN_PRINTF(("Plugin::GetInstanceObject (this=%p)\n",
- static_cast<void*>(this)));
- // The browser will unref when it discards the var for this object.
- ScriptablePlugin* handle =
- static_cast<ScriptablePlugin*>(scriptable_plugin()->AddRef());
- pp::Var* handle_var = handle->var();
- PLUGIN_PRINTF(("Plugin::GetInstanceObject (handle=%p, handle_var=%p)\n",
- static_cast<void*>(handle), static_cast<void*>(handle_var)));
- return *handle_var; // make a copy
-}
-
void Plugin::HistogramStartupTimeSmall(const std::string& name, float dt) {
if (nexe_size_ > 0) {
float size_in_MB = static_cast<float>(nexe_size_) / (1024.f * 1024.f);
diff --git a/ppapi/native_client/src/trusted/plugin/plugin.gypi b/ppapi/native_client/src/trusted/plugin/plugin.gypi
index 5d3aa94..fd70909 100644
--- a/ppapi/native_client/src/trusted/plugin/plugin.gypi
+++ b/ppapi/native_client/src/trusted/plugin/plugin.gypi
@@ -17,7 +17,6 @@
'pnacl_options.cc',
'pnacl_resources.cc',
'pnacl_translate_thread.cc',
- 'scriptable_plugin.cc',
'sel_ldr_launcher_chrome.cc',
'service_runtime.cc',
'srpc_client.cc',
diff --git a/ppapi/native_client/src/trusted/plugin/plugin.h b/ppapi/native_client/src/trusted/plugin/plugin.h
index 3c17698..d2432c8 100644
--- a/ppapi/native_client/src/trusted/plugin/plugin.h
+++ b/ppapi/native_client/src/trusted/plugin/plugin.h
@@ -22,7 +22,7 @@
#include "native_client/src/trusted/validator/nacl_file_info.h"
#include "ppapi/c/private/ppb_nacl_private.h"
-#include "ppapi/cpp/private/instance_private.h"
+#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/private/uma_private.h"
#include "ppapi/cpp/url_loader.h"
#include "ppapi/cpp/var.h"
@@ -52,9 +52,8 @@ namespace plugin {
class ErrorInfo;
class Manifest;
-class ScriptablePlugin;
-class Plugin : public pp::InstancePrivate {
+class Plugin : public pp::Instance {
public:
// Factory method for creation.
static Plugin* New(PP_Instance instance);
@@ -69,10 +68,6 @@ class Plugin : public pp::InstancePrivate {
// Handles document load, when the plugin is a MIME type handler.
virtual bool HandleDocumentLoad(const pp::URLLoader& url_loader);
- // Returns a scriptable reference to this plugin element.
- // Called by JavaScript document.getElementById(plugin_id).
- virtual pp::Var GetInstanceObject();
-
// ----- Plugin interface support.
// Load support.
@@ -262,11 +257,6 @@ class Plugin : public pp::InstancePrivate {
// in this order, for the main nacl subprocess.
void ShutDownSubprocesses();
- ScriptablePlugin* scriptable_plugin() const { return scriptable_plugin_; }
- void set_scriptable_plugin(ScriptablePlugin* scriptable_plugin) {
- scriptable_plugin_ = scriptable_plugin;
- }
-
// Access the service runtime for the main NaCl subprocess.
ServiceRuntime* main_service_runtime() const {
return main_subprocess_.service_runtime();
@@ -391,8 +381,6 @@ class Plugin : public pp::InstancePrivate {
void SetExitStatusOnMainThread(int32_t pp_error, int exit_status);
- ScriptablePlugin* scriptable_plugin_;
-
int argc_;
char** argn_;
char** argv_;
diff --git a/ppapi/native_client/src/trusted/plugin/scriptable_plugin.cc b/ppapi/native_client/src/trusted/plugin/scriptable_plugin.cc
deleted file mode 100644
index 05c0455..0000000
--- a/ppapi/native_client/src/trusted/plugin/scriptable_plugin.cc
+++ /dev/null
@@ -1,191 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Scriptable plugin implementation.
-
-#include "ppapi/native_client/src/trusted/plugin/scriptable_plugin.h"
-
-#include <string.h>
-
-#include <sstream>
-#include <string>
-#include <vector>
-
-#include "native_client/src/include/nacl_macros.h"
-#include "native_client/src/include/nacl_string.h"
-#include "native_client/src/include/portability.h"
-#include "native_client/src/shared/platform/nacl_check.h"
-#include "native_client/src/shared/srpc/nacl_srpc.h"
-#include "ppapi/native_client/src/trusted/plugin/plugin.h"
-#include "ppapi/native_client/src/trusted/plugin/utility.h"
-
-
-namespace plugin {
-
-namespace {
-
-pp::Var Error(const nacl::string& call_name, const char* caller,
- const char* error, pp::Var* exception) {
- nacl::stringstream error_stream;
- error_stream << call_name << ": " << error;
- if (!exception->is_undefined()) {
- error_stream << " - " + exception->AsString();
- }
- // Get the error string in 2 steps; otherwise, the temporary string returned
- // by the stream is destructed, causing a dangling pointer.
- std::string str = error_stream.str();
- const char* e = str.c_str();
- PLUGIN_PRINTF(("ScriptablePlugin::%s (%s)\n", caller, e));
- *exception = pp::Var(e);
- return pp::Var();
-}
-
-} // namespace
-
-ScriptablePlugin::ScriptablePlugin(Plugin* plugin)
- : var_(NULL), num_unref_calls_(0), plugin_(plugin) {
- PLUGIN_PRINTF(("ScriptablePlugin::ScriptablePlugin (this=%p, plugin=%p)\n",
- static_cast<void*>(this),
- static_cast<void*>(plugin)));
-}
-
-ScriptablePlugin::~ScriptablePlugin() {
- PLUGIN_PRINTF(("ScriptablePlugin::~ScriptablePlugin (this=%p)\n",
- static_cast<void*>(this)));
- PLUGIN_PRINTF(("ScriptablePlugin::~ScriptablePlugin (this=%p, return)\n",
- static_cast<void*>(this)));
-}
-
-void ScriptablePlugin::Unref(ScriptablePlugin** handle) {
- if (*handle != NULL) {
- (*handle)->Unref();
- *handle = NULL;
- }
-}
-
-ScriptablePlugin* ScriptablePlugin::NewPlugin(Plugin* plugin) {
- PLUGIN_PRINTF(("ScriptablePlugin::NewPlugin (plugin=%p)\n",
- static_cast<void*>(plugin)));
- if (plugin == NULL) {
- return NULL;
- }
- ScriptablePlugin* scriptable_plugin = new ScriptablePlugin(plugin);
- if (scriptable_plugin == NULL) {
- return NULL;
- }
- PLUGIN_PRINTF(("ScriptablePlugin::NewPlugin (return %p)\n",
- static_cast<void*>(scriptable_plugin)));
- return scriptable_plugin;
-}
-
-bool ScriptablePlugin::HasProperty(const pp::Var& name, pp::Var* exception) {
- UNREFERENCED_PARAMETER(exception);
- PLUGIN_PRINTF(("ScriptablePlugin::HasProperty (this=%p, name=%s)\n",
- static_cast<void*>(this), name.DebugString().c_str()));
- return false;
-}
-
-bool ScriptablePlugin::HasMethod(const pp::Var& name, pp::Var* exception) {
- UNREFERENCED_PARAMETER(exception);
- PLUGIN_PRINTF(("ScriptablePlugin::HasMethod (this=%p, name='%s')\n",
- static_cast<void*>(this), name.DebugString().c_str()));
- return false;
-}
-
-pp::Var ScriptablePlugin::GetProperty(const pp::Var& name,
- pp::Var* exception) {
- PLUGIN_PRINTF(("ScriptablePlugin::GetProperty (name=%s)\n",
- name.DebugString().c_str()));
- Error("GetProperty", name.DebugString().c_str(),
- "property getting is not supported", exception);
- return pp::Var();
-}
-
-void ScriptablePlugin::SetProperty(const pp::Var& name,
- const pp::Var& value,
- pp::Var* exception) {
- PLUGIN_PRINTF(("ScriptablePlugin::SetProperty (name=%s, value=%s)\n",
- name.DebugString().c_str(), value.DebugString().c_str()));
- Error("SetProperty", name.DebugString().c_str(),
- "property setting is not supported", exception);
-}
-
-
-void ScriptablePlugin::RemoveProperty(const pp::Var& name,
- pp::Var* exception) {
- PLUGIN_PRINTF(("ScriptablePlugin::RemoveProperty (name=%s)\n",
- name.DebugString().c_str()));
- Error("RemoveProperty", name.DebugString().c_str(),
- "property removal is not supported", exception);
-}
-
-void ScriptablePlugin::GetAllPropertyNames(std::vector<pp::Var>* properties,
- pp::Var* exception) {
- PLUGIN_PRINTF(("ScriptablePlugin::GetAllPropertyNames ()\n"));
- UNREFERENCED_PARAMETER(properties);
- UNREFERENCED_PARAMETER(exception);
- Error("GetAllPropertyNames", "", "GetAllPropertyNames is not supported",
- exception);
-}
-
-
-pp::Var ScriptablePlugin::Call(const pp::Var& name,
- const std::vector<pp::Var>& args,
- pp::Var* exception) {
- PLUGIN_PRINTF(("ScriptablePlugin::Call (name=%s, %" NACL_PRIuS
- " args)\n", name.DebugString().c_str(), args.size()));
- return Error("Call", name.DebugString().c_str(),
- "method invocation is not supported", exception);
-}
-
-
-pp::Var ScriptablePlugin::Construct(const std::vector<pp::Var>& args,
- pp::Var* exception) {
- PLUGIN_PRINTF(("ScriptablePlugin::Construct (%" NACL_PRIuS
- " args)\n", args.size()));
- return Error("constructor", "Construct", "constructor is not supported",
- exception);
-}
-
-
-ScriptablePlugin* ScriptablePlugin::AddRef() {
- // This is called when we are about to share this object with the browser,
- // and we need to make sure we have an internal plugin reference, so this
- // object doesn't get deallocated when the browser discards its references.
- if (var_ == NULL) {
- var_ = new pp::VarPrivate(plugin_, this);
- CHECK(var_ != NULL);
- }
- PLUGIN_PRINTF(("ScriptablePlugin::AddRef (this=%p, var=%p)\n",
- static_cast<void*>(this), static_cast<void*>(var_)));
- return this;
-}
-
-
-void ScriptablePlugin::Unref() {
- // We should have no more than one internal owner of this object, so this
- // should be called no more than once.
- CHECK(++num_unref_calls_ == 1);
- PLUGIN_PRINTF(("ScriptablePlugin::Unref (this=%p, var=%p)\n",
- static_cast<void*>(this), static_cast<void*>(var_)));
- if (var_ != NULL) {
- // We have shared this with the browser while keeping our own var
- // reference, but we no longer need ours. If the browser has copies,
- // it will clean things up later, otherwise this object will get
- // deallocated right away.
- PLUGIN_PRINTF(("ScriptablePlugin::Unref (delete var)\n"));
- pp::Var* var = var_;
- var_ = NULL;
- delete var;
- } else {
- // Neither the browser nor plugin ever var referenced this object,
- // so it can safely discarded.
- PLUGIN_PRINTF(("ScriptablePlugin::Unref (delete this)\n"));
- CHECK(var_ == NULL);
- delete this;
- }
-}
-
-
-} // namespace plugin
diff --git a/ppapi/native_client/src/trusted/plugin/scriptable_plugin.h b/ppapi/native_client/src/trusted/plugin/scriptable_plugin.h
deleted file mode 100644
index d9b000dd..0000000
--- a/ppapi/native_client/src/trusted/plugin/scriptable_plugin.h
+++ /dev/null
@@ -1,111 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// The browser scriptable container class. The methods on this class
-// are defined in the specific API directories.
-
-#ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SCRIPTABLE_PLUGIN_H_
-#define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SCRIPTABLE_PLUGIN_H_
-
-#include <vector>
-
-#include "native_client/src/include/nacl_macros.h"
-#include "native_client/src/include/portability.h"
-#include "ppapi/cpp/dev/scriptable_object_deprecated.h"
-#include "ppapi/cpp/private/var_private.h"
-#include "ppapi/native_client/src/trusted/plugin/utility.h"
-
-namespace plugin {
-
-// Forward declarations for externals.
-class Plugin;
-
-// ScriptablePlugin encapsulates plugins that are scriptable from the browser.
-class ScriptablePlugin : public pp::deprecated::ScriptableObject {
- public:
- // Factory method.
- static ScriptablePlugin* NewPlugin(Plugin* plugin);
-
- // If not NULL, this var should be reused to pass this object to the browser.
- pp::VarPrivate* var() { return var_; }
-
- static void Unref(ScriptablePlugin** handle);
-
- // Get the contained plugin object. NULL if this contains a descriptor.
- Plugin* plugin() const { return plugin_; }
-
- // This function is called when we are about to share the object owned by the
- // plugin with the browser. Since reference counting on the browser side is
- // handled via pp::Var's, we create the var() here if not created already.
- ScriptablePlugin* AddRef();
- // Remove a browser reference to this object.
- // Delete the object when the ref count becomes 0.
- // If var() is set, we delete it. Otherwise, we delete the object itself.
- // Therefore, this cannot be called more than once.
- void Unref();
-
- // ------ Methods inherited from pp::deprecated::ScriptableObject:
-
- // Returns true for preloaded NaCl Plugin properties.
- // Does not set |exception|.
- virtual bool HasProperty(const pp::Var& name, pp::Var* exception);
- // Returns true for preloaded NaCl Plugin methods and SRPC methods exported
- // from a NaCl module. Does not set |exception|.
- virtual bool HasMethod(const pp::Var& name, pp::Var* exception);
-
- // Gets the value of a preloaded NaCl Plugin property.
- // Sets |exception| on failure.
- virtual pp::Var GetProperty(const pp::Var& name, pp::Var* exception);
- // Sets the value of a preloaded NaCl Plugin property.
- // Does not add new properties. Sets |exception| of failure.
- virtual void SetProperty(const pp::Var& name, const pp::Var& value,
- pp::Var* exception);
- // Set |exception| to indicate that property removal is not supported.
- virtual void RemoveProperty(const pp::Var& name, pp::Var* exception);
- // Returns a list of all preloaded NaCl Plugin |properties|.
- // Does not set |exception|.
- virtual void GetAllPropertyNames(std::vector<pp::Var>* properties,
- pp::Var* exception);
-
- // Calls preloaded NaCl Plugin methods or SRPC methods exported from
- // a NaCl module. Sets |exception| on failure.
- virtual pp::Var Call(const pp::Var& name, const std::vector<pp::Var>& args,
- pp::Var* exception);
-
- // Sets |exception| to indicate that constructor is not supported.
- virtual pp::Var Construct(const std::vector<pp::Var>& args,
- pp::Var* exception);
-
- private:
- NACL_DISALLOW_COPY_AND_ASSIGN(ScriptablePlugin);
- // Prevent construction from outside the class: must use factory New()
- // method instead.
- explicit ScriptablePlugin(Plugin* plugin);
- // This will be called when both the plugin and the browser clear all
- // references to this object.
- virtual ~ScriptablePlugin();
-
- // When we pass the object owned by the plugin to the browser, we need to wrap
- // it in a pp::VarPrivate, which also registers the object with the browser
- // for refcounting. It must be registered only once with all other var
- // references being copies of the original one. Thus, we record the
- // pp::VarPrivate here and reuse it when satisfiying additional browser
- // requests. This way we also ensure that when the browser clears its
- // references, this object does not get deallocated while we still hold ours.
- // This is never set for objects that are not shared with the browser nor for
- // objects created during SRPC calls as they are taken over by the browser on
- // return.
- pp::VarPrivate* var_;
-
- // We should have no more than one internal plugin owner for this object,
- // and only that owner should call Unref(). To CHECK for that keep a counter.
- int num_unref_calls_;
-
- // The contained plugin object.
- Plugin* plugin_;
-};
-
-} // namespace plugin
-
-#endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SCRIPTABLE_PLUGIN_H_