Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_FILE_IO_HOST_H_ | |
| 6 #define CONTENT_RENDERER_PEPPER_PEPPER_FILE_IO_HOST_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/memory/weak_ptr.h" | |
| 12 #include "content/public/renderer/renderer_ppapi_host.h" | |
| 13 #include "ppapi/host/host_message_context.h" | |
| 14 #include "ppapi/host/resource_host.h" | |
| 15 #include "ppapi/shared_impl/ppb_file_io_shared.h" | |
| 16 #include "ppapi/thunk/ppb_file_ref_api.h" | |
| 17 #include "webkit/plugins/ppapi/plugin_delegate.h" | |
| 18 | |
| 19 using ppapi::host::ReplyMessageContext; | |
| 20 using webkit::ppapi::PluginDelegate; | |
| 21 | |
| 22 namespace webkit { | |
| 23 namespace ppapi { | |
| 24 class QuotaFileIO; | |
| 25 } // namespace ppapi | |
| 26 } // namespace webkit | |
| 27 | |
| 28 namespace content { | |
| 29 | |
| 30 class PepperFileIOHost : public ppapi::host::ResourceHost, | |
| 31 public ppapi::PPB_FileIO_Shared, | |
|
raymes
2012/11/28 18:39:35
We want to remove this as a base class. I think it
victorhsieh
2012/11/29 06:34:55
Done.
| |
| 32 public base::SupportsWeakPtr<PepperFileIOHost> { | |
| 33 public: | |
| 34 PepperFileIOHost(RendererPpapiHost* host, | |
| 35 PP_Instance instance, | |
| 36 PP_Resource resource); | |
| 37 virtual ~PepperFileIOHost(); | |
| 38 | |
| 39 // ppapi::host::ResourceHost override. | |
| 40 virtual int32_t OnResourceMessageReceived( | |
| 41 const IPC::Message& msg, | |
| 42 ppapi::host::HostMessageContext* context) OVERRIDE; | |
| 43 | |
| 44 private: | |
| 45 int32_t OnHostMsgOpen(ppapi::host::HostMessageContext* context, | |
| 46 PP_Resource file_ref_resource, | |
| 47 int32_t open_flags); | |
| 48 int32_t OnHostMsgQuery(ppapi::host::HostMessageContext* context); | |
| 49 int32_t OnHostMsgTouch(ppapi::host::HostMessageContext* context, | |
| 50 PP_Time last_access_time, | |
| 51 PP_Time last_modified_time); | |
| 52 int32_t OnHostMsgRead(ppapi::host::HostMessageContext* context, | |
| 53 int64_t offset, | |
| 54 int32_t bytes_to_read); | |
| 55 int32_t OnHostMsgWrite(ppapi::host::HostMessageContext* context, | |
| 56 int64_t offset, | |
| 57 const std::string& buffer); | |
| 58 int32_t OnHostMsgSetLength(ppapi::host::HostMessageContext* context, | |
| 59 int64_t length); | |
| 60 int32_t OnHostMsgClose(ppapi::host::HostMessageContext* context); | |
| 61 int32_t OnHostMsgFlush(ppapi::host::HostMessageContext* context); | |
| 62 // Trusted API. | |
| 63 int32_t OnHostMsgGetOSFileDescriptor( | |
| 64 ppapi::host::HostMessageContext* context); | |
| 65 int32_t OnHostMsgWillWrite(ppapi::host::HostMessageContext* context, | |
| 66 int64_t offset, | |
| 67 int32_t bytes_to_write); | |
| 68 int32_t OnHostMsgWillSetLength(ppapi::host::HostMessageContext* context, | |
| 69 int64_t length); | |
| 70 | |
| 71 int32_t OpenValidated(const ReplyMessageContext& reply_context, | |
|
raymes
2012/11/28 18:39:35
We want to remove these "validated" functions
victorhsieh
2012/11/29 06:34:55
Done.
| |
| 72 ppapi::thunk::PPB_FileRef_API* file_ref_api, | |
| 73 int32_t open_flags); | |
| 74 int32_t QueryValidated(const ReplyMessageContext&); | |
| 75 int32_t TouchValidated(const ReplyMessageContext& reply_context, | |
| 76 PP_Time last_access_time, | |
| 77 PP_Time last_modified_time); | |
| 78 int32_t ReadValidated(const ReplyMessageContext& reply_context, | |
| 79 int64_t offset, | |
| 80 int32_t bytes_to_read); | |
| 81 int32_t WriteValidated(const ReplyMessageContext& reply_context, | |
| 82 int64_t offset, | |
| 83 const char* buffer, | |
| 84 int32_t bytes_to_write); | |
| 85 int32_t SetLengthValidated(const ReplyMessageContext& reply_context, | |
| 86 int64_t length); | |
| 87 int32_t FlushValidated(const ReplyMessageContext& reply_context); | |
| 88 | |
| 89 // Callback handlers. These mostly convert the PlatformFileError to the | |
| 90 // PP_Error code and send back the reply. Note that the argument | |
| 91 // ReplyMessageContext is copied so that we have a closure containing all | |
| 92 // necessary information to reply. | |
| 93 void ExecutePlatformGeneralCallback( | |
|
raymes
2012/11/29 00:50:58
We should be able to fit the first argument on the
victorhsieh
2012/11/29 06:34:55
Done.
| |
| 94 ReplyMessageContext reply_context, | |
| 95 base::PlatformFileError error_code); | |
| 96 void ExecutePlatformOpenFileCallback( | |
| 97 ReplyMessageContext reply_context, | |
| 98 base::PlatformFileError error_code, | |
| 99 base::PassPlatformFile file); | |
| 100 void ExecutePlatformOpenFileSystemURLCallback( | |
| 101 ReplyMessageContext reply_context, | |
| 102 base::PlatformFileError error_code, | |
| 103 base::PassPlatformFile file, | |
| 104 const PluginDelegate::NotifyCloseFileCallback& callback); | |
| 105 void ExecutePlatformQueryCallback( | |
| 106 ReplyMessageContext reply_context, | |
| 107 base::PlatformFileError error_code, | |
| 108 const base::PlatformFileInfo& file_info); | |
| 109 void ExecutePlatformReadCallback( | |
| 110 ReplyMessageContext reply_context, | |
| 111 base::PlatformFileError error_code, | |
| 112 const char* data, int bytes_read); | |
| 113 void ExecutePlatformWriteCallback( | |
| 114 ReplyMessageContext reply_context, | |
| 115 base::PlatformFileError error_code, | |
| 116 int bytes_written); | |
| 117 void ExecutePlatformWillWriteCallback( | |
| 118 ReplyMessageContext reply_context, | |
| 119 base::PlatformFileError error_code, | |
| 120 int bytes_written); | |
| 121 | |
| 122 // TODO(victorhsieh): eliminate plugin_delegate_ as it's no longer needed. | |
| 123 webkit::ppapi::PluginDelegate* plugin_delegate_; // Not owned. | |
| 124 | |
| 125 base::PlatformFile file_; | |
| 126 | |
| 127 // The file system type specified in the Open() call. This will be | |
| 128 // PP_FILESYSTEMTYPE_INVALID before open was called. This value does not | |
| 129 // indicate that the open command actually succeeded. | |
| 130 PP_FileSystemType file_system_type_; | |
| 131 | |
| 132 // Valid only for PP_FILESYSTEMTYPE_LOCAL{PERSISTENT,TEMPORARY}. | |
| 133 GURL file_system_url_; | |
| 134 | |
| 135 // Callback function for notifying when the file handle is closed. | |
| 136 PluginDelegate::NotifyCloseFileCallback notify_close_file_callback_; | |
| 137 | |
| 138 // Pointer to a QuotaFileIO instance, which is valid only while a file | |
| 139 // of type PP_FILESYSTEMTYPE_LOCAL{PERSISTENT,TEMPORARY} is opened. | |
| 140 scoped_ptr<webkit::ppapi::QuotaFileIO> quota_file_io_; | |
| 141 | |
| 142 base::WeakPtrFactory<PepperFileIOHost> weak_factory_; | |
| 143 | |
| 144 DISALLOW_COPY_AND_ASSIGN(PepperFileIOHost); | |
| 145 }; | |
| 146 | |
| 147 } // namespace content | |
| 148 | |
| 149 #endif // CONTENT_RENDERER_PEPPER_PEPPER_FILE_IO_HOST_H_ | |
| OLD | NEW |