| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2010 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 WEBKIT_GLUE_PLUGINS_PEPPER_FILE_IO_H_ | |
| 6 #define WEBKIT_GLUE_PLUGINS_PEPPER_FILE_IO_H_ | |
| 7 | |
| 8 #include "base/file_path.h" | |
| 9 #include "base/platform_file.h" | |
| 10 #include "base/scoped_callback_factory.h" | |
| 11 #include "base/scoped_ptr.h" | |
| 12 #include "ppapi/c/dev/pp_file_info_dev.h" | |
| 13 #include "ppapi/c/pp_completion_callback.h" | |
| 14 #include "ppapi/c/pp_time.h" | |
| 15 #include "webkit/glue/plugins/pepper_plugin_delegate.h" | |
| 16 #include "webkit/glue/plugins/pepper_resource.h" | |
| 17 | |
| 18 struct PP_CompletionCallback; | |
| 19 struct PPB_FileIO_Dev; | |
| 20 struct PPB_FileIOTrusted_Dev; | |
| 21 | |
| 22 namespace pepper { | |
| 23 | |
| 24 class PluginModule; | |
| 25 | |
| 26 class FileIO : public Resource { | |
| 27 public: | |
| 28 explicit FileIO(PluginModule* module); | |
| 29 virtual ~FileIO(); | |
| 30 | |
| 31 // Returns a pointer to the interface implementing PPB_FileIO that is exposed | |
| 32 // to the plugin. | |
| 33 static const PPB_FileIO_Dev* GetInterface(); | |
| 34 | |
| 35 // Returns a pointer to the interface implementing PPB_FileIOTrusted that is | |
| 36 // exposed to the plugin. | |
| 37 static const PPB_FileIOTrusted_Dev* GetTrustedInterface(); | |
| 38 | |
| 39 // Resource overrides. | |
| 40 virtual FileIO* AsFileIO(); | |
| 41 | |
| 42 // PPB_FileIO implementation. | |
| 43 int32_t Open(FileRef* file_ref, | |
| 44 int32_t open_flags, | |
| 45 PP_CompletionCallback callback); | |
| 46 int32_t Query(PP_FileInfo_Dev* info, | |
| 47 PP_CompletionCallback callback); | |
| 48 int32_t Touch(PP_Time last_access_time, | |
| 49 PP_Time last_modified_time, | |
| 50 PP_CompletionCallback callback); | |
| 51 int32_t Read(int64_t offset, | |
| 52 char* buffer, | |
| 53 int32_t bytes_to_read, | |
| 54 PP_CompletionCallback callback); | |
| 55 int32_t Write(int64_t offset, | |
| 56 const char* buffer, | |
| 57 int32_t bytes_to_write, | |
| 58 PP_CompletionCallback callback); | |
| 59 int32_t SetLength(int64_t length, | |
| 60 PP_CompletionCallback callback); | |
| 61 int32_t Flush(PP_CompletionCallback callback); | |
| 62 void Close(); | |
| 63 | |
| 64 // PPB_FileIOTrusted implementation. | |
| 65 int32_t GetOSFileDescriptor(); | |
| 66 int32_t WillWrite(int64_t offset, | |
| 67 int32_t bytes_to_write, | |
| 68 PP_CompletionCallback callback); | |
| 69 int32_t WillSetLength(int64_t length, | |
| 70 PP_CompletionCallback callback); | |
| 71 | |
| 72 void RunPendingCallback(int result); | |
| 73 void StatusCallback(base::PlatformFileError error_code); | |
| 74 void AsyncOpenFileCallback(base::PlatformFileError error_code, | |
| 75 base::PlatformFile file); | |
| 76 void QueryInfoCallback(base::PlatformFileError error_code, | |
| 77 const base::PlatformFileInfo& file_info); | |
| 78 void ReadWriteCallback(base::PlatformFileError error_code, | |
| 79 int bytes_read_or_written); | |
| 80 | |
| 81 private: | |
| 82 PluginDelegate* delegate_; | |
| 83 base::ScopedCallbackFactory<FileIO> callback_factory_; | |
| 84 | |
| 85 base::PlatformFile file_; | |
| 86 PP_FileSystemType_Dev file_system_type_; | |
| 87 | |
| 88 PP_CompletionCallback callback_; | |
| 89 PP_FileInfo_Dev* info_; | |
| 90 }; | |
| 91 | |
| 92 } // namespace pepper | |
| 93 | |
| 94 #endif // WEBKIT_GLUE_PLUGINS_PEPPER_FILE_IO_H_ | |
| OLD | NEW |