summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authorbbudge@chromium.org <bbudge@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-19 04:16:36 +0000
committerbbudge@chromium.org <bbudge@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-19 04:16:36 +0000
commitc77144727785be9a25c10a7954e38a3a579b417a (patch)
tree5fe5083e10e8af5ec822848a07cb04b416682496 /ppapi
parent7a6acd091023b662745562592406b5efbc1a5b42 (diff)
downloadchromium_src-c77144727785be9a25c10a7954e38a3a579b417a.zip
chromium_src-c77144727785be9a25c10a7954e38a3a579b417a.tar.gz
chromium_src-c77144727785be9a25c10a7954e38a3a579b417a.tar.bz2
Refactor FileIO to the new resource host system.
Taking over from Victor's CL: https://codereview.chromium.org/11419131/ Re-landing, with a fix. The original waited to reset the file state until after the callback had completed. This is too late, as the client should be able to perform another file operation during the callback. Changeset #1 is the original patch. The fix is in change set #2 Original author=Victor Hsieh BUG=none TEST=browser_tests --gtest_filter=PPAPINaClNewlibTest.FileIO* Review URL: https://chromiumcodereview.appspot.com/11941022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@177830 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/ppapi_proxy.gypi4
-rw-r--r--ppapi/ppapi_shared.gypi4
-rw-r--r--ppapi/proxy/file_io_resource.cc291
-rw-r--r--ppapi/proxy/file_io_resource.h95
-rw-r--r--ppapi/proxy/interface_list.cc1
-rw-r--r--ppapi/proxy/ppapi_messages.h85
-rw-r--r--ppapi/proxy/ppb_file_io_proxy.cc457
-rw-r--r--ppapi/proxy/ppb_file_io_proxy.h93
-rw-r--r--ppapi/proxy/resource_creation_proxy.cc4
-rw-r--r--ppapi/shared_impl/file_io_state_manager.cc56
-rw-r--r--ppapi/shared_impl/file_io_state_manager.h69
-rw-r--r--ppapi/shared_impl/ppb_file_io_shared.cc244
-rw-r--r--ppapi/shared_impl/ppb_file_io_shared.h159
-rw-r--r--ppapi/thunk/interfaces_ppb_private.h5
-rw-r--r--ppapi/thunk/interfaces_ppb_public_stable.h5
15 files changed, 553 insertions, 1019 deletions
diff --git a/ppapi/ppapi_proxy.gypi b/ppapi/ppapi_proxy.gypi
index ef4e834b..552dcf3 100644
--- a/ppapi/ppapi_proxy.gypi
+++ b/ppapi/ppapi_proxy.gypi
@@ -53,6 +53,8 @@
'proxy/flash_menu_resource.h',
'proxy/flash_resource.cc',
'proxy/flash_resource.h',
+ 'proxy/file_io_resource.cc',
+ 'proxy/file_io_resource.h',
'proxy/gamepad_resource.cc',
'proxy/gamepad_resource.h',
'proxy/host_dispatcher.cc',
@@ -91,8 +93,6 @@
'proxy/ppb_buffer_proxy.h',
'proxy/ppb_core_proxy.cc',
'proxy/ppb_core_proxy.h',
- 'proxy/ppb_file_io_proxy.cc',
- 'proxy/ppb_file_io_proxy.h',
'proxy/ppb_file_ref_proxy.cc',
'proxy/ppb_file_ref_proxy.h',
'proxy/ppb_file_system_proxy.cc',
diff --git a/ppapi/ppapi_shared.gypi b/ppapi/ppapi_shared.gypi
index ad03525..12f0e87 100644
--- a/ppapi/ppapi_shared.gypi
+++ b/ppapi/ppapi_shared.gypi
@@ -24,6 +24,8 @@
'shared_impl/array_writer.h',
'shared_impl/callback_tracker.cc',
'shared_impl/callback_tracker.h',
+ 'shared_impl/file_io_state_manager.cc',
+ 'shared_impl/file_io_state_manager.h',
'shared_impl/file_path.cc',
'shared_impl/file_path.h',
'shared_impl/file_type_conversion.cc',
@@ -51,8 +53,6 @@
'shared_impl/ppb_crypto_shared.cc',
'shared_impl/ppb_device_ref_shared.cc',
'shared_impl/ppb_device_ref_shared.h',
- 'shared_impl/ppb_file_io_shared.cc',
- 'shared_impl/ppb_file_io_shared.h',
'shared_impl/ppb_file_ref_shared.cc',
'shared_impl/ppb_file_ref_shared.h',
'shared_impl/ppb_gamepad_shared.cc',
diff --git a/ppapi/proxy/file_io_resource.cc b/ppapi/proxy/file_io_resource.cc
new file mode 100644
index 0000000..77105a1
--- /dev/null
+++ b/ppapi/proxy/file_io_resource.cc
@@ -0,0 +1,291 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ppapi/proxy/file_io_resource.h"
+
+#include "base/bind.h"
+#include "ipc/ipc_message.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/proxy/ppapi_messages.h"
+#include "ppapi/shared_impl/array_writer.h"
+#include "ppapi/shared_impl/ppapi_globals.h"
+#include "ppapi/shared_impl/resource_tracker.h"
+#include "ppapi/thunk/enter.h"
+#include "ppapi/thunk/ppb_file_ref_api.h"
+
+using ppapi::thunk::EnterResourceNoLock;
+using ppapi::thunk::PPB_FileIO_API;
+using ppapi::thunk::PPB_FileRef_API;
+
+namespace {
+
+// An adapter to let Read() share the same implementation with ReadToArray().
+void* DummyGetDataBuffer(void* user_data, uint32_t count, uint32_t size) {
+ return user_data;
+}
+
+} // namespace
+
+namespace ppapi {
+namespace proxy {
+
+FileIOResource::FileIOResource(Connection connection, PP_Instance instance)
+ : PluginResource(connection, instance) {
+ SendCreate(RENDERER, PpapiHostMsg_FileIO_Create());
+}
+
+FileIOResource::~FileIOResource() {
+}
+
+PPB_FileIO_API* FileIOResource::AsPPB_FileIO_API() {
+ return this;
+}
+
+int32_t FileIOResource::Open(PP_Resource file_ref,
+ int32_t open_flags,
+ scoped_refptr<TrackedCallback> callback) {
+ EnterResourceNoLock<PPB_FileRef_API> enter(file_ref, true);
+ if (enter.failed())
+ return PP_ERROR_BADRESOURCE;
+
+ int32_t rv = state_manager_.CheckOperationState(
+ FileIOStateManager::OPERATION_EXCLUSIVE, false);
+ if (rv != PP_OK)
+ return rv;
+
+ Call<PpapiPluginMsg_FileIO_OpenReply>(RENDERER,
+ PpapiHostMsg_FileIO_Open(
+ enter.resource()->host_resource().host_resource(),
+ open_flags),
+ base::Bind(&FileIOResource::OnPluginMsgOpenFileComplete, this,
+ callback));
+
+ state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_EXCLUSIVE);
+ return PP_OK_COMPLETIONPENDING;
+}
+
+int32_t FileIOResource::Query(PP_FileInfo* info,
+ scoped_refptr<TrackedCallback> callback) {
+ int32_t rv = state_manager_.CheckOperationState(
+ FileIOStateManager::OPERATION_EXCLUSIVE, true);
+ if (rv != PP_OK)
+ return rv;
+
+ Call<PpapiPluginMsg_FileIO_QueryReply>(RENDERER,
+ PpapiHostMsg_FileIO_Query(),
+ base::Bind(&FileIOResource::OnPluginMsgQueryComplete, this,
+ callback, info));
+
+ state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_EXCLUSIVE);
+ return PP_OK_COMPLETIONPENDING;
+}
+
+int32_t FileIOResource::Touch(PP_Time last_access_time,
+ PP_Time last_modified_time,
+ scoped_refptr<TrackedCallback> callback) {
+ int32_t rv = state_manager_.CheckOperationState(
+ FileIOStateManager::OPERATION_EXCLUSIVE, true);
+ if (rv != PP_OK)
+ return rv;
+
+ Call<PpapiPluginMsg_FileIO_GeneralReply>(RENDERER,
+ PpapiHostMsg_FileIO_Touch(last_access_time, last_modified_time),
+ base::Bind(&FileIOResource::OnPluginMsgGeneralComplete, this,
+ callback));
+
+ state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_EXCLUSIVE);
+ return PP_OK_COMPLETIONPENDING;
+}
+
+int32_t FileIOResource::Read(int64_t offset,
+ char* buffer,
+ int32_t bytes_to_read,
+ scoped_refptr<TrackedCallback> callback) {
+ int32_t rv = state_manager_.CheckOperationState(
+ FileIOStateManager::OPERATION_READ, true);
+ if (rv != PP_OK)
+ return rv;
+
+ PP_ArrayOutput output_adapter;
+ output_adapter.GetDataBuffer = &DummyGetDataBuffer;
+ output_adapter.user_data = buffer;
+ state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_READ);
+ return ReadValidated(offset, bytes_to_read, output_adapter, callback);
+}
+
+int32_t FileIOResource::ReadToArray(int64_t offset,
+ int32_t max_read_length,
+ PP_ArrayOutput* array_output,
+ scoped_refptr<TrackedCallback> callback) {
+ DCHECK(array_output);
+ int32_t rv = state_manager_.CheckOperationState(
+ FileIOStateManager::OPERATION_READ, true);
+ if (rv != PP_OK)
+ return rv;
+
+ state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_READ);
+ return ReadValidated(offset, max_read_length, *array_output, callback);
+}
+
+int32_t FileIOResource::Write(int64_t offset,
+ const char* buffer,
+ int32_t bytes_to_write,
+ scoped_refptr<TrackedCallback> callback) {
+ int32_t rv = state_manager_.CheckOperationState(
+ FileIOStateManager::OPERATION_WRITE, true);
+ if (rv != PP_OK)
+ return rv;
+
+ // TODO(brettw) it would be nice to use a shared memory buffer for large
+ // writes rather than having to copy to a string (which will involve a number
+ // of extra copies to serialize over IPC).
+ Call<PpapiPluginMsg_FileIO_GeneralReply>(RENDERER,
+ PpapiHostMsg_FileIO_Write(offset, std::string(buffer, bytes_to_write)),
+ base::Bind(&FileIOResource::OnPluginMsgGeneralComplete, this,
+ callback));
+
+ state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_WRITE);
+ return PP_OK_COMPLETIONPENDING;
+}
+
+int32_t FileIOResource::SetLength(int64_t length,
+ scoped_refptr<TrackedCallback> callback) {
+ int32_t rv = state_manager_.CheckOperationState(
+ FileIOStateManager::OPERATION_EXCLUSIVE, true);
+ if (rv != PP_OK)
+ return rv;
+
+ Call<PpapiPluginMsg_FileIO_GeneralReply>(RENDERER,
+ PpapiHostMsg_FileIO_SetLength(length),
+ base::Bind(&FileIOResource::OnPluginMsgGeneralComplete, this,
+ callback));
+
+ state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_EXCLUSIVE);
+ return PP_OK_COMPLETIONPENDING;
+}
+
+int32_t FileIOResource::Flush(scoped_refptr<TrackedCallback> callback) {
+ int32_t rv = state_manager_.CheckOperationState(
+ FileIOStateManager::OPERATION_EXCLUSIVE, true);
+ if (rv != PP_OK)
+ return rv;
+
+ Call<PpapiPluginMsg_FileIO_GeneralReply>(RENDERER,
+ PpapiHostMsg_FileIO_Flush(),
+ base::Bind(&FileIOResource::OnPluginMsgGeneralComplete, this,
+ callback));
+
+ state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_EXCLUSIVE);
+ return PP_OK_COMPLETIONPENDING;
+}
+
+void FileIOResource::Close() {
+ Post(RENDERER, PpapiHostMsg_FileIO_Close());
+}
+
+int32_t FileIOResource::GetOSFileDescriptor() {
+ int32_t file_descriptor;
+ // Only available when running in process.
+ SyncCall<PpapiPluginMsg_FileIO_GetOSFileDescriptorReply>(
+ RENDERER, PpapiHostMsg_FileIO_GetOSFileDescriptor(), &file_descriptor);
+ return file_descriptor;
+}
+
+int32_t FileIOResource::WillWrite(int64_t offset,
+ int32_t bytes_to_write,
+ scoped_refptr<TrackedCallback> callback) {
+ Call<PpapiPluginMsg_FileIO_GeneralReply>(RENDERER,
+ PpapiHostMsg_FileIO_WillWrite(offset, bytes_to_write),
+ base::Bind(&FileIOResource::OnPluginMsgGeneralComplete, this,
+ callback));
+ state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_EXCLUSIVE);
+ return PP_OK_COMPLETIONPENDING;
+}
+
+int32_t FileIOResource::WillSetLength(int64_t length,
+ scoped_refptr<TrackedCallback> callback) {
+ Call<PpapiPluginMsg_FileIO_GeneralReply>(RENDERER,
+ PpapiHostMsg_FileIO_WillSetLength(length),
+ base::Bind(&FileIOResource::OnPluginMsgGeneralComplete, this,
+ callback));
+ state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_EXCLUSIVE);
+ return PP_OK_COMPLETIONPENDING;
+}
+
+int32_t FileIOResource::ReadValidated(int64_t offset,
+ int32_t bytes_to_read,
+ const PP_ArrayOutput& array_output,
+ scoped_refptr<TrackedCallback> callback) {
+ Call<PpapiPluginMsg_FileIO_ReadReply>(RENDERER,
+ PpapiHostMsg_FileIO_Read(offset, bytes_to_read),
+ base::Bind(&FileIOResource::OnPluginMsgReadComplete, this,
+ callback, array_output));
+ return PP_OK_COMPLETIONPENDING;
+}
+
+void FileIOResource::OnPluginMsgGeneralComplete(
+ scoped_refptr<TrackedCallback> callback,
+ const ResourceMessageReplyParams& params) {
+ DCHECK(state_manager_.get_pending_operation() ==
+ FileIOStateManager::OPERATION_EXCLUSIVE ||
+ state_manager_.get_pending_operation() ==
+ FileIOStateManager::OPERATION_WRITE);
+ // End the operation now. The callback may perform another file operation.
+ state_manager_.SetOperationFinished();
+ callback->Run(params.result());
+}
+
+void FileIOResource::OnPluginMsgOpenFileComplete(
+ scoped_refptr<TrackedCallback> callback,
+ const ResourceMessageReplyParams& params) {
+ DCHECK(state_manager_.get_pending_operation() ==
+ FileIOStateManager::OPERATION_EXCLUSIVE);
+ if (params.result() == PP_OK)
+ state_manager_.SetOpenSucceed();
+ // End the operation now. The callback may perform another file operation.
+ state_manager_.SetOperationFinished();
+ callback->Run(params.result());
+}
+
+void FileIOResource::OnPluginMsgQueryComplete(
+ scoped_refptr<TrackedCallback> callback,
+ PP_FileInfo* output_info,
+ const ResourceMessageReplyParams& params,
+ const PP_FileInfo& info) {
+ DCHECK(state_manager_.get_pending_operation() ==
+ FileIOStateManager::OPERATION_EXCLUSIVE);
+ *output_info = info;
+ // End the operation now. The callback may perform another file operation.
+ state_manager_.SetOperationFinished();
+ callback->Run(params.result());
+}
+
+void FileIOResource::OnPluginMsgReadComplete(
+ scoped_refptr<TrackedCallback> callback,
+ PP_ArrayOutput array_output,
+ const ResourceMessageReplyParams& params,
+ const std::string& data) {
+ DCHECK(state_manager_.get_pending_operation() ==
+ FileIOStateManager::OPERATION_READ);
+
+ // The result code should contain the data size if it's positive.
+ int32_t result = params.result();
+ DCHECK((result < 0 && data.size() == 0) ||
+ result == static_cast<int32_t>(data.size()));
+
+ ArrayWriter output;
+ output.set_pp_array_output(array_output);
+ if (output.is_valid())
+ output.StoreArray(data.data(), std::max(0, result));
+ else
+ result = PP_ERROR_FAILED;
+
+ // End the operation now. The callback may perform another file operation.
+ state_manager_.SetOperationFinished();
+ callback->Run(result);
+}
+
+} // namespace proxy
+} // namespace ppapi
+
diff --git a/ppapi/proxy/file_io_resource.h b/ppapi/proxy/file_io_resource.h
new file mode 100644
index 0000000..f5a1aa8
--- /dev/null
+++ b/ppapi/proxy/file_io_resource.h
@@ -0,0 +1,95 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef PPAPI_PROXY_FILE_IO_RESOURCE_H_
+#define PPAPI_PROXY_FILE_IO_RESOURCE_H_
+
+#include <string>
+
+#include "ppapi/proxy/connection.h"
+#include "ppapi/proxy/plugin_resource.h"
+#include "ppapi/proxy/ppapi_proxy_export.h"
+#include "ppapi/shared_impl/file_io_state_manager.h"
+#include "ppapi/thunk/ppb_file_io_api.h"
+
+namespace ppapi {
+
+class TrackedCallback;
+
+namespace proxy {
+
+class PPAPI_PROXY_EXPORT FileIOResource
+ : public PluginResource,
+ public thunk::PPB_FileIO_API {
+ public:
+ FileIOResource(Connection connection, PP_Instance instance);
+ virtual ~FileIOResource();
+
+ // Resource overrides.
+ virtual thunk::PPB_FileIO_API* AsPPB_FileIO_API() OVERRIDE;
+
+ // PPB_FileIO_API implementation.
+ virtual int32_t Open(PP_Resource file_ref,
+ int32_t open_flags,
+ scoped_refptr<TrackedCallback> callback) OVERRIDE;
+ virtual int32_t Query(PP_FileInfo* info,
+ scoped_refptr<TrackedCallback> callback) OVERRIDE;
+ virtual int32_t Touch(PP_Time last_access_time,
+ PP_Time last_modified_time,
+ scoped_refptr<TrackedCallback> callback) OVERRIDE;
+ virtual int32_t Read(int64_t offset,
+ char* buffer,
+ int32_t bytes_to_read,
+ scoped_refptr<TrackedCallback> callback) OVERRIDE;
+ virtual int32_t ReadToArray(int64_t offset,
+ int32_t max_read_length,
+ PP_ArrayOutput* array_output,
+ scoped_refptr<TrackedCallback> callback) OVERRIDE;
+ virtual int32_t Write(int64_t offset,
+ const char* buffer,
+ int32_t bytes_to_write,
+ scoped_refptr<TrackedCallback> callback) OVERRIDE;
+ virtual int32_t SetLength(int64_t length,
+ scoped_refptr<TrackedCallback> callback) OVERRIDE;
+ virtual int32_t Flush(scoped_refptr<TrackedCallback> callback) OVERRIDE;
+ virtual void Close() OVERRIDE;
+ virtual int32_t GetOSFileDescriptor() OVERRIDE;
+ virtual int32_t WillWrite(int64_t offset,
+ int32_t bytes_to_write,
+ scoped_refptr<TrackedCallback> callback) OVERRIDE;
+ virtual int32_t WillSetLength(
+ int64_t length,
+ scoped_refptr<TrackedCallback> callback) OVERRIDE;
+
+ private:
+ int32_t ReadValidated(int64_t offset,
+ int32_t bytes_to_read,
+ const PP_ArrayOutput& array_output,
+ scoped_refptr<TrackedCallback> callback);
+
+ // Handlers of reply messages. Note that all of them have a callback
+ // parameters bound when call to the host.
+ void OnPluginMsgGeneralComplete(scoped_refptr<TrackedCallback> callback,
+ const ResourceMessageReplyParams& params);
+ void OnPluginMsgOpenFileComplete(scoped_refptr<TrackedCallback> callback,
+ const ResourceMessageReplyParams& params);
+ void OnPluginMsgQueryComplete(scoped_refptr<TrackedCallback> callback,
+ PP_FileInfo* output_info_,
+ const ResourceMessageReplyParams& params,
+ const PP_FileInfo& info);
+ void OnPluginMsgReadComplete(scoped_refptr<TrackedCallback> callback,
+ PP_ArrayOutput array_output,
+ const ResourceMessageReplyParams& params,
+ const std::string& data);
+
+ FileIOStateManager state_manager_;
+
+ DISALLOW_COPY_AND_ASSIGN(FileIOResource);
+};
+
+} // namespace proxy
+} // namespace ppapi
+
+#endif // PPAPI_PROXY_FILE_IO_RESOURCE_H_
+
diff --git a/ppapi/proxy/interface_list.cc b/ppapi/proxy/interface_list.cc
index 51fe853..1cb27d1 100644
--- a/ppapi/proxy/interface_list.cc
+++ b/ppapi/proxy/interface_list.cc
@@ -81,7 +81,6 @@
#include "ppapi/proxy/ppb_broker_proxy.h"
#include "ppapi/proxy/ppb_buffer_proxy.h"
#include "ppapi/proxy/ppb_core_proxy.h"
-#include "ppapi/proxy/ppb_file_io_proxy.h"
#include "ppapi/proxy/ppb_file_ref_proxy.h"
#include "ppapi/proxy/ppb_file_system_proxy.h"
#include "ppapi/proxy/ppb_flash_message_loop_proxy.h"
diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h
index e893053..b4666e4 100644
--- a/ppapi/proxy/ppapi_messages.h
+++ b/ppapi/proxy/ppapi_messages.h
@@ -430,22 +430,6 @@ IPC_MESSAGE_ROUTED4(PpapiMsg_PPBAudio_NotifyAudioStreamCreated,
ppapi::proxy::SerializedHandle /* socket_handle */,
ppapi::proxy::SerializedHandle /* handle */)
-// PPB_FileIO.
-IPC_MESSAGE_ROUTED2(PpapiMsg_PPBFileIO_GeneralComplete,
- ppapi::HostResource /* file_io */,
- int32_t /* result */)
-IPC_MESSAGE_ROUTED2(PpapiMsg_PPBFileIO_OpenFileComplete,
- ppapi::HostResource /* file_io */,
- int32_t /* result */)
-IPC_MESSAGE_ROUTED3(PpapiMsg_PPBFileIO_QueryComplete,
- ppapi::HostResource /* file_io */,
- int32_t /* result */,
- PP_FileInfo /* info */)
-IPC_MESSAGE_ROUTED3(PpapiMsg_PPBFileIO_ReadComplete,
- ppapi::HostResource /* file_io */,
- int32_t /* result */,
- std::string /* data */)
-
// PPB_FileRef.
IPC_MESSAGE_ROUTED3(
PpapiMsg_PPBFileRef_CallbackComplete,
@@ -804,43 +788,6 @@ IPC_MESSAGE_ROUTED1(PpapiHostMsg_PPBCore_AddRefResource,
IPC_MESSAGE_ROUTED1(PpapiHostMsg_PPBCore_ReleaseResource,
ppapi::HostResource)
-// PPB_FileIO.
-IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBFileIO_Create,
- PP_Instance /* instance */,
- ppapi::HostResource /* result */)
-IPC_MESSAGE_ROUTED3(PpapiHostMsg_PPBFileIO_Open,
- ppapi::HostResource /* host_resource */,
- ppapi::HostResource /* file_ref_resource */,
- int32_t /* open_flags */)
-IPC_MESSAGE_ROUTED1(PpapiHostMsg_PPBFileIO_Close,
- ppapi::HostResource /* host_resource */)
-IPC_MESSAGE_ROUTED1(PpapiHostMsg_PPBFileIO_Query,
- ppapi::HostResource /* host_resource */)
-IPC_MESSAGE_ROUTED3(PpapiHostMsg_PPBFileIO_Touch,
- ppapi::HostResource /* host_resource */,
- PP_Time /* last_access_time */,
- PP_Time /* last_modified_time */)
-IPC_MESSAGE_ROUTED3(PpapiHostMsg_PPBFileIO_Read,
- ppapi::HostResource /* host_resource */,
- int64_t /* offset */,
- int32_t /* bytes_to_read */)
-IPC_MESSAGE_ROUTED3(PpapiHostMsg_PPBFileIO_Write,
- ppapi::HostResource /* host_resource */,
- int64_t /* offset */,
- std::string /* data */)
-IPC_MESSAGE_ROUTED2(PpapiHostMsg_PPBFileIO_SetLength,
- ppapi::HostResource /* host_resource */,
- int64_t /* length */)
-IPC_MESSAGE_ROUTED1(PpapiHostMsg_PPBFileIO_Flush,
- ppapi::HostResource /* host_resource */)
-IPC_MESSAGE_ROUTED3(PpapiHostMsg_PPBFileIO_WillWrite,
- ppapi::HostResource /* host_resource */,
- int64_t /* offset */,
- int32_t /* bytes_to_write */)
-IPC_MESSAGE_ROUTED2(PpapiHostMsg_PPBFileIO_WillSetLength,
- ppapi::HostResource /* host_resource */,
- int64_t /* length */)
-
// PPB_FileRef.
IPC_SYNC_MESSAGE_ROUTED2_1(PpapiHostMsg_PPBFileRef_Create,
ppapi::HostResource /* file_system */,
@@ -1400,6 +1347,38 @@ IPC_MESSAGE_CONTROL4(PpapiHostMsg_FileChooser_Show,
IPC_MESSAGE_CONTROL1(PpapiPluginMsg_FileChooser_ShowReply,
std::vector<ppapi::PPB_FileRef_CreateInfo> /* files */)
+// FileIO
+IPC_MESSAGE_CONTROL0(PpapiHostMsg_FileIO_Create)
+IPC_MESSAGE_CONTROL2(PpapiHostMsg_FileIO_Open,
+ PP_Resource /* file_ref_resource */,
+ int32_t /* open_flags */)
+IPC_MESSAGE_CONTROL0(PpapiPluginMsg_FileIO_OpenReply)
+IPC_MESSAGE_CONTROL0(PpapiHostMsg_FileIO_Close)
+IPC_MESSAGE_CONTROL0(PpapiHostMsg_FileIO_Query)
+IPC_MESSAGE_CONTROL1(PpapiPluginMsg_FileIO_QueryReply, PP_FileInfo /* info */)
+IPC_MESSAGE_CONTROL2(PpapiHostMsg_FileIO_Touch,
+ PP_Time /* last_access_time */,
+ PP_Time /* last_modified_time */)
+IPC_MESSAGE_CONTROL2(PpapiHostMsg_FileIO_Read,
+ int64_t /* offset */,
+ int32_t /* bytes_to_read */)
+IPC_MESSAGE_CONTROL1(PpapiPluginMsg_FileIO_ReadReply, std::string /* data */)
+IPC_MESSAGE_CONTROL2(PpapiHostMsg_FileIO_Write,
+ int64_t /* offset */,
+ std::string /* data */)
+IPC_MESSAGE_CONTROL1(PpapiHostMsg_FileIO_SetLength,
+ int64_t /* length */)
+IPC_MESSAGE_CONTROL0(PpapiHostMsg_FileIO_Flush)
+IPC_MESSAGE_CONTROL2(PpapiHostMsg_FileIO_WillWrite,
+ int64_t /* offset */,
+ int32_t /* bytes_to_write */)
+IPC_MESSAGE_CONTROL1(PpapiHostMsg_FileIO_WillSetLength,
+ int64_t /* length */)
+IPC_MESSAGE_CONTROL0(PpapiHostMsg_FileIO_GetOSFileDescriptor)
+IPC_MESSAGE_CONTROL1(PpapiPluginMsg_FileIO_GetOSFileDescriptorReply,
+ int32_t /* file descriptor */)
+IPC_MESSAGE_CONTROL0(PpapiPluginMsg_FileIO_GeneralReply)
+
// Flash device ID.
IPC_MESSAGE_CONTROL0(PpapiHostMsg_FlashDeviceID_Create)
IPC_MESSAGE_CONTROL0(PpapiHostMsg_FlashDeviceID_GetDeviceID)
diff --git a/ppapi/proxy/ppb_file_io_proxy.cc b/ppapi/proxy/ppb_file_io_proxy.cc
deleted file mode 100644
index 002efdf..0000000
--- a/ppapi/proxy/ppb_file_io_proxy.cc
+++ /dev/null
@@ -1,457 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ppapi/proxy/ppb_file_io_proxy.h"
-
-#include "ppapi/c/pp_errors.h"
-#include "ppapi/proxy/enter_proxy.h"
-#include "ppapi/proxy/ppapi_messages.h"
-#include "ppapi/proxy/ppb_file_ref_proxy.h"
-#include "ppapi/shared_impl/ppapi_globals.h"
-#include "ppapi/shared_impl/ppb_file_io_shared.h"
-#include "ppapi/shared_impl/resource.h"
-#include "ppapi/shared_impl/resource_tracker.h"
-
-using ppapi::thunk::PPB_FileIO_API;
-using ppapi::thunk::PPB_FileRef_API;
-
-namespace ppapi {
-namespace proxy {
-
-namespace {
-
-// The maximum size we'll support reading in one chunk. The renderer process
-// must allocate a buffer sized according to the request of the plugin. To
-// keep things from getting out of control, we cap the read size to this value.
-// This should generally be OK since the API specifies that it may perform a
-// partial read.
-static const int32_t kMaxReadSize = 33554432; // 32MB
-
-#if !defined(OS_NACL)
-typedef EnterHostFromHostResourceForceCallback<PPB_FileIO_API> EnterHostFileIO;
-#endif
-typedef EnterPluginFromHostResource<PPB_FileIO_API> EnterPluginFileIO;
-
-class FileIO : public PPB_FileIO_Shared {
- public:
- explicit FileIO(const HostResource& host_resource);
- virtual ~FileIO();
-
- // PPB_FileIO_API implementation (not provided by FileIOImpl).
- virtual void Close() OVERRIDE;
- virtual int32_t GetOSFileDescriptor() OVERRIDE;
- virtual int32_t WillWrite(int64_t offset,
- int32_t bytes_to_write,
- scoped_refptr<TrackedCallback> callback) OVERRIDE;
- virtual int32_t WillSetLength(
- int64_t length,
- scoped_refptr<TrackedCallback> callback) OVERRIDE;
-
- private:
- // FileIOImpl overrides.
- virtual int32_t OpenValidated(
- PP_Resource file_ref_resource,
- PPB_FileRef_API* file_ref_api,
- int32_t open_flags,
- scoped_refptr<TrackedCallback> callback) OVERRIDE;
- virtual int32_t QueryValidated(
- PP_FileInfo* info,
- scoped_refptr<TrackedCallback> callback) OVERRIDE;
- virtual int32_t TouchValidated(
- PP_Time last_access_time,
- PP_Time last_modified_time,
- scoped_refptr<TrackedCallback> callback) OVERRIDE;
- virtual int32_t ReadValidated(
- int64_t offset,
- const PP_ArrayOutput& output_array_buffer,
- int32_t max_read_length,
- scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
- virtual int32_t WriteValidated(
- int64_t offset,
- const char* buffer,
- int32_t bytes_to_write,
- scoped_refptr<TrackedCallback> callback) OVERRIDE;
- virtual int32_t SetLengthValidated(
- int64_t length,
- scoped_refptr<TrackedCallback> callback) OVERRIDE;
- virtual int32_t FlushValidated(
- scoped_refptr<TrackedCallback> callback) OVERRIDE;
-
- PluginDispatcher* GetDispatcher() const {
- return PluginDispatcher::GetForResource(this);
- }
-
- static const ApiID kApiID = API_ID_PPB_FILE_IO;
-
- DISALLOW_IMPLICIT_CONSTRUCTORS(FileIO);
-};
-
-FileIO::FileIO(const HostResource& host_resource)
- : PPB_FileIO_Shared(host_resource) {
-}
-
-FileIO::~FileIO() {
- Close();
-}
-
-void FileIO::Close() {
- if (file_open_) {
- GetDispatcher()->Send(new PpapiHostMsg_PPBFileIO_Close(kApiID,
- host_resource()));
- }
-}
-
-int32_t FileIO::GetOSFileDescriptor() {
- return -1;
-}
-
-int32_t FileIO::WillWrite(int64_t offset,
- int32_t bytes_to_write,
- scoped_refptr<TrackedCallback> callback) {
- GetDispatcher()->Send(new PpapiHostMsg_PPBFileIO_WillWrite(
- kApiID, host_resource(), offset, bytes_to_write));
- RegisterCallback(OPERATION_EXCLUSIVE, callback, NULL, NULL);
- return PP_OK_COMPLETIONPENDING;
-}
-
-int32_t FileIO::WillSetLength(int64_t length,
- scoped_refptr<TrackedCallback> callback) {
- GetDispatcher()->Send(new PpapiHostMsg_PPBFileIO_WillSetLength(
- kApiID, host_resource(), length));
- RegisterCallback(OPERATION_EXCLUSIVE, callback, NULL, NULL);
- return PP_OK_COMPLETIONPENDING;
-}
-
-int32_t FileIO::OpenValidated(PP_Resource file_ref_resource,
- PPB_FileRef_API* file_ref_api,
- int32_t open_flags,
- scoped_refptr<TrackedCallback> callback) {
- Resource* file_ref_object =
- PpapiGlobals::Get()->GetResourceTracker()->GetResource(file_ref_resource);
-
- GetDispatcher()->Send(new PpapiHostMsg_PPBFileIO_Open(
- kApiID, host_resource(), file_ref_object->host_resource(), open_flags));
- RegisterCallback(OPERATION_EXCLUSIVE, callback, NULL, NULL);
- return PP_OK_COMPLETIONPENDING;
-}
-
-int32_t FileIO::QueryValidated(PP_FileInfo* info,
- scoped_refptr<TrackedCallback> callback) {
- GetDispatcher()->Send(new PpapiHostMsg_PPBFileIO_Query(
- kApiID, host_resource()));
- RegisterCallback(OPERATION_EXCLUSIVE, callback, NULL, info);
- return PP_OK_COMPLETIONPENDING;
-}
-
-int32_t FileIO::TouchValidated(PP_Time last_access_time,
- PP_Time last_modified_time,
- scoped_refptr<TrackedCallback> callback) {
- GetDispatcher()->Send(new PpapiHostMsg_PPBFileIO_Touch(
- kApiID, host_resource(), last_access_time, last_modified_time));
- RegisterCallback(OPERATION_EXCLUSIVE, callback, NULL, NULL);
- return PP_OK_COMPLETIONPENDING;
-}
-
-int32_t FileIO::ReadValidated(int64_t offset,
- const PP_ArrayOutput& output_array_buffer,
- int32_t max_read_length,
- scoped_refptr<TrackedCallback> callback) {
- GetDispatcher()->Send(new PpapiHostMsg_PPBFileIO_Read(
- kApiID, host_resource(), offset, max_read_length));
- RegisterCallback(OPERATION_READ, callback, &output_array_buffer, NULL);
- return PP_OK_COMPLETIONPENDING;
-}
-
-int32_t FileIO::WriteValidated(int64_t offset,
- const char* buffer,
- int32_t bytes_to_write,
- scoped_refptr<TrackedCallback> callback) {
- // TODO(brettw) it would be nice to use a shared memory buffer for large
- // writes rather than having to copy to a string (which will involve a number
- // of extra copies to serialize over IPC).
- GetDispatcher()->Send(new PpapiHostMsg_PPBFileIO_Write(
- kApiID, host_resource(), offset, std::string(buffer, bytes_to_write)));
- RegisterCallback(OPERATION_WRITE, callback, NULL, NULL);
- return PP_OK_COMPLETIONPENDING;
-}
-
-int32_t FileIO::SetLengthValidated(int64_t length,
- scoped_refptr<TrackedCallback> callback) {
- GetDispatcher()->Send(new PpapiHostMsg_PPBFileIO_SetLength(
- kApiID, host_resource(), length));
- RegisterCallback(OPERATION_EXCLUSIVE, callback, NULL, NULL);
- return PP_OK_COMPLETIONPENDING;
-}
-
-int32_t FileIO::FlushValidated(scoped_refptr<TrackedCallback> callback) {
- GetDispatcher()->Send(new PpapiHostMsg_PPBFileIO_Flush(
- kApiID, host_resource()));
- RegisterCallback(OPERATION_EXCLUSIVE, callback, NULL, NULL);
- return PP_OK_COMPLETIONPENDING;
-}
-
-} // namespace
-
-// -----------------------------------------------------------------------------
-
-PPB_FileIO_Proxy::PPB_FileIO_Proxy(Dispatcher* dispatcher)
- : InterfaceProxy(dispatcher),
- callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
-}
-
-PPB_FileIO_Proxy::~PPB_FileIO_Proxy() {
-}
-
-// static
-PP_Resource PPB_FileIO_Proxy::CreateProxyResource(PP_Instance instance) {
- PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
- if (!dispatcher)
- return 0;
-
- HostResource result;
- dispatcher->Send(new PpapiHostMsg_PPBFileIO_Create(kApiID, instance,
- &result));
- if (result.is_null())
- return 0;
- return (new FileIO(result))->GetReference();
-}
-
-bool PPB_FileIO_Proxy::OnMessageReceived(const IPC::Message& msg) {
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(PPB_FileIO_Proxy, msg)
- #if !defined(OS_NACL)
- // Plugin -> host message.
- IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileIO_Create, OnHostMsgCreate)
- IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileIO_Open, OnHostMsgOpen)
- IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileIO_Close, OnHostMsgClose)
- IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileIO_Query, OnHostMsgQuery)
- IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileIO_Touch, OnHostMsgTouch)
- IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileIO_Read, OnHostMsgRead)
- IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileIO_Write, OnHostMsgWrite)
- IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileIO_SetLength, OnHostMsgSetLength)
- IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileIO_Flush, OnHostMsgFlush)
- IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileIO_WillWrite, OnHostMsgWillWrite)
- IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileIO_WillSetLength,
- OnHostMsgWillSetLength)
-#endif // !defined(OS_NACL)
- // Host -> plugin messages.
- IPC_MESSAGE_HANDLER(PpapiMsg_PPBFileIO_GeneralComplete,
- OnPluginMsgGeneralComplete)
- IPC_MESSAGE_HANDLER(PpapiMsg_PPBFileIO_OpenFileComplete,
- OnPluginMsgOpenFileComplete)
- IPC_MESSAGE_HANDLER(PpapiMsg_PPBFileIO_QueryComplete,
- OnPluginMsgQueryComplete)
- IPC_MESSAGE_HANDLER(PpapiMsg_PPBFileIO_ReadComplete,
- OnPluginMsgReadComplete)
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP()
- return handled;
-}
-
-#if !defined(OS_NACL)
-void PPB_FileIO_Proxy::OnHostMsgCreate(PP_Instance instance,
- HostResource* result) {
- thunk::EnterResourceCreation enter(instance);
- if (enter.succeeded()) {
- result->SetHostResource(instance,
- enter.functions()->CreateFileIO(instance));
- }
-}
-
-void PPB_FileIO_Proxy::OnHostMsgOpen(const HostResource& host_resource,
- const HostResource& file_ref_resource,
- int32_t open_flags) {
- EnterHostFileIO enter(host_resource, callback_factory_,
- &PPB_FileIO_Proxy::OpenFileCallbackCompleteInHost, host_resource);
- if (enter.succeeded()) {
- enter.SetResult(enter.object()->Open(
- file_ref_resource.host_resource(), open_flags, enter.callback()));
- }
-}
-
-void PPB_FileIO_Proxy::OnHostMsgClose(const HostResource& host_resource) {
- EnterHostFromHostResource<PPB_FileIO_API> enter(host_resource);
- if (enter.succeeded())
- enter.object()->Close();
-}
-
-void PPB_FileIO_Proxy::OnHostMsgQuery(const HostResource& host_resource) {
- // The callback will take charge of deleting the FileInfo. The contents must
- // be defined so we don't send garbage to the plugin in the failure case.
- PP_FileInfo* info = new PP_FileInfo;
- memset(info, 0, sizeof(PP_FileInfo));
- EnterHostFileIO enter(host_resource, callback_factory_,
- &PPB_FileIO_Proxy::QueryCallbackCompleteInHost,
- host_resource, info);
- if (enter.succeeded())
- enter.SetResult(enter.object()->Query(info, enter.callback()));
-}
-
-void PPB_FileIO_Proxy::OnHostMsgTouch(const HostResource& host_resource,
- PP_Time last_access_time,
- PP_Time last_modified_time) {
- EnterHostFileIO enter(host_resource, callback_factory_,
- &PPB_FileIO_Proxy::GeneralCallbackCompleteInHost,
- host_resource);
- if (enter.succeeded()) {
- enter.SetResult(enter.object()->Touch(last_access_time, last_modified_time,
- enter.callback()));
- }
-}
-
-void PPB_FileIO_Proxy::OnHostMsgRead(const HostResource& host_resource,
- int64_t offset,
- int32_t bytes_to_read) {
- // Validate bytes_to_read before allocating below. This value is coming from
- // the untrusted plugin.
- bytes_to_read = std::min(bytes_to_read, kMaxReadSize);
- if (bytes_to_read < 0) {
- ReadCallbackCompleteInHost(PP_ERROR_FAILED, host_resource,
- new std::string());
- return;
- }
-
- // The callback will take charge of deleting the string.
- std::string* dest = new std::string;
- dest->resize(bytes_to_read);
- EnterHostFileIO enter(host_resource, callback_factory_,
- &PPB_FileIO_Proxy::ReadCallbackCompleteInHost,
- host_resource, dest);
- if (enter.succeeded()) {
- enter.SetResult(enter.object()->Read(offset,
- bytes_to_read > 0 ? &(*dest)[0] : NULL,
- bytes_to_read, enter.callback()));
- }
-}
-
-void PPB_FileIO_Proxy::OnHostMsgWrite(const HostResource& host_resource,
- int64_t offset,
- const std::string& data) {
- EnterHostFileIO enter(host_resource, callback_factory_,
- &PPB_FileIO_Proxy::GeneralCallbackCompleteInHost,
- host_resource);
- if (enter.succeeded()) {
- enter.SetResult(enter.object()->Write(offset, data.data(), data.size(),
- enter.callback()));
- }
-}
-
-void PPB_FileIO_Proxy::OnHostMsgSetLength(const HostResource& host_resource,
- int64_t length) {
- EnterHostFileIO enter(host_resource, callback_factory_,
- &PPB_FileIO_Proxy::GeneralCallbackCompleteInHost,
- host_resource);
- if (enter.succeeded())
- enter.SetResult(enter.object()->SetLength(length, enter.callback()));
-}
-
-void PPB_FileIO_Proxy::OnHostMsgFlush(const HostResource& host_resource) {
- EnterHostFileIO enter(host_resource, callback_factory_,
- &PPB_FileIO_Proxy::GeneralCallbackCompleteInHost,
- host_resource);
- if (enter.succeeded())
- enter.SetResult(enter.object()->Flush(enter.callback()));
-}
-
-void PPB_FileIO_Proxy::OnHostMsgWillWrite(const HostResource& host_resource,
- int64_t offset,
- int32_t bytes_to_write) {
- EnterHostFileIO enter(host_resource, callback_factory_,
- &PPB_FileIO_Proxy::GeneralCallbackCompleteInHost,
- host_resource);
- if (enter.succeeded()) {
- enter.SetResult(enter.object()->WillWrite(offset, bytes_to_write,
- enter.callback()));
- }
-}
-
-void PPB_FileIO_Proxy::OnHostMsgWillSetLength(const HostResource& host_resource,
- int64_t length) {
- EnterHostFileIO enter(host_resource, callback_factory_,
- &PPB_FileIO_Proxy::GeneralCallbackCompleteInHost,
- host_resource);
- if (enter.succeeded())
- enter.SetResult(enter.object()->WillSetLength(length, enter.callback()));
-}
-#endif // !defined(OS_NACL)
-
-void PPB_FileIO_Proxy::OnPluginMsgGeneralComplete(
- const HostResource& host_resource,
- int32_t result) {
- EnterPluginFileIO enter(host_resource);
- if (enter.succeeded())
- static_cast<FileIO*>(enter.object())->ExecuteGeneralCallback(result);
-}
-
-void PPB_FileIO_Proxy::OnPluginMsgOpenFileComplete(
- const HostResource& host_resource,
- int32_t result) {
- EnterPluginFileIO enter(host_resource);
- if (enter.succeeded())
- static_cast<FileIO*>(enter.object())->ExecuteOpenFileCallback(result);
-}
-
-void PPB_FileIO_Proxy::OnPluginMsgQueryComplete(
- const HostResource& host_resource,
- int32_t result,
- const PP_FileInfo& info) {
- EnterPluginFileIO enter(host_resource);
- if (enter.succeeded())
- static_cast<FileIO*>(enter.object())->ExecuteQueryCallback(result, info);
-}
-
-void PPB_FileIO_Proxy::OnPluginMsgReadComplete(
- const HostResource& host_resource,
- int32_t result,
- const std::string& data) {
- EnterPluginFileIO enter(host_resource);
- if (enter.succeeded()) {
- // The result code should contain the data size if it's positive.
- DCHECK((result < 0 && data.size() == 0) ||
- result == static_cast<int32_t>(data.size()));
- static_cast<FileIO*>(enter.object())->ExecuteReadCallback(result,
- data.data());
- }
-}
-
-#if !defined(OS_NACL)
-void PPB_FileIO_Proxy::GeneralCallbackCompleteInHost(
- int32_t pp_error,
- const HostResource& host_resource) {
- Send(new PpapiMsg_PPBFileIO_GeneralComplete(kApiID, host_resource, pp_error));
-}
-
-void PPB_FileIO_Proxy::OpenFileCallbackCompleteInHost(
- int32_t pp_error,
- const HostResource& host_resource) {
- Send(new PpapiMsg_PPBFileIO_OpenFileComplete(kApiID, host_resource,
- pp_error));
-}
-
-void PPB_FileIO_Proxy::QueryCallbackCompleteInHost(
- int32_t pp_error,
- const HostResource& host_resource,
- PP_FileInfo* info) {
- Send(new PpapiMsg_PPBFileIO_QueryComplete(kApiID, host_resource, pp_error,
- *info));
- delete info;
-}
-
-void PPB_FileIO_Proxy::ReadCallbackCompleteInHost(
- int32_t pp_error,
- const HostResource& host_resource,
- std::string* data) {
- // Only send the amount of data in the string that was actually read.
- if (pp_error >= 0) {
- DCHECK(pp_error <= static_cast<int32_t>(data->size()));
- data->resize(pp_error);
- }
- Send(new PpapiMsg_PPBFileIO_ReadComplete(kApiID, host_resource, pp_error,
- *data));
- delete data;
-}
-#endif // !defined(OS_NACL)
-
-} // namespace proxy
-} // namespace ppapi
diff --git a/ppapi/proxy/ppb_file_io_proxy.h b/ppapi/proxy/ppb_file_io_proxy.h
deleted file mode 100644
index 10e5313..0000000
--- a/ppapi/proxy/ppb_file_io_proxy.h
+++ /dev/null
@@ -1,93 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef PPAPI_PROXY_PPB_FILE_IO_PROXY_H_
-#define PPAPI_PROXY_PPB_FILE_IO_PROXY_H_
-
-#include <string>
-
-#include "base/basictypes.h"
-#include "ppapi/c/pp_file_info.h"
-#include "ppapi/proxy/interface_proxy.h"
-#include "ppapi/proxy/proxy_completion_callback_factory.h"
-#include "ppapi/utility/completion_callback_factory.h"
-
-namespace ppapi {
-
-class HostResource;
-namespace proxy {
-
-class PPB_FileIO_Proxy : public InterfaceProxy {
- public:
- explicit PPB_FileIO_Proxy(Dispatcher* dispatcher);
- virtual ~PPB_FileIO_Proxy();
-
- static PP_Resource CreateProxyResource(PP_Instance instance);
-
- // InterfaceProxy implementation.
- virtual bool OnMessageReceived(const IPC::Message& msg);
-
- static const ApiID kApiID = API_ID_PPB_FILE_IO;
-
- private:
- // Plugin -> Host message handlers.
- void OnHostMsgCreate(PP_Instance instance, HostResource* result);
- void OnHostMsgOpen(const HostResource& host_resource,
- const HostResource& file_ref_resource,
- int32_t open_flags);
- void OnHostMsgClose(const HostResource& host_resource);
- void OnHostMsgQuery(const HostResource& host_resource);
- void OnHostMsgTouch(const HostResource& host_resource,
- PP_Time last_access_time,
- PP_Time last_modified_time);
- void OnHostMsgRead(const HostResource& host_resource,
- int64_t offset,
- int32_t bytes_to_read);
- void OnHostMsgWrite(const HostResource& host_resource,
- int64_t offset,
- const std::string& data);
- void OnHostMsgSetLength(const HostResource& host_resource,
- int64_t length);
- void OnHostMsgFlush(const HostResource& host_resource);
- void OnHostMsgWillWrite(const HostResource& host_resource,
- int64_t offset,
- int32_t bytes_to_write);
- void OnHostMsgWillSetLength(const HostResource& host_resource,
- int64_t length);
-
- // Host -> Plugin message handlers.
- void OnPluginMsgGeneralComplete(const HostResource& host_resource,
- int32_t result);
- void OnPluginMsgOpenFileComplete(const HostResource& host_resource,
- int32_t result);
- void OnPluginMsgQueryComplete(const HostResource& host_resource,
- int32_t result,
- const PP_FileInfo& info);
- void OnPluginMsgReadComplete(const HostResource& host_resource,
- int32_t result,
- const std::string& data);
- void OnPluginMsgWriteComplete(const HostResource& host_resource,
- int32_t result);
-
- // Host-side callback handlers. These convert the callbacks to an IPC message
- // to the plugin.
- void GeneralCallbackCompleteInHost(int32_t pp_error,
- const HostResource& host_resource);
- void OpenFileCallbackCompleteInHost(int32_t pp_error,
- const HostResource& host_resource);
- void QueryCallbackCompleteInHost(int32_t pp_error,
- const HostResource& host_resource,
- PP_FileInfo* info);
- void ReadCallbackCompleteInHost(int32_t pp_error,
- const HostResource& host_resource,
- std::string* data);
- ProxyCompletionCallbackFactory<PPB_FileIO_Proxy> callback_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(PPB_FileIO_Proxy);
-};
-
-} // namespace proxy
-} // namespace ppapi
-
-#endif // PPAPI_PROXY_PPB_FILE_IO_PROXY_H_
diff --git a/ppapi/proxy/resource_creation_proxy.cc b/ppapi/proxy/resource_creation_proxy.cc
index 90a23bb8..e3f1b79 100644
--- a/ppapi/proxy/resource_creation_proxy.cc
+++ b/ppapi/proxy/resource_creation_proxy.cc
@@ -11,6 +11,7 @@
#include "ppapi/proxy/browser_font_resource_trusted.h"
#include "ppapi/proxy/connection.h"
#include "ppapi/proxy/file_chooser_resource.h"
+#include "ppapi/proxy/file_io_resource.h"
#include "ppapi/proxy/flash_device_id_resource.h"
#include "ppapi/proxy/flash_font_file_resource.h"
#include "ppapi/proxy/flash_menu_resource.h"
@@ -22,7 +23,6 @@
#include "ppapi/proxy/ppb_audio_proxy.h"
#include "ppapi/proxy/ppb_broker_proxy.h"
#include "ppapi/proxy/ppb_buffer_proxy.h"
-#include "ppapi/proxy/ppb_file_io_proxy.h"
#include "ppapi/proxy/ppb_file_ref_proxy.h"
#include "ppapi/proxy/ppb_file_system_proxy.h"
#include "ppapi/proxy/ppb_flash_message_loop_proxy.h"
@@ -69,7 +69,7 @@ InterfaceProxy* ResourceCreationProxy::Create(Dispatcher* dispatcher) {
}
PP_Resource ResourceCreationProxy::CreateFileIO(PP_Instance instance) {
- return PPB_FileIO_Proxy::CreateProxyResource(instance);
+ return (new FileIOResource(GetConnection(), instance))->GetReference();
}
PP_Resource ResourceCreationProxy::CreateFileRef(PP_Resource file_system,
diff --git a/ppapi/shared_impl/file_io_state_manager.cc b/ppapi/shared_impl/file_io_state_manager.cc
new file mode 100644
index 0000000..9c9b6ea
--- /dev/null
+++ b/ppapi/shared_impl/file_io_state_manager.cc
@@ -0,0 +1,56 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ppapi/shared_impl/file_io_state_manager.h"
+
+#include "base/logging.h"
+#include "ppapi/c/pp_errors.h"
+
+namespace ppapi {
+
+FileIOStateManager::FileIOStateManager()
+ : num_pending_ops_(0),
+ pending_op_(OPERATION_NONE),
+ file_open_(false) {
+}
+
+FileIOStateManager::~FileIOStateManager() {
+}
+
+void FileIOStateManager::SetOpenSucceed() {
+ file_open_ = true;
+}
+
+int32_t FileIOStateManager::CheckOperationState(OperationType new_op,
+ bool should_be_open) {
+ if (should_be_open) {
+ if (!file_open_)
+ return PP_ERROR_FAILED;
+ } else {
+ if (file_open_)
+ return PP_ERROR_FAILED;
+ }
+
+ if (pending_op_ != OPERATION_NONE &&
+ (pending_op_ != new_op || pending_op_ == OPERATION_EXCLUSIVE))
+ return PP_ERROR_INPROGRESS;
+
+ return PP_OK;
+}
+
+void FileIOStateManager::SetPendingOperation(OperationType new_op) {
+ DCHECK(pending_op_ == OPERATION_NONE ||
+ (pending_op_ != OPERATION_EXCLUSIVE && pending_op_ == new_op));
+ pending_op_ = new_op;
+ num_pending_ops_++;
+}
+
+void FileIOStateManager::SetOperationFinished() {
+ DCHECK_GT(num_pending_ops_, 0);
+ if (--num_pending_ops_ == 0)
+ pending_op_ = OPERATION_NONE;
+}
+
+} // namespace ppapi
+
diff --git a/ppapi/shared_impl/file_io_state_manager.h b/ppapi/shared_impl/file_io_state_manager.h
new file mode 100644
index 0000000..7b5f926
--- /dev/null
+++ b/ppapi/shared_impl/file_io_state_manager.h
@@ -0,0 +1,69 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef PPAPI_SHARED_IMPL_FILE_IO_STATE_MANAGER_H_
+#define PPAPI_SHARED_IMPL_FILE_IO_STATE_MANAGER_H_
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "ppapi/c/pp_stdint.h"
+#include "ppapi/shared_impl/ppapi_shared_export.h"
+
+namespace ppapi {
+
+// FileIOStateManager is a helper class that maintains the state of operations.
+// For example, some operations are mutually exclusive, meaning that an
+// operation could be rejected because of the current pending operation. Also,
+// most of the operations only work when the file has been opened.
+class PPAPI_SHARED_EXPORT FileIOStateManager {
+ public:
+ FileIOStateManager();
+ ~FileIOStateManager();
+
+ enum OperationType {
+ // There is no pending operation right now.
+ OPERATION_NONE,
+
+ // If there are pending reads, any other kind of async operation is not
+ // allowed.
+ OPERATION_READ,
+
+ // If there are pending writes, any other kind of async operation is not
+ // allowed.
+ OPERATION_WRITE,
+
+ // If there is a pending operation that is neither read nor write, no
+ // further async operation is allowed.
+ OPERATION_EXCLUSIVE
+ };
+
+ OperationType get_pending_operation() const { return pending_op_; }
+
+ void SetOpenSucceed();
+
+ // Called at the beginning of each operation. It is responsible to make sure
+ // that state is correct. For example, some operations are only valid after
+ // the file is opened, or operations might need to run exclusively.
+ //
+ // It returns |PP_OK| on success, or |PP_ERROR_...| for various reasons.
+ int32_t CheckOperationState(OperationType new_op, bool should_be_open);
+
+ // Marks the state of current operations as started or finished.
+ void SetPendingOperation(OperationType op);
+ void SetOperationFinished();
+
+ private:
+ int num_pending_ops_;
+ OperationType pending_op_;
+
+ // Set to true when the file has been successfully opened.
+ bool file_open_;
+
+ DISALLOW_COPY_AND_ASSIGN(FileIOStateManager);
+};
+
+} // namespace ppapi
+
+#endif // PPAPI_SHARED_IMPL_FILE_IO_STATE_MANAGER_H_
+
diff --git a/ppapi/shared_impl/ppb_file_io_shared.cc b/ppapi/shared_impl/ppb_file_io_shared.cc
deleted file mode 100644
index 42a8d32..0000000
--- a/ppapi/shared_impl/ppb_file_io_shared.cc
+++ /dev/null
@@ -1,244 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ppapi/shared_impl/ppb_file_io_shared.h"
-
-#include <string.h>
-
-#include "base/bind.h"
-#include "base/logging.h"
-#include "base/message_loop.h"
-#include "ppapi/c/pp_errors.h"
-#include "ppapi/shared_impl/array_writer.h"
-#include "ppapi/shared_impl/file_type_conversion.h"
-#include "ppapi/shared_impl/time_conversion.h"
-#include "ppapi/thunk/enter.h"
-#include "ppapi/thunk/ppb_file_ref_api.h"
-
-namespace ppapi {
-
-using thunk::EnterResourceNoLock;
-using thunk::PPB_FileIO_API;
-using thunk::PPB_FileRef_API;
-
-namespace {
-
-// An adapter to let Read() share the same implementation with ReadToArray().
-void* DummyGetDataBuffer(void* user_data, uint32_t count, uint32_t size) {
- return user_data;
-}
-
-} // namespace
-
-PPB_FileIO_Shared::CallbackEntry::CallbackEntry()
- : info(NULL) {
-}
-
-PPB_FileIO_Shared::CallbackEntry::CallbackEntry(const CallbackEntry& entry)
- : callback(entry.callback),
- read_buffer(entry.read_buffer),
- info(entry.info) {
-}
-
-PPB_FileIO_Shared::CallbackEntry::~CallbackEntry() {
-}
-
-PPB_FileIO_Shared::PPB_FileIO_Shared(PP_Instance instance)
- : Resource(OBJECT_IS_IMPL, instance),
- file_system_type_(PP_FILESYSTEMTYPE_INVALID),
- file_open_(false),
- pending_op_(OPERATION_NONE) {
-}
-
-PPB_FileIO_Shared::PPB_FileIO_Shared(const HostResource& host_resource)
- : Resource(OBJECT_IS_PROXY, host_resource),
- file_system_type_(PP_FILESYSTEMTYPE_INVALID),
- file_open_(false),
- pending_op_(OPERATION_NONE) {
-}
-
-PPB_FileIO_Shared::~PPB_FileIO_Shared() {
-}
-
-thunk::PPB_FileIO_API* PPB_FileIO_Shared::AsPPB_FileIO_API() {
- return this;
-}
-
-int32_t PPB_FileIO_Shared::Open(PP_Resource file_ref,
- int32_t open_flags,
- scoped_refptr<TrackedCallback> callback) {
- EnterResourceNoLock<PPB_FileRef_API> enter(file_ref, true);
- if (enter.failed())
- return PP_ERROR_BADRESOURCE;
-
- int32_t rv = CommonCallValidation(false, OPERATION_EXCLUSIVE);
- if (rv != PP_OK)
- return rv;
-
- PP_FileSystemType type = enter.object()->GetFileSystemType();
- if (type != PP_FILESYSTEMTYPE_LOCALPERSISTENT &&
- type != PP_FILESYSTEMTYPE_LOCALTEMPORARY &&
- type != PP_FILESYSTEMTYPE_EXTERNAL)
- return PP_ERROR_FAILED;
- file_system_type_ = type;
-
- return OpenValidated(file_ref, enter.object(), open_flags, callback);
-}
-
-int32_t PPB_FileIO_Shared::Query(PP_FileInfo* info,
- scoped_refptr<TrackedCallback> callback) {
- int32_t rv = CommonCallValidation(true, OPERATION_EXCLUSIVE);
- if (rv != PP_OK)
- return rv;
- if (!info)
- return PP_ERROR_BADARGUMENT;
- return QueryValidated(info, callback);
-}
-
-int32_t PPB_FileIO_Shared::Touch(PP_Time last_access_time,
- PP_Time last_modified_time,
- scoped_refptr<TrackedCallback> callback) {
- int32_t rv = CommonCallValidation(true, OPERATION_EXCLUSIVE);
- if (rv != PP_OK)
- return rv;
- return TouchValidated(last_access_time, last_modified_time, callback);
-}
-
-int32_t PPB_FileIO_Shared::Read(int64_t offset,
- char* buffer,
- int32_t bytes_to_read,
- scoped_refptr<TrackedCallback> callback) {
- int32_t rv = CommonCallValidation(true, OPERATION_READ);
- if (rv != PP_OK)
- return rv;
- PP_ArrayOutput buffer_adapter = { &DummyGetDataBuffer, buffer };
- return ReadValidated(offset, buffer_adapter, bytes_to_read, callback);
-}
-
-int32_t PPB_FileIO_Shared::ReadToArray(
- int64_t offset,
- int32_t max_read_length,
- PP_ArrayOutput* output_array_buffer,
- scoped_refptr<TrackedCallback> callback) {
- int32_t rv = CommonCallValidation(true, OPERATION_READ);
- if (rv != PP_OK)
- return rv;
- if (!output_array_buffer)
- return PP_ERROR_BADARGUMENT;
- return ReadValidated(offset, *output_array_buffer, max_read_length, callback);
-}
-
-int32_t PPB_FileIO_Shared::Write(int64_t offset,
- const char* buffer,
- int32_t bytes_to_write,
- scoped_refptr<TrackedCallback> callback) {
- int32_t rv = CommonCallValidation(true, OPERATION_WRITE);
- if (rv != PP_OK)
- return rv;
- return WriteValidated(offset, buffer, bytes_to_write, callback);
-}
-
-int32_t PPB_FileIO_Shared::SetLength(int64_t length,
- scoped_refptr<TrackedCallback> callback) {
- int32_t rv = CommonCallValidation(true, OPERATION_EXCLUSIVE);
- if (rv != PP_OK)
- return rv;
- return SetLengthValidated(length, callback);
-}
-
-int32_t PPB_FileIO_Shared::Flush(scoped_refptr<TrackedCallback> callback) {
- int32_t rv = CommonCallValidation(true, OPERATION_EXCLUSIVE);
- if (rv != PP_OK)
- return rv;
- return FlushValidated(callback);
-}
-
-void PPB_FileIO_Shared::ExecuteGeneralCallback(int32_t pp_error) {
- RunAndRemoveFirstPendingCallback(pp_error);
-}
-
-void PPB_FileIO_Shared::ExecuteOpenFileCallback(int32_t pp_error) {
- if (pp_error == PP_OK)
- file_open_ = true;
- ExecuteGeneralCallback(pp_error);
-}
-
-void PPB_FileIO_Shared::ExecuteQueryCallback(int32_t pp_error,
- const PP_FileInfo& info) {
- if (pending_op_ != OPERATION_EXCLUSIVE || callbacks_.empty() ||
- !callbacks_.front().info) {
- NOTREACHED();
- return;
- }
- *callbacks_.front().info = info;
- RunAndRemoveFirstPendingCallback(pp_error);
-}
-
-void PPB_FileIO_Shared::ExecuteReadCallback(int32_t pp_error_or_bytes,
- const char* data) {
- if (pending_op_ != OPERATION_READ || callbacks_.empty()) {
- NOTREACHED();
- return;
- }
-
- // The result code contains the number of bytes if it's positive.
- ArrayWriter output;
- output.set_pp_array_output(callbacks_.front().read_buffer);
- if (output.is_valid()) {
- output.StoreArray(data, std::max(0, pp_error_or_bytes));
- }
-
- // Always issue the callback.
- RunAndRemoveFirstPendingCallback(pp_error_or_bytes);
-}
-
-int32_t PPB_FileIO_Shared::CommonCallValidation(bool should_be_open,
- OperationType new_op) {
- // Only asynchronous operation is supported.
- if (should_be_open) {
- if (!file_open_)
- return PP_ERROR_FAILED;
- } else {
- if (file_open_)
- return PP_ERROR_FAILED;
- }
-
- if (pending_op_ != OPERATION_NONE &&
- (pending_op_ != new_op || pending_op_ == OPERATION_EXCLUSIVE)) {
- return PP_ERROR_INPROGRESS;
- }
-
- return PP_OK;
-}
-
-void PPB_FileIO_Shared::RegisterCallback(
- OperationType op,
- scoped_refptr<TrackedCallback> callback,
- const PP_ArrayOutput* read_buffer,
- PP_FileInfo* info) {
- DCHECK(pending_op_ == OPERATION_NONE ||
- (pending_op_ != OPERATION_EXCLUSIVE && pending_op_ == op));
-
- CallbackEntry entry;
- entry.callback = callback;
- if (read_buffer)
- entry.read_buffer = *read_buffer;
- entry.info = info;
- callbacks_.push_back(entry);
-
- pending_op_ = op;
-}
-
-void PPB_FileIO_Shared::RunAndRemoveFirstPendingCallback(int32_t result) {
- DCHECK(!callbacks_.empty());
-
- CallbackEntry front = callbacks_.front();
- callbacks_.pop_front();
- if (callbacks_.empty())
- pending_op_ = OPERATION_NONE;
-
- front.callback->Run(result);
-}
-
-} // namespace ppapi
diff --git a/ppapi/shared_impl/ppb_file_io_shared.h b/ppapi/shared_impl/ppb_file_io_shared.h
deleted file mode 100644
index 2c39c8d..0000000
--- a/ppapi/shared_impl/ppb_file_io_shared.h
+++ /dev/null
@@ -1,159 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef PPAPI_SHARED_IMPL_PPB_FILE_IO_SHARED_H_
-#define PPAPI_SHARED_IMPL_PPB_FILE_IO_SHARED_H_
-
-#include <deque>
-
-#include "base/compiler_specific.h"
-#include "ppapi/shared_impl/ppapi_shared_export.h"
-#include "ppapi/shared_impl/resource.h"
-#include "ppapi/shared_impl/tracked_callback.h"
-#include "ppapi/thunk/ppb_file_io_api.h"
-
-namespace ppapi {
-
-namespace thunk {
-class PPB_FileRef_API;
-}
-
-class PPAPI_SHARED_EXPORT PPB_FileIO_Shared : public Resource,
- public thunk::PPB_FileIO_API {
- public:
- PPB_FileIO_Shared(PP_Instance instance);
- PPB_FileIO_Shared(const HostResource& host_resource);
- ~PPB_FileIO_Shared();
-
- // Resource overrides.
- virtual thunk::PPB_FileIO_API* AsPPB_FileIO_API() OVERRIDE;
-
- // PPB_FileIO_API implementation.
- virtual int32_t Open(PP_Resource file_ref,
- int32_t open_flags,
- scoped_refptr<TrackedCallback> callback) OVERRIDE;
- virtual int32_t Query(PP_FileInfo* info,
- scoped_refptr<TrackedCallback> callback) OVERRIDE;
- virtual int32_t Touch(PP_Time last_access_time,
- PP_Time last_modified_time,
- scoped_refptr<TrackedCallback> callback) OVERRIDE;
- virtual int32_t Read(int64_t offset,
- char* buffer,
- int32_t bytes_to_read,
- scoped_refptr<TrackedCallback> callback) OVERRIDE;
- virtual int32_t ReadToArray(int64_t offset,
- int32_t max_read_length,
- PP_ArrayOutput* output_array_buffer,
- scoped_refptr<TrackedCallback> callback) OVERRIDE;
- virtual int32_t Write(int64_t offset,
- const char* buffer,
- int32_t bytes_to_write,
- scoped_refptr<TrackedCallback> callback) OVERRIDE;
- virtual int32_t SetLength(int64_t length,
- scoped_refptr<TrackedCallback> callback) OVERRIDE;
- virtual int32_t Flush(scoped_refptr<TrackedCallback> callback) OVERRIDE;
-
- // Callback handler for different types of operations.
- void ExecuteGeneralCallback(int32_t pp_error);
- void ExecuteOpenFileCallback(int32_t pp_error);
- void ExecuteQueryCallback(int32_t pp_error, const PP_FileInfo& info);
- void ExecuteReadCallback(int32_t pp_error_or_bytes, const char* data);
-
- protected:
- struct CallbackEntry {
- CallbackEntry();
- CallbackEntry(const CallbackEntry& entry);
- ~CallbackEntry();
-
- scoped_refptr<TrackedCallback> callback;
-
- // Output buffer used only by |Read()|.
- PP_ArrayOutput read_buffer;
-
- // Pointer back to the caller's PP_FileInfo structure for Query operations.
- // NULL for non-query operations. Not owned.
- PP_FileInfo* info;
- };
-
- enum OperationType {
- // There is no pending operation right now.
- OPERATION_NONE,
-
- // If there are pending reads, any other kind of async operation is not
- // allowed.
- OPERATION_READ,
-
- // If there are pending writes, any other kind of async operation is not
- // allowed.
- OPERATION_WRITE,
-
- // If there is a pending operation that is neither read nor write, no
- // further async operation is allowed.
- OPERATION_EXCLUSIVE
- };
-
- // Validated versions of the FileIO API. Subclasses in the proxy and impl
- // implement these so the common error checking stays here.
- virtual int32_t OpenValidated(PP_Resource file_ref_resource,
- thunk::PPB_FileRef_API* file_ref_api,
- int32_t open_flags,
- scoped_refptr<TrackedCallback> callback) = 0;
- virtual int32_t QueryValidated(PP_FileInfo* info,
- scoped_refptr<TrackedCallback> callback) = 0;
- virtual int32_t TouchValidated(PP_Time last_access_time,
- PP_Time last_modified_time,
- scoped_refptr<TrackedCallback> callback) = 0;
- virtual int32_t ReadValidated(int64_t offset,
- const PP_ArrayOutput& buffer,
- int32_t max_read_length,
- scoped_refptr<TrackedCallback> callback) = 0;
- virtual int32_t WriteValidated(int64_t offset,
- const char* buffer,
- int32_t bytes_to_write,
- scoped_refptr<TrackedCallback> callback) = 0;
- virtual int32_t SetLengthValidated(
- int64_t length,
- scoped_refptr<TrackedCallback> callback) = 0;
- virtual int32_t FlushValidated(scoped_refptr<TrackedCallback> callback) = 0;
-
- // Called for every "Validated" function.
- //
- // This verifies that the callback is valid and that no callback is already
- // pending, or it is a read(write) request and currently the pending
- // operations are reads(writes).
- //
- // Returns |PP_OK| to indicate that everything is valid or |PP_ERROR_...| if
- // the call should be aborted and that code returned to the plugin.
- int32_t CommonCallValidation(bool should_be_open, OperationType new_op);
-
- // Sets up a pending callback. This should only be called once it is certain
- // that |PP_OK_COMPLETIONPENDING| will be returned.
- //
- // |read_buffer| is only used by read operations, |info| is used only by
- // query operations.
- void RegisterCallback(OperationType op,
- scoped_refptr<TrackedCallback> callback,
- const PP_ArrayOutput* read_buffer,
- PP_FileInfo* info);
-
- // Pops the oldest callback from the queue and runs it.
- void RunAndRemoveFirstPendingCallback(int32_t result);
-
- // The file system type specified in the Open() call. This will be
- // PP_FILESYSTEMTYPE_INVALID before open was called. This value does not
- // indicate that the open command actually succeeded.
- PP_FileSystemType file_system_type_;
-
- // Set to true when the file has been successfully opened.
- bool file_open_;
-
- std::deque<CallbackEntry> callbacks_;
- OperationType pending_op_;
-
- DISALLOW_COPY_AND_ASSIGN(PPB_FileIO_Shared);
-};
-
-} // namespace ppapi
-
-#endif // PPAPI_SHARED_IMPL_PPB_FILE_IO_SHARED_H_
diff --git a/ppapi/thunk/interfaces_ppb_private.h b/ppapi/thunk/interfaces_ppb_private.h
index e1c53ec..12c0fdf 100644
--- a/ppapi/thunk/interfaces_ppb_private.h
+++ b/ppapi/thunk/interfaces_ppb_private.h
@@ -35,9 +35,6 @@ PROXIED_IFACE(NoAPIName, PPB_FILECHOOSER_TRUSTED_INTERFACE_0_6,
PPB_FileChooserTrusted_0_6)
PROXIED_IFACE(PPB_FileRef, PPB_FILEREFPRIVATE_INTERFACE_0_1,
PPB_FileRefPrivate_0_1)
-// This uses the FileIO API which is declared in the public stable file.
-PROXIED_IFACE(PPB_FileIO, PPB_FILEIOTRUSTED_INTERFACE_0_4,
- PPB_FileIOTrusted_0_4)
PROXIED_IFACE(PPB_Instance, PPB_FLASHFULLSCREEN_INTERFACE_0_1,
PPB_FlashFullscreen_0_1)
PROXIED_IFACE(PPB_Instance, PPB_FLASHFULLSCREEN_INTERFACE_1_0,
@@ -45,6 +42,8 @@ PROXIED_IFACE(PPB_Instance, PPB_FLASHFULLSCREEN_INTERFACE_1_0,
PROXIED_IFACE(NoAPIName, PPB_TALK_PRIVATE_INTERFACE_1_0,
PPB_Talk_Private_1_0)
+// This uses the FileIO API which is declared in the public stable file.
+PROXIED_IFACE(NoAPIName, PPB_FILEIOTRUSTED_INTERFACE_0_4, PPB_FileIOTrusted_0_4)
// Hack to keep font working. The Font 0.6 API is binary compatible with
// BrowserFont 1.0, so just map the string to the same thing.
diff --git a/ppapi/thunk/interfaces_ppb_public_stable.h b/ppapi/thunk/interfaces_ppb_public_stable.h
index c7ae59b6..3bf9479 100644
--- a/ppapi/thunk/interfaces_ppb_public_stable.h
+++ b/ppapi/thunk/interfaces_ppb_public_stable.h
@@ -19,7 +19,6 @@
// that exist in the webkit/plugins/ppapi/*_impl.h, but not in the proxy.
PROXIED_API(PPB_Audio)
PROXIED_API(PPB_Core)
-PROXIED_API(PPB_FileIO)
PROXIED_API(PPB_FileRef)
PROXIED_API(PPB_FileSystem)
PROXIED_API(PPB_Graphics3D)
@@ -48,8 +47,6 @@ UNPROXIED_API(PPB_AudioConfig)
// interface string.
// Note: Core is special and is registered manually.
PROXIED_IFACE(PPB_Audio, PPB_AUDIO_INTERFACE_1_0, PPB_Audio_1_0)
-PROXIED_IFACE(PPB_FileIO, PPB_FILEIO_INTERFACE_1_0, PPB_FileIO_1_0)
-PROXIED_IFACE(PPB_FileIO, PPB_FILEIO_INTERFACE_1_1, PPB_FileIO_1_1)
PROXIED_IFACE(PPB_FileRef, PPB_FILEREF_INTERFACE_1_0, PPB_FileRef_1_0)
PROXIED_IFACE(PPB_FileSystem, PPB_FILESYSTEM_INTERFACE_1_0, PPB_FileSystem_1_0)
PROXIED_IFACE(PPB_Graphics3D, PPB_GRAPHICS_3D_INTERFACE_1_0, PPB_Graphics3D_1_0)
@@ -57,6 +54,8 @@ PROXIED_IFACE(PPB_ImageData, PPB_IMAGEDATA_INTERFACE_1_0, PPB_ImageData_1_0)
PROXIED_IFACE(PPB_Instance, PPB_CONSOLE_INTERFACE_1_0, PPB_Console_1_0)
PROXIED_IFACE(PPB_Instance, PPB_GAMEPAD_INTERFACE_1_0, PPB_Gamepad_1_0)
PROXIED_IFACE(PPB_Instance, PPB_INSTANCE_INTERFACE_1_0, PPB_Instance_1_0)
+PROXIED_IFACE(NoAPIName, PPB_FILEIO_INTERFACE_1_0, PPB_FileIO_1_0)
+PROXIED_IFACE(NoAPIName, PPB_FILEIO_INTERFACE_1_1, PPB_FileIO_1_1)
PROXIED_IFACE(NoAPIName, PPB_GRAPHICS_2D_INTERFACE_1_0, PPB_Graphics2D_1_0)
PROXIED_IFACE(NoAPIName, PPB_INPUT_EVENT_INTERFACE_1_0, PPB_InputEvent_1_0)
PROXIED_IFACE(NoAPIName, PPB_KEYBOARD_INPUT_EVENT_INTERFACE_1_0,