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..89088fe5b7a22cd4021959ece91c5fbb7ee4f7af 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. |
dmichael (off chromium)
2013/10/30 17:47:27
This comment isn't really necessary anymore, since
Matt Giuca
2013/10/30 23:13:54
Done.
|
+Connection GetConnectionForInstance(PP_Instance instance) { |
+ PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
+ // PluginDispatcher::GetForInstance returns NULL in the in-process case. |
dmichael (off chromium)
2013/10/30 17:47:27
Ditto.
Matt Giuca
2013/10/30 23:13:54
Done.
|
+ 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(PP_Instance instance, |
+ const IPC::Message& creation_message, |
+ int pending_renderer_id, |
+ int pending_browser_id) { |
+ 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)) { |
+ 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) |