| 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" | |
| 23 #include "ppapi/thunk/ppb_file_ref_api.h" | 22 #include "ppapi/thunk/ppb_file_ref_api.h" |
| 24 #include "url/gurl.h" | 23 #include "url/gurl.h" |
| 25 #include "webkit/common/quota/quota_types.h" | 24 #include "webkit/common/quota/quota_types.h" |
| 26 | 25 |
| 27 using ppapi::host::ReplyMessageContext; | 26 using ppapi::host::ReplyMessageContext; |
| 28 | 27 |
| 29 namespace content { | 28 namespace content { |
| 30 class PepperPluginInstanceImpl; | |
| 31 class QuotaFileIO; | 29 class QuotaFileIO; |
| 32 | 30 |
| 33 class PepperFileIOHost : public ppapi::host::ResourceHost, | 31 class PepperFileIOHost : public ppapi::host::ResourceHost, |
| 34 public base::SupportsWeakPtr<PepperFileIOHost>, | 32 public base::SupportsWeakPtr<PepperFileIOHost>, |
| 35 public IPC::Listener { | 33 public IPC::Listener { |
| 36 public: | 34 public: |
| 37 typedef base::Callback<void (base::PlatformFileError)> | 35 typedef base::Callback<void (base::PlatformFileError)> |
| 38 NotifyCloseFileCallback; | 36 NotifyCloseFileCallback; |
| 39 | 37 |
| 40 PepperFileIOHost(RendererPpapiHost* host, | 38 PepperFileIOHost(RendererPpapiHost* host, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 ppapi::host::HostMessageContext* context); | 72 ppapi::host::HostMessageContext* context); |
| 75 // Trusted API. | 73 // Trusted API. |
| 76 int32_t OnHostMsgGetOSFileDescriptor( | 74 int32_t OnHostMsgGetOSFileDescriptor( |
| 77 ppapi::host::HostMessageContext* context); | 75 ppapi::host::HostMessageContext* context); |
| 78 int32_t OnHostMsgWillWrite(ppapi::host::HostMessageContext* context, | 76 int32_t OnHostMsgWillWrite(ppapi::host::HostMessageContext* context, |
| 79 int64_t offset, | 77 int64_t offset, |
| 80 int32_t bytes_to_write); | 78 int32_t bytes_to_write); |
| 81 int32_t OnHostMsgWillSetLength(ppapi::host::HostMessageContext* context, | 79 int32_t OnHostMsgWillSetLength(ppapi::host::HostMessageContext* context, |
| 82 int64_t length); | 80 int64_t length); |
| 83 | 81 |
| 84 void DidGetFileRefInfo( | |
| 85 ppapi::host::ReplyMessageContext reply_context, | |
| 86 int flags, | |
| 87 const std::vector<ppapi::FileRefDetailedInfo>& infos); | |
| 88 | |
| 89 // Callback handlers. These mostly convert the PlatformFileError to the | 82 // Callback handlers. These mostly convert the PlatformFileError to the |
| 90 // PP_Error code and send back the reply. Note that the argument | 83 // PP_Error code and send back the reply. Note that the argument |
| 91 // ReplyMessageContext is copied so that we have a closure containing all | 84 // ReplyMessageContext is copied so that we have a closure containing all |
| 92 // necessary information to reply. | 85 // necessary information to reply. |
| 93 void ExecutePlatformGeneralCallback(ReplyMessageContext reply_context, | 86 void ExecutePlatformGeneralCallback(ReplyMessageContext reply_context, |
| 94 base::PlatformFileError error_code); | 87 base::PlatformFileError error_code); |
| 95 void ExecutePlatformOpenFileCallback(ReplyMessageContext reply_context, | 88 void ExecutePlatformOpenFileCallback(ReplyMessageContext reply_context, |
| 96 base::PlatformFileError error_code, | 89 base::PlatformFileError error_code, |
| 97 base::PassPlatformFile file); | 90 base::PassPlatformFile file); |
| 98 void ExecutePlatformOpenFileSystemURLCallback( | 91 void ExecutePlatformOpenFileSystemURLCallback( |
| 99 ReplyMessageContext reply_context, | 92 ReplyMessageContext reply_context, |
| 100 base::PlatformFileError error_code, | 93 base::PlatformFileError error_code, |
| 101 base::PassPlatformFile file, | 94 base::PassPlatformFile file, |
| 102 quota::QuotaLimitType quota_policy, | 95 quota::QuotaLimitType quota_policy, |
| 103 const NotifyCloseFileCallback& callback); | 96 const NotifyCloseFileCallback& callback); |
| 104 void ExecutePlatformQueryCallback(ReplyMessageContext reply_context, | 97 void ExecutePlatformQueryCallback(ReplyMessageContext reply_context, |
| 105 base::PlatformFileError error_code, | 98 base::PlatformFileError error_code, |
| 106 const base::PlatformFileInfo& file_info); | 99 const base::PlatformFileInfo& file_info); |
| 107 void ExecutePlatformReadCallback(ReplyMessageContext reply_context, | 100 void ExecutePlatformReadCallback(ReplyMessageContext reply_context, |
| 108 base::PlatformFileError error_code, | 101 base::PlatformFileError error_code, |
| 109 const char* data, int bytes_read); | 102 const char* data, int bytes_read); |
| 110 void ExecutePlatformWriteCallback(ReplyMessageContext reply_context, | 103 void ExecutePlatformWriteCallback(ReplyMessageContext reply_context, |
| 111 base::PlatformFileError error_code, | 104 base::PlatformFileError error_code, |
| 112 int bytes_written); | 105 int bytes_written); |
| 113 | 106 |
| 114 RendererPpapiHost* renderer_ppapi_host_; | 107 RendererPpapiHost* renderer_ppapi_host_; |
| 115 PepperPluginInstanceImpl* plugin_instance_; | 108 |
| 116 base::PlatformFile file_; | 109 base::PlatformFile file_; |
| 117 | 110 |
| 118 // The file system type specified in the Open() call. This will be | 111 // The file system type specified in the Open() call. This will be |
| 119 // PP_FILESYSTEMTYPE_INVALID before open was called. This value does not | 112 // PP_FILESYSTEMTYPE_INVALID before open was called. This value does not |
| 120 // indicate that the open command actually succeeded. | 113 // indicate that the open command actually succeeded. |
| 121 PP_FileSystemType file_system_type_; | 114 PP_FileSystemType file_system_type_; |
| 122 | 115 |
| 123 // Valid only for PP_FILESYSTEMTYPE_LOCAL{PERSISTENT,TEMPORARY}. | 116 // Valid only for PP_FILESYSTEMTYPE_LOCAL{PERSISTENT,TEMPORARY}. |
| 124 GURL file_system_url_; | 117 GURL file_system_url_; |
| 125 | 118 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 147 IDMap<AsyncOpenFileCallback> pending_async_open_files_; | 140 IDMap<AsyncOpenFileCallback> pending_async_open_files_; |
| 148 | 141 |
| 149 base::WeakPtrFactory<PepperFileIOHost> weak_factory_; | 142 base::WeakPtrFactory<PepperFileIOHost> weak_factory_; |
| 150 | 143 |
| 151 DISALLOW_COPY_AND_ASSIGN(PepperFileIOHost); | 144 DISALLOW_COPY_AND_ASSIGN(PepperFileIOHost); |
| 152 }; | 145 }; |
| 153 | 146 |
| 154 } // namespace content | 147 } // namespace content |
| 155 | 148 |
| 156 #endif // CONTENT_RENDERER_PEPPER_PEPPER_FILE_IO_HOST_H_ | 149 #endif // CONTENT_RENDERER_PEPPER_PEPPER_FILE_IO_HOST_H_ |
| OLD | NEW |