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

Unified Diff: content/renderer/pepper/pepper_file_io_host.cc

Issue 18063005: Do PPB_FileIO Query and Read in the plugin process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Clean up and add comments. Created 7 years, 4 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: content/renderer/pepper/pepper_file_io_host.cc
diff --git a/content/renderer/pepper/pepper_file_io_host.cc b/content/renderer/pepper/pepper_file_io_host.cc
index 4d78f015f498d7d52bdbded755bb2d336899e061..7896c2254cdeaad533f594a0320c7f5011d6463b 100644
--- a/content/renderer/pepper/pepper_file_io_host.cc
+++ b/content/renderer/pepper/pepper_file_io_host.cc
@@ -23,6 +23,7 @@
#include "content/renderer/pepper/quota_file_io.h"
#include "content/renderer/render_thread_impl.h"
#include "ppapi/c/pp_errors.h"
+#include "ppapi/c/ppb_file_io.h"
#include "ppapi/host/dispatch_host_message.h"
#include "ppapi/host/ppapi_host.h"
#include "ppapi/proxy/ppapi_messages.h"
@@ -143,6 +144,7 @@ PepperFileIOHost::PepperFileIOHost(RendererPpapiHost* host,
PP_Instance instance,
PP_Resource resource)
: ResourceHost(host->GetPpapiHost(), instance, resource),
+ renderer_ppapi_host_(host),
file_(base::kInvalidPlatformFileValue),
file_system_type_(PP_FILESYSTEMTYPE_INVALID),
quota_policy_(quota::kQuotaLimitTypeUnknown),
@@ -521,16 +523,13 @@ int32_t PepperFileIOHost::OnHostMsgRequestOSFileHandle(
quota_policy_ != quota::kQuotaLimitTypeUnlimited)
return PP_ERROR_FAILED;
- RendererPpapiHost* renderer_ppapi_host =
- RendererPpapiHost::GetForPPInstance(pp_instance());
-
// Whitelist to make it privately accessible.
if (!GetContentClient()->renderer()->IsPluginAllowedToCallRequestOSFileHandle(
- renderer_ppapi_host->GetContainerForInstance(pp_instance())))
+ renderer_ppapi_host_->GetContainerForInstance(pp_instance())))
return PP_ERROR_NOACCESS;
IPC::PlatformFileForTransit file =
- renderer_ppapi_host->ShareHandleWithRemote(file_, false);
+ renderer_ppapi_host_->ShareHandleWithRemote(file_, false);
if (file == IPC::InvalidPlatformFileForTransit())
return PP_ERROR_FAILED;
ppapi::host::ReplyMessageContext reply_context =
@@ -583,11 +582,26 @@ void PepperFileIOHost::ExecutePlatformOpenFileCallback(
file_ = file.ReleaseValue();
DCHECK(!quota_file_io_.get());
- if (file_ != base::kInvalidPlatformFileValue &&
- (file_system_type_ == PP_FILESYSTEMTYPE_LOCALTEMPORARY ||
- file_system_type_ == PP_FILESYSTEMTYPE_LOCALPERSISTENT)) {
- quota_file_io_.reset(new QuotaFileIO(
- new QuotaFileIODelegate, file_, file_system_url_, file_system_type_));
+ if (file_ != base::kInvalidPlatformFileValue) {
+ if (file_system_type_ == PP_FILESYSTEMTYPE_LOCALTEMPORARY ||
+ file_system_type_ == PP_FILESYSTEMTYPE_LOCALPERSISTENT) {
+ quota_file_io_.reset(new QuotaFileIO(
+ new QuotaFileIODelegate, file_, file_system_url_, file_system_type_));
+ }
+
+ IPC::PlatformFileForTransit file_for_transit =
+ renderer_ppapi_host_->ShareHandleWithRemote(file_, false);
+ if (!(file_for_transit == IPC::InvalidPlatformFileForTransit())) {
+ // Send the file descriptor to the plugin process. This is used in the
+ // plugin for any file operations that can be done there.
+ // IMPORTANT: Clear PP_FILEOPENFLAG_WRITE and PP_FILEOPENFLAG_APPEND so
+ // the plugin can't write and so bypass our quota checks.
+ int32_t no_write_flags =
+ open_flags_ & ~(PP_FILEOPENFLAG_WRITE | PP_FILEOPENFLAG_APPEND);
+ ppapi::proxy::SerializedHandle file_handle;
+ file_handle.set_file_handle(file_for_transit, no_write_flags);
+ reply_context.params.AppendHandle(file_handle);
+ }
}
reply_context.params.set_result(pp_error);

Powered by Google App Engine
This is Rietveld 408576698