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

Unified Diff: ppapi/proxy/plugin_var_tracker.cc

Issue 26564009: [PPAPI] It is now possible to pass filesystems from JavaScript to NaCl modules. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Use a vector instead of variable-length array. (Fix Windows compile). Created 7 years, 2 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: ppapi/proxy/plugin_var_tracker.cc
diff --git a/ppapi/proxy/plugin_var_tracker.cc b/ppapi/proxy/plugin_var_tracker.cc
index 0788b99923d44b5f4392d69374dbdb6e202c1c2e..a5a4fa9104e478ee1167aec43a7a1af61179c090 100644
--- a/ppapi/proxy/plugin_var_tracker.cc
+++ b/ppapi/proxy/plugin_var_tracker.cc
@@ -6,10 +6,13 @@
#include "base/memory/ref_counted.h"
#include "base/memory/singleton.h"
+#include "ipc/ipc_message.h"
#include "ppapi/c/dev/ppp_class_deprecated.h"
#include "ppapi/c/ppb_var.h"
+#include "ppapi/proxy/file_system_resource.h"
#include "ppapi/proxy/plugin_array_buffer_var.h"
#include "ppapi/proxy/plugin_dispatcher.h"
+#include "ppapi/proxy/plugin_globals.h"
#include "ppapi/proxy/plugin_resource_var.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/proxy/proxy_object_var.h"
@@ -22,6 +25,18 @@
namespace ppapi {
namespace proxy {
+namespace {
+
+// Should only be called when the Pepper plugin is out of process.
+Connection GetConnectionForInstance(PP_Instance instance) {
+ PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
+ // GetForInstance returns NULL in the in-process case.
+ DCHECK(dispatcher);
+ return Connection(PluginGlobals::Get()->GetBrowserSender(), dispatcher);
+}
+
+} // namespace
+
PluginVarTracker::HostVar::HostVar(PluginDispatcher* d, int32 i)
: dispatcher(d),
host_object_id(i) {
@@ -154,6 +169,40 @@ void PluginVarTracker::ReleaseHostObject(PluginDispatcher* dispatcher,
ReleaseVar(found->second);
}
+PP_Var PluginVarTracker::MakeResourcePPVar(const IPC::Message& creation_message,
+ int pending_renderer_id,
+ int pending_browser_id,
+ PP_Instance instance) {
+ DCHECK(pending_renderer_id);
+ DCHECK(pending_browser_id);
+ switch (creation_message.type()) {
+ case PpapiPluginMsg_FileSystem_CreateFromPendingHost::ID: {
+ PP_FileSystemType file_system_type;
+ if (!UnpackMessage<PpapiPluginMsg_FileSystem_CreateFromPendingHost>(
+ creation_message, &file_system_type)) {
raymes 2013/10/30 06:31:51 nit: indentation
Matt Giuca 2013/10/30 07:00:39 dmichael already picked this up. My reply: ClangF
+ NOTREACHED() << "Invalid message of type "
+ "PpapiPluginMsg_FileSystem_CreateFromPendingHost";
+ return PP_MakeNull();
+ }
+ // Create a plugin-side resource and attach it to the host resource.
+ // Note: This only makes sense when the plugin is out of process (which
+ // should always be true when passing resource vars).
+ PP_Resource pp_resource =
+ (new FileSystemResource(GetConnectionForInstance(instance),
+ instance,
+ pending_renderer_id,
+ pending_browser_id,
+ file_system_type))->GetReference();
+ return VarTracker::MakeResourcePPVar(pp_resource);
+ }
+ default: {
+ NOTREACHED() << "Creation message has unexpected type "
+ << creation_message.type();
+ return PP_MakeNull();
+ }
+ }
+}
+
ResourceVar* PluginVarTracker::MakeResourceVar(PP_Resource pp_resource) {
// The resource 0 returns a null resource var.
if (!pp_resource)

Powered by Google App Engine
This is Rietveld 408576698