summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-21 23:49:16 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-21 23:49:16 +0000
commitce482dfe397df7f7c06901ade9f35b10fd32aa94 (patch)
tree88e2dca000032b47b12edfa908c8e8ec0f4ddab3 /ppapi
parent563532cca9b9c670f77c16b70034e4fe2aad7e7e (diff)
downloadchromium_src-ce482dfe397df7f7c06901ade9f35b10fd32aa94.zip
chromium_src-ce482dfe397df7f7c06901ade9f35b10fd32aa94.tar.gz
chromium_src-ce482dfe397df7f7c06901ade9f35b10fd32aa94.tar.bz2
Implement the filesystem proxy. This allows the FileRef tests (the ones which
don't use FileIO which isn't don yet) to pass in the proxy. Hook up the code from the URLLoader that downloads to a file. This allows all URLLoader tests to pass in the proxy. Change code in dispatcher that zeros out the array to take into account padding. It was only zero-filling half of the array since sizeof(enum) * # elts seems to be half as large as the actual array due to padding on 64-bit systems. Make the aborted completion callbacks run asynchronously. This was caught by one of the file ref tests. We really need a system for doing this better, but I don't want to do that in this patch. TEST=ppapi_tests run under proxy Review URL: http://codereview.chromium.org/6543028 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75566 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/c/dev/pp_file_info_dev.h1
-rw-r--r--ppapi/c/dev/ppb_file_ref_dev.h3
-rw-r--r--ppapi/c/dev/ppb_file_system_dev.h27
-rw-r--r--ppapi/ppapi_shared_proxy.gypi2
-rw-r--r--ppapi/proxy/dispatcher.cc8
-rw-r--r--ppapi/proxy/interface_id.h1
-rw-r--r--ppapi/proxy/plugin_resource.h1
-rw-r--r--ppapi/proxy/ppapi_messages_internal.h17
-rw-r--r--ppapi/proxy/ppb_file_chooser_proxy.cc9
-rw-r--r--ppapi/proxy/ppb_file_ref_proxy.cc2
-rw-r--r--ppapi/proxy/ppb_file_system_proxy.cc204
-rw-r--r--ppapi/proxy/ppb_file_system_proxy.h61
-rw-r--r--ppapi/proxy/ppb_url_loader_proxy.cc9
-rw-r--r--ppapi/proxy/ppb_url_response_info_proxy.cc39
-rw-r--r--ppapi/proxy/ppb_url_response_info_proxy.h3
15 files changed, 358 insertions, 29 deletions
diff --git a/ppapi/c/dev/pp_file_info_dev.h b/ppapi/c/dev/pp_file_info_dev.h
index dd247fc..782b4f9 100644
--- a/ppapi/c/dev/pp_file_info_dev.h
+++ b/ppapi/c/dev/pp_file_info_dev.h
@@ -17,6 +17,7 @@ typedef enum {
PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_FileType_Dev, 4);
typedef enum {
+ PP_FILESYSTEMTYPE_INVALID = 0, /* For identifying invalid return values. */
PP_FILESYSTEMTYPE_EXTERNAL,
PP_FILESYSTEMTYPE_LOCALPERSISTENT,
PP_FILESYSTEMTYPE_LOCALTEMPORARY
diff --git a/ppapi/c/dev/ppb_file_ref_dev.h b/ppapi/c/dev/ppb_file_ref_dev.h
index 4799b34..24cb21d 100644
--- a/ppapi/c/dev/ppb_file_ref_dev.h
+++ b/ppapi/c/dev/ppb_file_ref_dev.h
@@ -24,7 +24,8 @@ struct PPB_FileRef_Dev {
// resource is invalid or some type other than a FileRef.
PP_Bool (*IsFileRef)(PP_Resource resource);
- // Returns the file system identifier of this file.
+ // Returns the file system identifier of this file, or
+ // PP_FILESYSTEMTYPE_INVALID if the file ref is invalid.
PP_FileSystemType_Dev (*GetFileSystemType)(PP_Resource file_ref);
// Returns the name of the file. The value returned by this function does not
diff --git a/ppapi/c/dev/ppb_file_system_dev.h b/ppapi/c/dev/ppb_file_system_dev.h
index 69b18bd..768c35f 100644
--- a/ppapi/c/dev/ppb_file_system_dev.h
+++ b/ppapi/c/dev/ppb_file_system_dev.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010 The Chromium Authors. All rights reserved.
+/* 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.
*/
@@ -6,6 +6,7 @@
#define PPAPI_C_DEV_PPB_FILE_SYSTEM_DEV_H_
#include "ppapi/c/dev/pp_file_info_dev.h"
+#include "ppapi/c/pp_bool.h"
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_stdint.h"
@@ -13,17 +14,33 @@
struct PP_CompletionCallback;
-#define PPB_FILESYSTEM_DEV_INTERFACE "PPB_FileSystem(Dev);0.3"
+#define PPB_FILESYSTEM_DEV_INTERFACE "PPB_FileSystem(Dev);0.4"
struct PPB_FileSystem_Dev {
- // Creates a weak pointer to the filesystem of the given type.
+ /** Creates a filesystem object of the given type. */
PP_Resource (*Create)(PP_Instance instance, PP_FileSystemType_Dev type);
- // Opens the file system. A file system must be opened before running any
- // other operation on it.
+ /** Returns PP_TRUE if the given resource is a FileSystem. */
+ PP_Bool (*IsFileSystem)(PP_Resource resource);
+
+ /**
+ * Opens the file system. A file system must be opened before running any
+ * other operation on it.
+ *
+ * TODO(brettw) clarify whether this must have completed before a file can
+ * be opened in it. Clarify what it means to be "completed."
+ */
int32_t (*Open)(PP_Resource file_system,
int64_t expected_size,
struct PP_CompletionCallback callback);
+
+ /**
+ * Returns the type of the given file system.
+ *
+ * Returns PP_FILESYSTEMTYPE_INVALID if the given resource is not a valid
+ * filesystem. It is valid to call this function even before Open completes.
+ */
+ PP_FileSystemType_Dev (*GetType)(PP_Resource file_system);
};
#endif /* PPAPI_C_DEV_PPB_FILE_SYSTEM_DEV_H_ */
diff --git a/ppapi/ppapi_shared_proxy.gypi b/ppapi/ppapi_shared_proxy.gypi
index 0ba2964..6fa1714 100644
--- a/ppapi/ppapi_shared_proxy.gypi
+++ b/ppapi/ppapi_shared_proxy.gypi
@@ -89,6 +89,8 @@
'proxy/ppb_file_chooser_proxy.h',
'proxy/ppb_file_ref_proxy.cc',
'proxy/ppb_file_ref_proxy.h',
+ 'proxy/ppb_file_system_proxy.cc',
+ 'proxy/ppb_file_system_proxy.h',
'proxy/ppb_flash_proxy.cc',
'proxy/ppb_flash_proxy.h',
'proxy/ppb_flash_menu_proxy.cc',
diff --git a/ppapi/proxy/dispatcher.cc b/ppapi/proxy/dispatcher.cc
index 2eca735..6942e26 100644
--- a/ppapi/proxy/dispatcher.cc
+++ b/ppapi/proxy/dispatcher.cc
@@ -50,6 +50,7 @@
#include "ppapi/proxy/ppb_cursor_control_proxy.h"
#include "ppapi/proxy/ppb_file_chooser_proxy.h"
#include "ppapi/proxy/ppb_file_ref_proxy.h"
+#include "ppapi/proxy/ppb_file_system_proxy.h"
#include "ppapi/proxy/ppb_flash_proxy.h"
#include "ppapi/proxy/ppb_flash_menu_proxy.h"
#include "ppapi/proxy/ppb_font_proxy.h"
@@ -92,10 +93,8 @@ struct InterfaceList {
};
InterfaceList::InterfaceList() {
- memset(id_to_plugin_info_, 0,
- static_cast<int>(INTERFACE_ID_COUNT) * sizeof(InterfaceID));
- memset(id_to_browser_info_, 0,
- static_cast<int>(INTERFACE_ID_COUNT) * sizeof(InterfaceID));
+ memset(id_to_plugin_info_, 0, sizeof(id_to_plugin_info_));
+ memset(id_to_browser_info_, 0, sizeof(id_to_browser_info_));
// PPB (browser) interfaces.
AddPPB(PPB_AudioConfig_Proxy::GetInfo());
@@ -107,6 +106,7 @@ InterfaceList::InterfaceList() {
AddPPB(PPB_CursorControl_Proxy::GetInfo());
AddPPB(PPB_FileChooser_Proxy::GetInfo());
AddPPB(PPB_FileRef_Proxy::GetInfo());
+ AddPPB(PPB_FileSystem_Proxy::GetInfo());
AddPPB(PPB_Flash_Proxy::GetInfo());
AddPPB(PPB_Flash_Menu_Proxy::GetInfo());
AddPPB(PPB_Font_Proxy::GetInfo());
diff --git a/ppapi/proxy/interface_id.h b/ppapi/proxy/interface_id.h
index d3da24e..bd1d054 100644
--- a/ppapi/proxy/interface_id.h
+++ b/ppapi/proxy/interface_id.h
@@ -22,6 +22,7 @@ enum InterfaceID {
INTERFACE_ID_PPB_CURSORCONTROL,
INTERFACE_ID_PPB_FILE_CHOOSER,
INTERFACE_ID_PPB_FILE_REF,
+ INTERFACE_ID_PPB_FILE_SYSTEM,
INTERFACE_ID_PPB_FLASH,
INTERFACE_ID_PPB_FLASH_MENU,
INTERFACE_ID_PPB_FONT,
diff --git a/ppapi/proxy/plugin_resource.h b/ppapi/proxy/plugin_resource.h
index 92b1b8c..0b4ef24 100644
--- a/ppapi/proxy/plugin_resource.h
+++ b/ppapi/proxy/plugin_resource.h
@@ -19,6 +19,7 @@
F(Context3D) \
F(FileChooser) \
F(FileRef) \
+ F(FileSystem) \
F(FlashMenu) \
F(Font) \
F(Graphics2D) \
diff --git a/ppapi/proxy/ppapi_messages_internal.h b/ppapi/proxy/ppapi_messages_internal.h
index be671a2..20ecffa 100644
--- a/ppapi/proxy/ppapi_messages_internal.h
+++ b/ppapi/proxy/ppapi_messages_internal.h
@@ -53,6 +53,12 @@ IPC_MESSAGE_ROUTED3(
int32_t /* result_code (will be != PP_OK on failure */,
std::vector<pp::proxy::PPBFileRef_CreateInfo> /* chosen_files */)
+// PPB_FileSystem.
+IPC_MESSAGE_ROUTED2(
+ PpapiMsg_PPBFileSystem_OpenComplete,
+ pp::proxy::HostResource /* filesystem */,
+ int32_t /* result */)
+
// PPB_Graphics2D.
IPC_MESSAGE_ROUTED2(PpapiMsg_PPBGraphics2D_FlushACK,
pp::proxy::HostResource /* graphics_2d */,
@@ -318,6 +324,15 @@ IPC_MESSAGE_ROUTED3(PpapiHostMsg_PPBFileRef_Rename,
pp::proxy::HostResource /* new_file_ref */,
uint32_t /* serialized_callback */);
+// PPB_FileSystem.
+IPC_SYNC_MESSAGE_ROUTED2_1(PpapiHostMsg_PPBFileSystem_Create,
+ PP_Instance /* instance */,
+ int /* type */,
+ pp::proxy::HostResource /* result */)
+IPC_MESSAGE_ROUTED2(PpapiHostMsg_PPBFileSystem_Open,
+ pp::proxy::HostResource /* result */,
+ int64_t /* expected_size */)
+
// PPB_Flash.
IPC_MESSAGE_ROUTED2(PpapiHostMsg_PPBFlash_SetInstanceAlwaysOnTop,
PP_Instance /* instance */,
@@ -570,7 +585,7 @@ IPC_SYNC_MESSAGE_ROUTED2_1(PpapiHostMsg_PPBURLResponseInfo_GetProperty,
pp::proxy::SerializedVar /* result */)
IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBURLResponseInfo_GetBodyAsFileRef,
pp::proxy::HostResource /* response */,
- pp::proxy::HostResource /* file_ref_result */)
+ pp::proxy::PPBFileRef_CreateInfo /* result */)
// PPB_Var.
IPC_MESSAGE_ROUTED1(PpapiHostMsg_PPBVar_AddRefObject,
diff --git a/ppapi/proxy/ppb_file_chooser_proxy.cc b/ppapi/proxy/ppb_file_chooser_proxy.cc
index a50908c4..9c997fb 100644
--- a/ppapi/proxy/ppb_file_chooser_proxy.cc
+++ b/ppapi/proxy/ppb_file_chooser_proxy.cc
@@ -45,8 +45,13 @@ FileChooser::FileChooser(const HostResource& resource)
FileChooser::~FileChooser() {
// Always need to fire completion callbacks to prevent a leak in the plugin.
- if (current_show_callback_.func)
- PP_RunCompletionCallback(&current_show_callback_, PP_ERROR_ABORTED);
+ if (current_show_callback_.func) {
+ // TODO(brettw) the callbacks at this level should be refactored with a
+ // more automatic tracking system like we have in the renderer.
+ MessageLoop::current()->PostTask(FROM_HERE, NewRunnableFunction(
+ current_show_callback_.func, current_show_callback_.user_data,
+ static_cast<int32_t>(PP_ERROR_ABORTED)));
+ }
// Any existing files we haven't transferred ownership to the plugin need
// to be freed.
diff --git a/ppapi/proxy/ppb_file_ref_proxy.cc b/ppapi/proxy/ppb_file_ref_proxy.cc
index 85b133e..3777ee3 100644
--- a/ppapi/proxy/ppb_file_ref_proxy.cc
+++ b/ppapi/proxy/ppb_file_ref_proxy.cc
@@ -297,8 +297,6 @@ void PPB_FileRef_Proxy::OnMsgGetParent(const HostResource& host_resource,
PPBFileRef_CreateInfo* result) {
PP_Resource resource = ppb_file_ref_target()->GetParent(
host_resource.host_resource());
- if (!resource)
- return; // CreateInfo default constructor initializes to 0.
SerializeFileRef(resource, result);
}
diff --git a/ppapi/proxy/ppb_file_system_proxy.cc b/ppapi/proxy/ppb_file_system_proxy.cc
new file mode 100644
index 0000000..36a36f1
--- /dev/null
+++ b/ppapi/proxy/ppb_file_system_proxy.cc
@@ -0,0 +1,204 @@
+// 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.
+
+#include "ppapi/proxy/ppb_file_system_proxy.h"
+
+#include "base/message_loop.h"
+#include "base/task.h"
+#include "ppapi/c/dev/ppb_file_system_dev.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/proxy/host_dispatcher.h"
+#include "ppapi/proxy/plugin_dispatcher.h"
+#include "ppapi/proxy/plugin_resource.h"
+#include "ppapi/proxy/ppapi_messages.h"
+#include "ppapi/proxy/serialized_var.h"
+
+namespace pp {
+namespace proxy {
+
+// This object maintains most of the state of the ref in the plugin for fast
+// querying. It's all set in the constructor from the "create info" sent from
+// the host.
+class FileSystem : public PluginResource {
+ public:
+ FileSystem(const HostResource& host_resource, PP_FileSystemType_Dev type);
+ virtual ~FileSystem();
+
+ virtual FileSystem* AsFileSystem();
+
+ PP_FileSystemType_Dev type_;
+ bool opened_;
+ PP_CompletionCallback current_open_callback_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(FileSystem);
+};
+
+FileSystem::FileSystem(const HostResource& host_resource,
+ PP_FileSystemType_Dev type)
+ : PluginResource(host_resource),
+ type_(type),
+ opened_(false),
+ current_open_callback_(PP_MakeCompletionCallback(NULL, NULL)) {
+}
+
+// TODO(brettw) this logic is duplicated with some other resource objects
+// like FileChooser. It would be nice to look at all of the different resources
+// that need callback tracking and design something that they can all re-use.
+FileSystem::~FileSystem() {
+ // Ensure the callback is always fired.
+ if (current_open_callback_.func) {
+ // TODO(brettw) the callbacks at this level should be refactored with a
+ // more automatic tracking system like we have in the renderer.
+ MessageLoop::current()->PostTask(FROM_HERE, NewRunnableFunction(
+ current_open_callback_.func, current_open_callback_.user_data,
+ static_cast<int32_t>(PP_ERROR_ABORTED)));
+ }
+}
+
+FileSystem* FileSystem::AsFileSystem() {
+ return this;
+}
+
+namespace {
+
+PP_Resource Create(PP_Instance instance, PP_FileSystemType_Dev type) {
+ PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
+ if (!dispatcher)
+ return PP_ERROR_BADARGUMENT;
+
+ HostResource result;
+ dispatcher->Send(new PpapiHostMsg_PPBFileSystem_Create(
+ INTERFACE_ID_PPB_FILE_SYSTEM, instance, type, &result));
+ if (result.is_null())
+ return 0;
+
+ linked_ptr<FileSystem> object(new FileSystem(result, type));
+ return PluginResourceTracker::GetInstance()->AddResource(object);
+}
+
+PP_Bool IsFileSystem(PP_Resource resource) {
+ FileSystem* object = PluginResource::GetAs<FileSystem>(resource);
+ return BoolToPPBool(!!object);
+}
+
+int32_t Open(PP_Resource file_system,
+ int64_t expected_size,
+ struct PP_CompletionCallback callback) {
+ FileSystem* object = PluginResource::GetAs<FileSystem>(file_system);
+ if (!object)
+ return PP_ERROR_BADRESOURCE;
+ if (object->opened_)
+ return PP_OK;
+
+ Dispatcher* dispatcher = PluginDispatcher::GetForInstance(object->instance());
+ if (!dispatcher)
+ return PP_ERROR_BADARGUMENT;
+
+ if (object->current_open_callback_.func)
+ return PP_ERROR_INPROGRESS;
+ object->current_open_callback_ = callback;
+
+ dispatcher->Send(new PpapiHostMsg_PPBFileSystem_Open(
+ INTERFACE_ID_PPB_FILE_SYSTEM, object->host_resource(), expected_size));
+ return PP_ERROR_WOULDBLOCK;
+}
+
+PP_FileSystemType_Dev GetType(PP_Resource resource) {
+ FileSystem* object = PluginResource::GetAs<FileSystem>(resource);
+ if (!object)
+ return PP_FILESYSTEMTYPE_INVALID;
+ return object->type_;
+}
+
+const PPB_FileSystem_Dev file_system_interface = {
+ &Create,
+ &IsFileSystem,
+ &Open,
+ &GetType
+};
+
+InterfaceProxy* CreateFileSystemProxy(Dispatcher* dispatcher,
+ const void* target_interface) {
+ return new PPB_FileSystem_Proxy(dispatcher, target_interface);
+}
+
+} // namespace
+
+PPB_FileSystem_Proxy::PPB_FileSystem_Proxy(Dispatcher* dispatcher,
+ const void* target_interface)
+ : InterfaceProxy(dispatcher, target_interface),
+ callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
+}
+
+PPB_FileSystem_Proxy::~PPB_FileSystem_Proxy() {
+}
+
+const InterfaceProxy::Info* PPB_FileSystem_Proxy::GetInfo() {
+ static const Info info = {
+ &file_system_interface,
+ PPB_FILESYSTEM_DEV_INTERFACE,
+ INTERFACE_ID_PPB_FILE_SYSTEM,
+ false,
+ &CreateFileSystemProxy,
+ };
+ return &info;
+}
+
+bool PPB_FileSystem_Proxy::OnMessageReceived(const IPC::Message& msg) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(PPB_FileSystem_Proxy, msg)
+ IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileSystem_Create, OnMsgCreate)
+ IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileSystem_Open, OnMsgOpen)
+ IPC_MESSAGE_HANDLER(PpapiMsg_PPBFileSystem_OpenComplete, OnMsgOpenComplete)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+}
+
+void PPB_FileSystem_Proxy::OnMsgCreate(PP_Instance instance,
+ int type,
+ HostResource* result) {
+ PP_Resource resource = ppb_file_system_target()->Create(
+ instance, static_cast<PP_FileSystemType_Dev>(type));
+ if (!resource)
+ return; // CreateInfo default constructor initializes to 0.
+ result->SetHostResource(instance, resource);
+}
+
+void PPB_FileSystem_Proxy::OnMsgOpen(const HostResource& host_resource,
+ int64_t expected_size) {
+ CompletionCallback callback = callback_factory_.NewCallback(
+ &PPB_FileSystem_Proxy::OpenCompleteInHost, host_resource);
+
+ int32_t result = ppb_file_system_target()->Open(
+ host_resource.host_resource(), expected_size,
+ callback.pp_completion_callback());
+ if (result != PP_ERROR_WOULDBLOCK)
+ callback.Run(result);
+}
+
+// Called in the plugin to handle the open callback.
+void PPB_FileSystem_Proxy::OnMsgOpenComplete(const HostResource& filesystem,
+ int32_t result) {
+ FileSystem* object = PluginResource::GetAs<FileSystem>(
+ PluginResourceTracker::GetInstance()->PluginResourceForHostResource(
+ filesystem));
+ if (!object || !object->current_open_callback_.func)
+ return;
+
+ PP_CompletionCallback callback = object->current_open_callback_;
+ object->current_open_callback_ = PP_MakeCompletionCallback(NULL, NULL);
+ PP_RunCompletionCallback(&callback, result);
+}
+
+void PPB_FileSystem_Proxy::OpenCompleteInHost(
+ int32_t result,
+ const HostResource& host_resource) {
+ dispatcher()->Send(new PpapiMsg_PPBFileSystem_OpenComplete(
+ INTERFACE_ID_PPB_FILE_SYSTEM, host_resource, result));
+}
+
+} // namespace proxy
+} // namespace pp
diff --git a/ppapi/proxy/ppb_file_system_proxy.h b/ppapi/proxy/ppb_file_system_proxy.h
new file mode 100644
index 0000000..acfe171
--- /dev/null
+++ b/ppapi/proxy/ppb_file_system_proxy.h
@@ -0,0 +1,61 @@
+// 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_SYSTEM_PROXY_H_
+#define PPAPI_PROXY_PPB_FILE_SYSTEM_PROXY_H_
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "ppapi/c/pp_instance.h"
+#include "ppapi/c/pp_resource.h"
+#include "ppapi/c/pp_time.h"
+#include "ppapi/cpp/completion_callback.h"
+#include "ppapi/proxy/interface_proxy.h"
+#include "ppapi/proxy/proxy_non_thread_safe_ref_count.h"
+
+struct PPB_FileSystem_Dev;
+
+namespace pp {
+namespace proxy {
+
+class HostResource;
+
+class PPB_FileSystem_Proxy : public InterfaceProxy {
+ public:
+ PPB_FileSystem_Proxy(Dispatcher* dispatcher, const void* target_interface);
+ virtual ~PPB_FileSystem_Proxy();
+
+ static const Info* GetInfo();
+
+ const PPB_FileSystem_Dev* ppb_file_system_target() const {
+ return static_cast<const PPB_FileSystem_Dev*>(target_interface());
+ }
+
+ // InterfaceProxy implementation.
+ virtual bool OnMessageReceived(const IPC::Message& msg);
+
+ private:
+ // Message handlers.
+ void OnMsgCreate(PP_Instance instance,
+ int type,
+ HostResource* result);
+ void OnMsgOpen(const HostResource& filesystem,
+ int64_t expected_size);
+
+ void OnMsgOpenComplete(const HostResource& filesystem,
+ int32_t result);
+
+ void OpenCompleteInHost(int32_t result, const HostResource& host_resource);
+
+ CompletionCallbackFactory<PPB_FileSystem_Proxy,
+ ProxyNonThreadSafeRefCount> callback_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(PPB_FileSystem_Proxy);
+};
+
+} // namespace proxy
+} // namespace pp
+
+#endif // PPAPI_PROXY_PPB_FILE_SYSTEM_PROXY_H_
diff --git a/ppapi/proxy/ppb_url_loader_proxy.cc b/ppapi/proxy/ppb_url_loader_proxy.cc
index 76e3a35..74b79d9 100644
--- a/ppapi/proxy/ppb_url_loader_proxy.cc
+++ b/ppapi/proxy/ppb_url_loader_proxy.cc
@@ -70,8 +70,13 @@ URLLoader::URLLoader(const HostResource& resource)
URLLoader::~URLLoader() {
// Always need to fire completion callbacks to prevent a leak in the plugin.
- if (current_read_callback_.func)
- PP_RunCompletionCallback(&current_read_callback_, PP_ERROR_ABORTED);
+ if (current_read_callback_.func) {
+ // TODO(brettw) the callbacks at this level should be refactored with a
+ // more automatic tracking system like we have in the renderer.
+ MessageLoop::current()->PostTask(FROM_HERE, NewRunnableFunction(
+ current_read_callback_.func, current_read_callback_.user_data,
+ static_cast<int32_t>(PP_ERROR_ABORTED)));
+ }
if (response_info_)
PluginResourceTracker::GetInstance()->ReleaseResource(response_info_);
diff --git a/ppapi/proxy/ppb_url_response_info_proxy.cc b/ppapi/proxy/ppb_url_response_info_proxy.cc
index 8e12470..575e016 100644
--- a/ppapi/proxy/ppb_url_response_info_proxy.cc
+++ b/ppapi/proxy/ppb_url_response_info_proxy.cc
@@ -5,9 +5,11 @@
#include "ppapi/proxy/ppb_url_response_info_proxy.h"
#include "ppapi/c/ppb_url_response_info.h"
+#include "ppapi/proxy/host_dispatcher.h"
#include "ppapi/proxy/plugin_dispatcher.h"
#include "ppapi/proxy/plugin_resource.h"
#include "ppapi/proxy/ppapi_messages.h"
+#include "ppapi/proxy/ppb_file_ref_proxy.h"
#include "ppapi/proxy/serialized_var.h"
namespace pp {
@@ -51,13 +53,23 @@ PP_Var GetProperty(PP_Resource response, PP_URLResponseProperty property) {
}
PP_Resource GetBodyAsFileRef(PP_Resource response) {
- /*
+ URLResponseInfo* object = PluginResource::GetAs<URLResponseInfo>(response);
+ if (!object)
+ return 0;
+ PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(
+ object->instance());
+ if (!dispatcher)
+ return 0;
+
+ // This could be more efficient by having the host automatically send us the
+ // file ref when the request is streaming to a file and it's in the state
+ // where the file is ready. This will prevent us from having to do this sync
+ // IPC here.
+ PPBFileRef_CreateInfo create_info;
dispatcher->Send(new PpapiHostMsg_PPBURLResponseInfo_GetBodyAsFileRef(
- INTERFACE_ID_PPB_URL_RESPONSE_INFO, response, &result));
- // TODO(brettw) when we have FileRef proxied, make an object from that
- // ref so we can track it properly and then uncomment this.
- */
- return 0;
+ INTERFACE_ID_PPB_URL_RESPONSE_INFO,
+ object->host_resource(), &create_info));
+ return PPB_FileRef_Proxy::DeserializeFileRef(create_info);
}
const PPB_URLResponseInfo urlresponseinfo_interface = {
@@ -124,11 +136,16 @@ void PPB_URLResponseInfo_Proxy::OnMsgGetProperty(
void PPB_URLResponseInfo_Proxy::OnMsgGetBodyAsFileRef(
HostResource response,
- HostResource* file_ref_result) {
- file_ref_result->SetHostResource(
- response.instance(),
- ppb_url_response_info_target()->GetBodyAsFileRef(
- response.host_resource()));
+ PPBFileRef_CreateInfo* result) {
+ PP_Resource file_ref = ppb_url_response_info_target()->GetBodyAsFileRef(
+ response.host_resource());
+
+ // Use the FileRef proxy to serialize.
+ DCHECK(!dispatcher()->IsPlugin());
+ HostDispatcher* host_disp = static_cast<HostDispatcher*>(dispatcher());
+ PPB_FileRef_Proxy* file_ref_proxy = static_cast<PPB_FileRef_Proxy*>(
+ host_disp->GetOrCreatePPBInterfaceProxy(INTERFACE_ID_PPB_FILE_REF));
+ file_ref_proxy->SerializeFileRef(file_ref, result);
}
} // namespace proxy
diff --git a/ppapi/proxy/ppb_url_response_info_proxy.h b/ppapi/proxy/ppb_url_response_info_proxy.h
index 50da19e..e22e9a8 100644
--- a/ppapi/proxy/ppb_url_response_info_proxy.h
+++ b/ppapi/proxy/ppb_url_response_info_proxy.h
@@ -17,6 +17,7 @@ struct PPB_URLResponseInfo;
namespace pp {
namespace proxy {
+struct PPBFileRef_CreateInfo;
class SerializedVarReturnValue;
class PPB_URLResponseInfo_Proxy : public InterfaceProxy {
@@ -47,7 +48,7 @@ class PPB_URLResponseInfo_Proxy : public InterfaceProxy {
int32_t property,
SerializedVarReturnValue result);
void OnMsgGetBodyAsFileRef(HostResource response,
- HostResource* file_ref_result);
+ PPBFileRef_CreateInfo* result);
DISALLOW_COPY_AND_ASSIGN(PPB_URLResponseInfo_Proxy);
};