Chromium Code Reviews| Index: content/renderer/pepper/pepper_file_io_host.h |
| diff --git a/content/renderer/pepper/pepper_file_io_host.h b/content/renderer/pepper/pepper_file_io_host.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4d111c552d1249cb057957aee085414094ecb5f6 |
| --- /dev/null |
| +++ b/content/renderer/pepper/pepper_file_io_host.h |
| @@ -0,0 +1,161 @@ |
| +// 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 CONTENT_RENDERER_PEPPER_PEPPER_FILE_IO_HOST_H_ |
| +#define CONTENT_RENDERER_PEPPER_PEPPER_FILE_IO_HOST_H_ |
| + |
| +#include "base/basictypes.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "content/common/content_export.h" |
| +#include "content/public/renderer/renderer_ppapi_host.h" |
| +#include "ppapi/host/host_message_context.h" |
| +#include "ppapi/host/resource_host.h" |
| +#include "ppapi/shared_impl/ppb_file_io_shared.h" |
| +#include "ppapi/thunk/ppb_file_ref_api.h" |
| +#include "webkit/plugins/ppapi/plugin_delegate.h" |
| + |
| +using webkit::ppapi::PluginDelegate; |
| + |
| +namespace webkit { |
| +namespace ppapi { |
| +class QuotaFileIO; |
| +} // namespace ppapi |
| +} // namespace webkit |
| + |
| +namespace content { |
| + |
| +class CONTENT_EXPORT PepperFileIOHost |
|
raymes
2012/11/27 06:54:28
You probably don't need to export this (and so can
victorhsieh
2012/11/27 09:44:42
Done.
|
| + : public ppapi::host::ResourceHost, |
| + public ppapi::PPB_FileIO_Shared, |
| + public base::SupportsWeakPtr<PepperFileIOHost> { |
| + public: |
| + PepperFileIOHost(RendererPpapiHost* host, |
| + PP_Instance instance, |
| + PP_Resource resource); |
| + virtual ~PepperFileIOHost(); |
| + |
| + virtual int32_t OnResourceMessageReceived( |
|
raymes
2012/11/26 22:30:54
Add "ppapi::host::ResourceHost override"
victorhsieh
2012/11/27 09:44:42
Done.
|
| + const IPC::Message& msg, |
| + ppapi::host::HostMessageContext* context) OVERRIDE; |
| + |
| + private: |
| + int32_t OnHostMsgOpen( |
| + ppapi::host::HostMessageContext* context, |
|
raymes
2012/11/26 22:30:54
nit: please move this to the previous line and ind
victorhsieh
2012/11/27 09:44:42
Done.
|
| + PP_Resource file_ref_resource, |
| + int32_t open_flags); |
| + int32_t OnHostMsgQuery( |
| + ppapi::host::HostMessageContext* context); |
| + int32_t OnHostMsgTouch( |
| + ppapi::host::HostMessageContext* context, |
| + PP_Time last_access_time, |
| + PP_Time last_modified_time); |
| + int32_t OnHostMsgRead( |
| + ppapi::host::HostMessageContext* context, |
| + int64_t offset, |
| + int32_t bytes_to_read); |
| + int32_t OnHostMsgWrite( |
| + ppapi::host::HostMessageContext* context, |
| + int64_t offset, |
| + const std::string& buffer); |
| + int32_t OnHostMsgSetLength( |
| + ppapi::host::HostMessageContext* context, |
| + int64_t length); |
| + int32_t OnHostMsgClose( |
| + ppapi::host::HostMessageContext* context); |
| + int32_t OnHostMsgFlush( |
| + ppapi::host::HostMessageContext* context); |
| + // Trusted API. |
| + int32_t OnHostMsgWillWrite( |
| + ppapi::host::HostMessageContext* context, |
| + int64_t offset, |
| + int32_t bytes_to_write); |
| + int32_t OnHostMsgWillSetLength( |
| + ppapi::host::HostMessageContext* context, |
| + int64_t length); |
| + |
| + // PPB_FileIO_Shared implementations. |
| + virtual int32_t CommonPreCondition(bool should_be_open, |
| + OperationType new_op) OVERRIDE; |
| + virtual void CommonPostCondition(OperationType new_op) OVERRIDE; |
| + virtual int32_t OpenValidated(PP_Resource file_ref_resource, |
| + ppapi::thunk::PPB_FileRef_API* file_ref_api, |
| + int32_t open_flags) OVERRIDE; |
| + virtual int32_t QueryValidated() OVERRIDE; |
| + virtual int32_t TouchValidated(PP_Time last_access_time, |
| + PP_Time last_modified_time) OVERRIDE; |
| + virtual int32_t ReadValidated(int64_t offset, |
| + int32_t bytes_to_read) OVERRIDE; |
| + virtual int32_t WriteValidated(int64_t offset, |
| + const char* buffer, |
| + int32_t bytes_to_write) OVERRIDE; |
| + virtual int32_t SetLengthValidated(int64_t length) OVERRIDE; |
| + virtual int32_t FlushValidated() OVERRIDE; |
| + |
| + // Callback handlers. These mostly convert the PlatformFileError to the |
| + // PP_Error code and send back the reply. Note that the argument |
| + // ReplyMessageContext is copied so that we have a closure containing all |
| + // necessary information to reply. This enables the host to handle operations |
| + // statelessly and parallelly. |
|
raymes
2012/11/27 06:54:28
parallely -> in parallel
victorhsieh
2012/11/27 09:44:42
Done.
|
| + void ExecutePlatformGeneralCallback( |
| + ppapi::host::ReplyMessageContext reply_context, |
| + base::PlatformFileError error_code); |
| + void ExecutePlatformOpenFileCallback( |
| + ppapi::host::ReplyMessageContext reply_context, |
| + base::PlatformFileError error_code, |
| + base::PassPlatformFile file); |
| + void ExecutePlatformOpenFileSystemURLCallback( |
| + ppapi::host::ReplyMessageContext reply_context, |
| + base::PlatformFileError error_code, |
| + base::PassPlatformFile file, |
| + const PluginDelegate::NotifyCloseFileCallback& callback); |
| + void ExecutePlatformQueryCallback( |
| + ppapi::host::ReplyMessageContext reply_context, |
| + base::PlatformFileError error_code, |
| + const base::PlatformFileInfo& file_info); |
| + void ExecutePlatformReadCallback( |
| + ppapi::host::ReplyMessageContext reply_context, |
| + base::PlatformFileError error_code, |
| + const char* data, int bytes_read); |
| + void ExecutePlatformWriteCallback( |
| + ppapi::host::ReplyMessageContext reply_context, |
| + base::PlatformFileError error_code, |
| + int bytes_written); |
| + void ExecutePlatformWillWriteCallback( |
| + ppapi::host::ReplyMessageContext reply_context, |
| + base::PlatformFileError error_code, |
| + int bytes_written); |
| + |
| + webkit::ppapi::PluginDelegate* plugin_delegate_; // Not owned. |
| + |
| + base::PlatformFile file_; |
| + |
| + // 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_; |
| + |
| + // Valid only for PP_FILESYSTEMTYPE_LOCAL{PERSISTENT,TEMPORARY}. |
| + GURL file_system_url_; |
| + |
| + // Callback function for notifying when the file handle is closed. |
| + PluginDelegate::NotifyCloseFileCallback notify_close_file_callback_; |
| + |
| + // Pointer to a QuotaFileIO instance, which is valid only while a file |
| + // of type PP_FILESYSTEMTYPE_LOCAL{PERSISTENT,TEMPORARY} is opened. |
| + scoped_ptr<webkit::ppapi::QuotaFileIO> quota_file_io_; |
| + |
| + // A temporary storage just to pass a ReplyMessageContext from |
| + // OnHostMsg{OP} to {OP}Validated. It is a short-living data and must be |
|
raymes
2012/11/27 06:54:28
"It is a short-living" -> "It is short-living"
victorhsieh
2012/11/27 09:44:42
Done.
raymes
2012/11/27 16:41:30
Also this doesn't seem updated.
victorhsieh
2012/11/28 04:11:55
Oops, it's somehow got reverted. Done.
|
| + // copied in {OP}Validated immediately. In fact, it is copied to the |
| + // closure of platform operation callback via Bind. |
| + ppapi::host::ReplyMessageContext temp_reply_context_; |
| + |
| + base::WeakPtrFactory<PepperFileIOHost> weak_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(PepperFileIOHost); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_RENDERER_PEPPER_PEPPER_FILE_IO_HOST_H_ |