Chromium Code Reviews| 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..8d536673e83b5e15e6f1d7e0278e3ddd5f597ac7 100644 |
| --- a/content/renderer/pepper/pepper_file_io_host.cc |
| +++ b/content/renderer/pepper/pepper_file_io_host.cc |
| @@ -17,10 +17,12 @@ |
| #include "content/public/common/content_client.h" |
| #include "content/public/renderer/content_renderer_client.h" |
| #include "content/renderer/pepper/host_globals.h" |
| +#include "content/renderer/pepper/pepper_browser_connection.h" |
| #include "content/renderer/pepper/pepper_helper_impl.h" |
| #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
| -#include "content/renderer/pepper/ppb_file_ref_impl.h" |
| +#include "content/renderer/pepper/plugin_module.h" |
| #include "content/renderer/pepper/quota_file_io.h" |
| +#include "content/renderer/pepper/renderer_ppapi_host_impl.h" |
| #include "content/renderer/render_thread_impl.h" |
| #include "ppapi/c/pp_errors.h" |
| #include "ppapi/host/dispatch_host_message.h" |
| @@ -37,7 +39,6 @@ using ppapi::FileIOStateManager; |
| using ppapi::PPTimeToTime; |
| using ppapi::host::ReplyMessageContext; |
| using ppapi::thunk::EnterResourceNoLock; |
| -using ppapi::thunk::PPB_FileRef_API; |
| namespace { |
| @@ -151,6 +152,7 @@ PepperFileIOHost::PepperFileIOHost(RendererPpapiHost* host, |
| weak_factory_(this), |
| routing_id_(RenderThreadImpl::current()->GenerateRoutingID()) { |
| ChildThread::current()->AddRoute(routing_id_, this); |
| + plugin_instance_ = HostGlobals::Get()->GetInstance(instance); |
|
dmichael (off chromium)
2013/08/07 22:19:13
nit: Why not do this in the initializer list?
teravest
2013/08/08 00:50:06
Done.
|
| } |
| PepperFileIOHost::~PepperFileIOHost() { |
| @@ -239,46 +241,59 @@ int32_t PepperFileIOHost::OnHostMsgOpen( |
| return PP_ERROR_BADARGUMENT; |
| } |
| - EnterResourceNoLock<PPB_FileRef_API> enter(file_ref_resource, true); |
| - if (enter.failed()) |
| - return PP_ERROR_BADRESOURCE; |
| + RendererPpapiHostImpl* host_impl = |
| + plugin_instance_->module()->renderer_ppapi_host(); |
| + RenderView* render_view = host_impl->GetRenderViewForInstance(pp_instance()); |
| + PepperBrowserConnection* browser_connection = |
| + PepperBrowserConnection::Get(render_view); |
| + int child_process_id = plugin_instance_->module()->GetPluginChildId(); |
| + |
| + std::vector<PP_Resource> resources; |
| + resources.push_back(file_ref_resource); |
| + browser_connection->SendBrowserFileRefGetInfo( |
| + child_process_id, |
| + resources, |
| + base::Bind(&PepperFileIOHost::DidGetFileRefInfo, |
| + weak_factory_.GetWeakPtr(), |
| + context->MakeReplyMessageContext(), |
| + platform_file_flags)); |
| + state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_EXCLUSIVE); |
| + return PP_OK_COMPLETIONPENDING; |
| +} |
| - PPB_FileRef_API* file_ref_api = enter.object(); |
| - PP_FileSystemType type = file_ref_api->GetFileSystemType(); |
| - if (type != PP_FILESYSTEMTYPE_LOCALPERSISTENT && |
| - type != PP_FILESYSTEMTYPE_LOCALTEMPORARY && |
| - type != PP_FILESYSTEMTYPE_EXTERNAL && |
| - type != PP_FILESYSTEMTYPE_ISOLATED) |
| - return PP_ERROR_FAILED; |
| - file_system_type_ = type; |
| +void PepperFileIOHost::DidGetFileRefInfo( |
| + ppapi::host::ReplyMessageContext reply_context, |
| + int platform_file_flags, |
| + const std::vector<ppapi::FileRef_DetailedInfo>& infos) { |
| + if (infos.size() == 0) |
| + return; |
| + // TODO: Confirm resources match. |
| - PPB_FileRef_Impl* file_ref = static_cast<PPB_FileRef_Impl*>(file_ref_api); |
| - if (file_ref->HasValidFileSystem()) { |
| - file_system_url_ = file_ref->GetFileSystemURL(); |
| + PP_FileSystemType type = infos[0].file_system_type; |
| + file_system_type_ = type; |
| + if (type != PP_FILESYSTEMTYPE_EXTERNAL) { |
| + const std::string& file_system_url_spec = infos[0].file_system_url_spec; |
| + file_system_url_ = GURL(file_system_url_spec); |
| FileSystemDispatcher* file_system_dispatcher = |
| ChildThread::current()->file_system_dispatcher(); |
| + |
| AsyncOpenFileSystemURLCallback callback = base::Bind( |
| &PepperFileIOHost::ExecutePlatformOpenFileSystemURLCallback, |
| weak_factory_.GetWeakPtr(), |
| - context->MakeReplyMessageContext()); |
| + reply_context); |
| file_system_dispatcher->OpenFile( |
| file_system_url_, platform_file_flags, |
| base::Bind(&DidOpenFileSystemURL, callback), |
| base::Bind(&DidFailOpenFileSystemURL, callback)); |
| } else { |
| - if (file_system_type_ != PP_FILESYSTEMTYPE_EXTERNAL) |
| - return PP_ERROR_FAILED; |
| int message_id = pending_async_open_files_.Add(new AsyncOpenFileCallback( |
| base::Bind(&PepperFileIOHost::ExecutePlatformOpenFileCallback, |
| weak_factory_.GetWeakPtr(), |
| - context->MakeReplyMessageContext()))); |
| + reply_context))); |
| RenderThreadImpl::current()->Send(new ViewHostMsg_AsyncOpenPepperFile( |
| - routing_id_, file_ref->GetSystemPath(), open_flags, message_id)); |
| + routing_id_, infos[0].external_path, open_flags_, message_id)); |
| } |
| - |
| - state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_EXCLUSIVE); |
| - return PP_OK_COMPLETIONPENDING; |
| } |
| int32_t PepperFileIOHost::OnHostMsgQuery( |