| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 WEBKIT_PLUGINS_PPAPI_PPB_FILE_IO_IMPL_H_ | 5 #ifndef WEBKIT_PLUGINS_PPAPI_PPB_FILE_IO_IMPL_H_ |
| 6 #define WEBKIT_PLUGINS_PPAPI_PPB_FILE_IO_IMPL_H_ | 6 #define WEBKIT_PLUGINS_PPAPI_PPB_FILE_IO_IMPL_H_ |
| 7 | 7 |
| 8 #include <queue> | 8 #include <queue> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_callback_factory.h" | 13 #include "base/memory/scoped_callback_factory.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/platform_file.h" | 15 #include "base/platform_file.h" |
| 16 #include "ppapi/c/pp_file_info.h" | 16 #include "ppapi/c/pp_file_info.h" |
| 17 #include "ppapi/c/pp_time.h" | 17 #include "ppapi/c/pp_time.h" |
| 18 #include "ppapi/shared_impl/resource.h" |
| 18 #include "ppapi/thunk/ppb_file_io_api.h" | 19 #include "ppapi/thunk/ppb_file_io_api.h" |
| 19 #include "webkit/plugins/ppapi/callbacks.h" | 20 #include "webkit/plugins/ppapi/callbacks.h" |
| 20 #include "webkit/plugins/ppapi/plugin_delegate.h" | 21 #include "webkit/plugins/ppapi/plugin_delegate.h" |
| 21 #include "webkit/plugins/ppapi/resource.h" | |
| 22 | 22 |
| 23 struct PP_CompletionCallback; | 23 struct PP_CompletionCallback; |
| 24 struct PPB_FileIO; | 24 struct PPB_FileIO; |
| 25 struct PPB_FileIOTrusted; | 25 struct PPB_FileIOTrusted; |
| 26 | 26 |
| 27 namespace webkit { | 27 namespace webkit { |
| 28 namespace ppapi { | 28 namespace ppapi { |
| 29 | 29 |
| 30 class PluginModule; | 30 class PluginModule; |
| 31 class PPB_FileRef_Impl; | 31 class PPB_FileRef_Impl; |
| 32 class QuotaFileIO; | 32 class QuotaFileIO; |
| 33 | 33 |
| 34 class PPB_FileIO_Impl : public Resource, | 34 class PPB_FileIO_Impl : public ::ppapi::Resource, |
| 35 public ::ppapi::thunk::PPB_FileIO_API { | 35 public ::ppapi::thunk::PPB_FileIO_API { |
| 36 public: | 36 public: |
| 37 explicit PPB_FileIO_Impl(PluginInstance* instance); | 37 explicit PPB_FileIO_Impl(PP_Instance instance); |
| 38 virtual ~PPB_FileIO_Impl(); | 38 virtual ~PPB_FileIO_Impl(); |
| 39 | 39 |
| 40 // Resource overrides. | 40 // Resource overrides. |
| 41 virtual ::ppapi::thunk::PPB_FileIO_API* AsPPB_FileIO_API() OVERRIDE; | 41 virtual ::ppapi::thunk::PPB_FileIO_API* AsPPB_FileIO_API() OVERRIDE; |
| 42 | 42 |
| 43 // PPB_FileIO_API implementation. | 43 // PPB_FileIO_API implementation. |
| 44 virtual int32_t Open(PP_Resource file_ref, | 44 virtual int32_t Open(PP_Resource file_ref, |
| 45 int32_t open_flags, | 45 int32_t open_flags, |
| 46 PP_CompletionCallback callback) OVERRIDE; | 46 PP_CompletionCallback callback) OVERRIDE; |
| 47 virtual int32_t Query(PP_FileInfo* info, | 47 virtual int32_t Query(PP_FileInfo* info, |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 void StatusCallback(base::PlatformFileError error_code); | 117 void StatusCallback(base::PlatformFileError error_code); |
| 118 void AsyncOpenFileCallback(base::PlatformFileError error_code, | 118 void AsyncOpenFileCallback(base::PlatformFileError error_code, |
| 119 base::PassPlatformFile file); | 119 base::PassPlatformFile file); |
| 120 void QueryInfoCallback(base::PlatformFileError error_code, | 120 void QueryInfoCallback(base::PlatformFileError error_code, |
| 121 const base::PlatformFileInfo& file_info); | 121 const base::PlatformFileInfo& file_info); |
| 122 void ReadCallback(base::PlatformFileError error_code, | 122 void ReadCallback(base::PlatformFileError error_code, |
| 123 const char* data, int bytes_read); | 123 const char* data, int bytes_read); |
| 124 void WriteCallback(base::PlatformFileError error_code, int bytes_written); | 124 void WriteCallback(base::PlatformFileError error_code, int bytes_written); |
| 125 void WillWriteCallback(base::PlatformFileError error_code, int bytes_written); | 125 void WillWriteCallback(base::PlatformFileError error_code, int bytes_written); |
| 126 | 126 |
| 127 PluginDelegate* GetPluginDelegate() const; |
| 128 |
| 127 base::ScopedCallbackFactory<PPB_FileIO_Impl> callback_factory_; | 129 base::ScopedCallbackFactory<PPB_FileIO_Impl> callback_factory_; |
| 128 | 130 |
| 129 base::PlatformFile file_; | 131 base::PlatformFile file_; |
| 130 PP_FileSystemType file_system_type_; | 132 PP_FileSystemType file_system_type_; |
| 131 | 133 |
| 132 // Valid only for PP_FILESYSTEMTYPE_LOCAL{PERSISTENT,TEMPORARY}. | 134 // Valid only for PP_FILESYSTEMTYPE_LOCAL{PERSISTENT,TEMPORARY}. |
| 133 GURL file_system_url_; | 135 GURL file_system_url_; |
| 134 | 136 |
| 135 std::queue<CallbackEntry> callbacks_; | 137 std::queue<CallbackEntry> callbacks_; |
| 136 OperationType pending_op_; | 138 OperationType pending_op_; |
| 137 | 139 |
| 138 // Output buffer pointer for |Query()|; only non-null when a callback is | 140 // Output buffer pointer for |Query()|; only non-null when a callback is |
| 139 // pending for it. | 141 // pending for it. |
| 140 PP_FileInfo* info_; | 142 PP_FileInfo* info_; |
| 141 | 143 |
| 142 // Pointer to a QuotaFileIO instance, which is valid only while a file | 144 // Pointer to a QuotaFileIO instance, which is valid only while a file |
| 143 // of type PP_FILESYSTEMTYPE_LOCAL{PERSISTENT,TEMPORARY} is opened. | 145 // of type PP_FILESYSTEMTYPE_LOCAL{PERSISTENT,TEMPORARY} is opened. |
| 144 scoped_ptr<QuotaFileIO> quota_file_io_; | 146 scoped_ptr<QuotaFileIO> quota_file_io_; |
| 145 | 147 |
| 146 DISALLOW_COPY_AND_ASSIGN(PPB_FileIO_Impl); | 148 DISALLOW_COPY_AND_ASSIGN(PPB_FileIO_Impl); |
| 147 }; | 149 }; |
| 148 | 150 |
| 149 } // namespace ppapi | 151 } // namespace ppapi |
| 150 } // namespace webkit | 152 } // namespace webkit |
| 151 | 153 |
| 152 #endif // WEBKIT_PLUGINS_PPAPI_PPB_FILE_IO_IMPL_H_ | 154 #endif // WEBKIT_PLUGINS_PPAPI_PPB_FILE_IO_IMPL_H_ |
| OLD | NEW |