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

Unified Diff: ppapi/proxy/raw_var_data.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: GetConnectionForInstance DCHECKs if in-process. 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/raw_var_data.cc
diff --git a/ppapi/proxy/raw_var_data.cc b/ppapi/proxy/raw_var_data.cc
index 91bcfbfd1f0b0448126f2da92cc6081076cd1f14..d7b63693021adfbcd946971653fb992467a4ea35 100644
--- a/ppapi/proxy/raw_var_data.cc
+++ b/ppapi/proxy/raw_var_data.cc
@@ -9,7 +9,12 @@
#include "base/containers/hash_tables.h"
#include "base/stl_util.h"
#include "ipc/ipc_message.h"
+#include "ppapi/proxy/file_system_resource.h"
+#include "ppapi/proxy/plugin_dispatcher.h"
+#include "ppapi/proxy/plugin_globals.h"
+#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/proxy/ppapi_param_traits.h"
+#include "ppapi/proxy/resource_creation_proxy.h"
#include "ppapi/shared_impl/array_var.h"
#include "ppapi/shared_impl/dictionary_var.h"
#include "ppapi/shared_impl/ppapi_globals.h"
@@ -64,6 +69,14 @@ bool CanHaveChildren(PP_Var var) {
return var.type == PP_VARTYPE_ARRAY || var.type == PP_VARTYPE_DICTIONARY;
}
+// 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
// RawVarDataGraph ------------------------------------------------------------
@@ -695,12 +708,40 @@ bool ResourceRawVarData::Init(const PP_Var& var, PP_Instance /*instance*/) {
}
PP_Var ResourceRawVarData::CreatePPVar(PP_Instance instance) {
- // If pp_resource_ is NULL, it could be because we are on the plugin side and
- // there is a pending resource host on the renderer.
- // TODO(mgiuca): Create a plugin-side resource in this case.
- // Currently, this should never occur. This will be needed when passing a
- // resource from the renderer to the plugin (http://crbug.com/177017).
- DCHECK(pp_resource_);
+ // If we are on the plugin side, and the var is a pending resource host,
+ // create a plugin-side resource. A var is a pending resource host if it has a
+ // pp_resource of 0, and a non-null creation message.
+ if (PpapiGlobals::Get()->IsPluginGlobals() && !pp_resource_ &&
+ creation_message_) {
+ DCHECK(pending_renderer_host_id_);
+ DCHECK(pending_browser_host_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_ =
+ (new FileSystemResource(GetConnectionForInstance(instance),
+ instance,
+ pending_renderer_host_id_,
+ pending_browser_host_id_,
+ file_system_type))->GetReference();
+ break;
+ }
+ default: {
+ NOTREACHED() << "Creation message has unexpected type "
+ << creation_message_->type();
+ return PP_MakeNull();
+ }
+ }
+ }
return PpapiGlobals::Get()->GetVarTracker()->MakeResourcePPVar(pp_resource_);
}

Powered by Google App Engine
This is Rietveld 408576698