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 PPAPI_PROXY_FILE_IO_RESOURCE_H_ |
| 6 #define PPAPI_PROXY_FILE_IO_RESOURCE_H_ |
| 7 |
| 8 #include "ppapi/proxy/connection.h" |
| 9 #include "ppapi/proxy/plugin_resource.h" |
| 10 #include "ppapi/proxy/ppapi_proxy_export.h" |
| 11 #include "ppapi/shared_impl/file_io_state_manager.h" |
| 12 #include "ppapi/thunk/ppb_file_io_api.h" |
| 13 |
| 14 namespace ppapi { |
| 15 |
| 16 class TrackedCallback; |
| 17 |
| 18 namespace proxy { |
| 19 |
| 20 class PPAPI_PROXY_EXPORT FileIOResource |
| 21 : public PluginResource, |
| 22 public thunk::PPB_FileIO_API { |
| 23 public: |
| 24 FileIOResource(Connection connection, PP_Instance instance); |
| 25 virtual ~FileIOResource(); |
| 26 |
| 27 // Resource overrides. |
| 28 virtual thunk::PPB_FileIO_API* AsPPB_FileIO_API() OVERRIDE; |
| 29 |
| 30 // PPB_FileIO_API implementation. |
| 31 virtual int32_t Open(PP_Resource file_ref, |
| 32 int32_t open_flags, |
| 33 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
| 34 virtual int32_t Query(PP_FileInfo* info, |
| 35 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
| 36 virtual int32_t Touch(PP_Time last_access_time, |
| 37 PP_Time last_modified_time, |
| 38 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
| 39 virtual int32_t Read(int64_t offset, |
| 40 char* buffer, |
| 41 int32_t bytes_to_read, |
| 42 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
| 43 virtual int32_t ReadToArray(int64_t offset, |
| 44 int32_t max_read_length, |
| 45 PP_ArrayOutput* array_output, |
| 46 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
| 47 virtual int32_t Write(int64_t offset, |
| 48 const char* buffer, |
| 49 int32_t bytes_to_write, |
| 50 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
| 51 virtual int32_t SetLength(int64_t length, |
| 52 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
| 53 virtual int32_t Flush(scoped_refptr<TrackedCallback> callback) OVERRIDE; |
| 54 virtual void Close() OVERRIDE; |
| 55 virtual int32_t GetOSFileDescriptor() OVERRIDE; |
| 56 virtual int32_t WillWrite(int64_t offset, |
| 57 int32_t bytes_to_write, |
| 58 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
| 59 virtual int32_t WillSetLength( |
| 60 int64_t length, |
| 61 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
| 62 |
| 63 private: |
| 64 int32_t ReadValidated(int64_t offset, |
| 65 int32_t bytes_to_read, |
| 66 const PP_ArrayOutput& array_output, |
| 67 scoped_refptr<TrackedCallback> callback); |
| 68 |
| 69 // Handlers of reply messages. Note that all of them have a callback |
| 70 // parameters bound when call to the host. |
| 71 void OnPluginMsgGeneralComplete(scoped_refptr<TrackedCallback> callback, |
| 72 const ResourceMessageReplyParams& params); |
| 73 void OnPluginMsgOpenFileComplete(scoped_refptr<TrackedCallback> callback, |
| 74 const ResourceMessageReplyParams& params); |
| 75 void OnPluginMsgQueryComplete(scoped_refptr<TrackedCallback> callback, |
| 76 PP_FileInfo* output_info_, |
| 77 const ResourceMessageReplyParams& params, |
| 78 const PP_FileInfo& info); |
| 79 void OnPluginMsgReadComplete(scoped_refptr<TrackedCallback> callback, |
| 80 PP_ArrayOutput array_output, |
| 81 const ResourceMessageReplyParams& params, |
| 82 const std::string& data); |
| 83 |
| 84 FileIOStateManager state_manager_; |
| 85 |
| 86 DISALLOW_COPY_AND_ASSIGN(FileIOResource); |
| 87 }; |
| 88 |
| 89 } // namespace proxy |
| 90 } // namespace ppapi |
| 91 |
| 92 #endif // PPAPI_PROXY_FILE_IO_RESOURCE_H_ |
OLD | NEW |