| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_FILE_IO_HOST_H_ | 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_FILE_IO_HOST_H_ |
| 6 #define CONTENT_RENDERER_PEPPER_PEPPER_FILE_IO_HOST_H_ | 6 #define CONTENT_RENDERER_PEPPER_PEPPER_FILE_IO_HOST_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
| 13 #include "base/id_map.h" | 13 #include "base/id_map.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/platform_file.h" | 15 #include "base/platform_file.h" |
| 16 #include "content/public/renderer/renderer_ppapi_host.h" | 16 #include "content/public/renderer/renderer_ppapi_host.h" |
| 17 #include "ipc/ipc_listener.h" | 17 #include "ipc/ipc_listener.h" |
| 18 #include "ipc/ipc_platform_file.h" | 18 #include "ipc/ipc_platform_file.h" |
| 19 #include "ppapi/host/host_message_context.h" | 19 #include "ppapi/host/host_message_context.h" |
| 20 #include "ppapi/host/resource_host.h" | 20 #include "ppapi/host/resource_host.h" |
| 21 #include "ppapi/shared_impl/file_io_state_manager.h" | 21 #include "ppapi/shared_impl/file_io_state_manager.h" |
| 22 #include "ppapi/shared_impl/file_ref_detailed_info.h" |
| 22 #include "ppapi/thunk/ppb_file_ref_api.h" | 23 #include "ppapi/thunk/ppb_file_ref_api.h" |
| 23 #include "url/gurl.h" | 24 #include "url/gurl.h" |
| 24 #include "webkit/common/quota/quota_types.h" | 25 #include "webkit/common/quota/quota_types.h" |
| 25 | 26 |
| 26 using ppapi::host::ReplyMessageContext; | 27 using ppapi::host::ReplyMessageContext; |
| 27 | 28 |
| 28 namespace content { | 29 namespace content { |
| 30 class PepperPluginInstanceImpl; |
| 29 class QuotaFileIO; | 31 class QuotaFileIO; |
| 30 | 32 |
| 31 class PepperFileIOHost : public ppapi::host::ResourceHost, | 33 class PepperFileIOHost : public ppapi::host::ResourceHost, |
| 32 public base::SupportsWeakPtr<PepperFileIOHost>, | 34 public base::SupportsWeakPtr<PepperFileIOHost>, |
| 33 public IPC::Listener { | 35 public IPC::Listener { |
| 34 public: | 36 public: |
| 35 typedef base::Callback<void (base::PlatformFileError)> | 37 typedef base::Callback<void (base::PlatformFileError)> |
| 36 NotifyCloseFileCallback; | 38 NotifyCloseFileCallback; |
| 37 | 39 |
| 38 PepperFileIOHost(RendererPpapiHost* host, | 40 PepperFileIOHost(RendererPpapiHost* host, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 ppapi::host::HostMessageContext* context); | 78 ppapi::host::HostMessageContext* context); |
| 77 // Trusted API. | 79 // Trusted API. |
| 78 int32_t OnHostMsgGetOSFileDescriptor( | 80 int32_t OnHostMsgGetOSFileDescriptor( |
| 79 ppapi::host::HostMessageContext* context); | 81 ppapi::host::HostMessageContext* context); |
| 80 int32_t OnHostMsgWillWrite(ppapi::host::HostMessageContext* context, | 82 int32_t OnHostMsgWillWrite(ppapi::host::HostMessageContext* context, |
| 81 int64_t offset, | 83 int64_t offset, |
| 82 int32_t bytes_to_write); | 84 int32_t bytes_to_write); |
| 83 int32_t OnHostMsgWillSetLength(ppapi::host::HostMessageContext* context, | 85 int32_t OnHostMsgWillSetLength(ppapi::host::HostMessageContext* context, |
| 84 int64_t length); | 86 int64_t length); |
| 85 | 87 |
| 88 void DidGetFileRefInfo( |
| 89 ppapi::host::ReplyMessageContext reply_context, |
| 90 int flags, |
| 91 const std::vector<ppapi::FileRefDetailedInfo>& infos); |
| 92 |
| 86 // Callback handlers. These mostly convert the PlatformFileError to the | 93 // Callback handlers. These mostly convert the PlatformFileError to the |
| 87 // PP_Error code and send back the reply. Note that the argument | 94 // PP_Error code and send back the reply. Note that the argument |
| 88 // ReplyMessageContext is copied so that we have a closure containing all | 95 // ReplyMessageContext is copied so that we have a closure containing all |
| 89 // necessary information to reply. | 96 // necessary information to reply. |
| 90 void ExecutePlatformGeneralCallback(ReplyMessageContext reply_context, | 97 void ExecutePlatformGeneralCallback(ReplyMessageContext reply_context, |
| 91 base::PlatformFileError error_code); | 98 base::PlatformFileError error_code); |
| 92 void ExecutePlatformOpenFileCallback(ReplyMessageContext reply_context, | 99 void ExecutePlatformOpenFileCallback(ReplyMessageContext reply_context, |
| 93 base::PlatformFileError error_code, | 100 base::PlatformFileError error_code, |
| 94 base::PassPlatformFile file); | 101 base::PassPlatformFile file); |
| 95 void ExecutePlatformOpenFileSystemURLCallback( | 102 void ExecutePlatformOpenFileSystemURLCallback( |
| 96 ReplyMessageContext reply_context, | 103 ReplyMessageContext reply_context, |
| 97 base::PlatformFileError error_code, | 104 base::PlatformFileError error_code, |
| 98 base::PassPlatformFile file, | 105 base::PassPlatformFile file, |
| 99 quota::QuotaLimitType quota_policy, | 106 quota::QuotaLimitType quota_policy, |
| 100 const NotifyCloseFileCallback& callback); | 107 const NotifyCloseFileCallback& callback); |
| 101 void ExecutePlatformQueryCallback(ReplyMessageContext reply_context, | 108 void ExecutePlatformQueryCallback(ReplyMessageContext reply_context, |
| 102 base::PlatformFileError error_code, | 109 base::PlatformFileError error_code, |
| 103 const base::PlatformFileInfo& file_info); | 110 const base::PlatformFileInfo& file_info); |
| 104 void ExecutePlatformReadCallback(ReplyMessageContext reply_context, | 111 void ExecutePlatformReadCallback(ReplyMessageContext reply_context, |
| 105 base::PlatformFileError error_code, | 112 base::PlatformFileError error_code, |
| 106 const char* data, int bytes_read); | 113 const char* data, int bytes_read); |
| 107 void ExecutePlatformWriteCallback(ReplyMessageContext reply_context, | 114 void ExecutePlatformWriteCallback(ReplyMessageContext reply_context, |
| 108 base::PlatformFileError error_code, | 115 base::PlatformFileError error_code, |
| 109 int bytes_written); | 116 int bytes_written); |
| 110 | 117 |
| 111 RendererPpapiHost* renderer_ppapi_host_; | 118 RendererPpapiHost* renderer_ppapi_host_; |
| 112 | 119 PepperPluginInstanceImpl* plugin_instance_; |
| 113 base::PlatformFile file_; | 120 base::PlatformFile file_; |
| 114 | 121 |
| 115 // The file system type specified in the Open() call. This will be | 122 // The file system type specified in the Open() call. This will be |
| 116 // PP_FILESYSTEMTYPE_INVALID before open was called. This value does not | 123 // PP_FILESYSTEMTYPE_INVALID before open was called. This value does not |
| 117 // indicate that the open command actually succeeded. | 124 // indicate that the open command actually succeeded. |
| 118 PP_FileSystemType file_system_type_; | 125 PP_FileSystemType file_system_type_; |
| 119 | 126 |
| 120 // Valid only for PP_FILESYSTEMTYPE_LOCAL{PERSISTENT,TEMPORARY}. | 127 // Valid only for PP_FILESYSTEMTYPE_LOCAL{PERSISTENT,TEMPORARY}. |
| 121 GURL file_system_url_; | 128 GURL file_system_url_; |
| 122 | 129 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 144 AsyncOpenFileCallback; | 151 AsyncOpenFileCallback; |
| 145 | 152 |
| 146 IDMap<AsyncOpenFileCallback> pending_async_open_files_; | 153 IDMap<AsyncOpenFileCallback> pending_async_open_files_; |
| 147 | 154 |
| 148 DISALLOW_COPY_AND_ASSIGN(PepperFileIOHost); | 155 DISALLOW_COPY_AND_ASSIGN(PepperFileIOHost); |
| 149 }; | 156 }; |
| 150 | 157 |
| 151 } // namespace content | 158 } // namespace content |
| 152 | 159 |
| 153 #endif // CONTENT_RENDERER_PEPPER_PEPPER_FILE_IO_HOST_H_ | 160 #endif // CONTENT_RENDERER_PEPPER_PEPPER_FILE_IO_HOST_H_ |
| OLD | NEW |