| 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" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 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 | 33 |
| 33 class PPB_FileIO_Impl : public Resource, | 34 class PPB_FileIO_Impl : public Resource, |
| 34 public ::ppapi::thunk::PPB_FileIO_API { | 35 public ::ppapi::thunk::PPB_FileIO_API { |
| 35 public: | 36 public: |
| 36 explicit PPB_FileIO_Impl(PluginInstance* instance); | 37 explicit PPB_FileIO_Impl(PluginInstance* instance); |
| 37 virtual ~PPB_FileIO_Impl(); | 38 virtual ~PPB_FileIO_Impl(); |
| 38 | 39 |
| 39 // ResourceObjectBase overrides. | 40 // ResourceObjectBase overrides. |
| 40 virtual ::ppapi::thunk::PPB_FileIO_API* AsPPB_FileIO_API() OVERRIDE; | 41 virtual ::ppapi::thunk::PPB_FileIO_API* AsPPB_FileIO_API() OVERRIDE; |
| 41 | 42 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 67 virtual int32_t WillSetLength(int64_t length, | 68 virtual int32_t WillSetLength(int64_t length, |
| 68 PP_CompletionCallback callback) OVERRIDE; | 69 PP_CompletionCallback callback) OVERRIDE; |
| 69 | 70 |
| 70 private: | 71 private: |
| 71 struct CallbackEntry { | 72 struct CallbackEntry { |
| 72 CallbackEntry(); | 73 CallbackEntry(); |
| 73 CallbackEntry(const CallbackEntry& entry); | 74 CallbackEntry(const CallbackEntry& entry); |
| 74 ~CallbackEntry(); | 75 ~CallbackEntry(); |
| 75 | 76 |
| 76 scoped_refptr<TrackedCompletionCallback> callback; | 77 scoped_refptr<TrackedCompletionCallback> callback; |
| 78 |
| 77 // Pointer back to the caller's read buffer; only used by |Read()|. | 79 // Pointer back to the caller's read buffer; only used by |Read()|. |
| 78 // Not owned. | 80 // Not owned. |
| 79 char* read_buffer; | 81 char* read_buffer; |
| 80 }; | 82 }; |
| 81 | 83 |
| 82 enum OperationType { | 84 enum OperationType { |
| 83 // If there are pending reads, any other kind of async operation is not | 85 // If there are pending reads, any other kind of async operation is not |
| 84 // allowed. | 86 // allowed. |
| 85 OPERATION_READ, | 87 OPERATION_READ, |
| 86 // If there are pending writes, any other kind of async operation is not | 88 // If there are pending writes, any other kind of async operation is not |
| (...skipping 15 matching lines...) Expand all Loading... |
| 102 // the call should be aborted and that code returned to the plugin. | 104 // the call should be aborted and that code returned to the plugin. |
| 103 int32_t CommonCallValidation(bool should_be_open, | 105 int32_t CommonCallValidation(bool should_be_open, |
| 104 OperationType new_op, | 106 OperationType new_op, |
| 105 PP_CompletionCallback callback); | 107 PP_CompletionCallback callback); |
| 106 | 108 |
| 107 // Sets up a pending callback. This should only be called once it is certain | 109 // Sets up a pending callback. This should only be called once it is certain |
| 108 // that |PP_OK_COMPLETIONPENDING| will be returned. | 110 // that |PP_OK_COMPLETIONPENDING| will be returned. |
| 109 // |read_buffer| is only used by read operations. | 111 // |read_buffer| is only used by read operations. |
| 110 void RegisterCallback(OperationType op, | 112 void RegisterCallback(OperationType op, |
| 111 PP_CompletionCallback callback, | 113 PP_CompletionCallback callback, |
| 112 char* rend_buffer); | 114 char* read_buffer); |
| 113 | |
| 114 void RunAndRemoveFirstPendingCallback(int32_t result); | 115 void RunAndRemoveFirstPendingCallback(int32_t result); |
| 115 | 116 |
| 116 void StatusCallback(base::PlatformFileError error_code); | 117 void StatusCallback(base::PlatformFileError error_code); |
| 117 void AsyncOpenFileCallback(base::PlatformFileError error_code, | 118 void AsyncOpenFileCallback(base::PlatformFileError error_code, |
| 118 base::PassPlatformFile file); | 119 base::PassPlatformFile file); |
| 119 void QueryInfoCallback(base::PlatformFileError error_code, | 120 void QueryInfoCallback(base::PlatformFileError error_code, |
| 120 const base::PlatformFileInfo& file_info); | 121 const base::PlatformFileInfo& file_info); |
| 121 void ReadCallback(base::PlatformFileError error_code, | 122 void ReadCallback(base::PlatformFileError error_code, |
| 122 const char* data, int bytes_read); | 123 const char* data, int bytes_read); |
| 123 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); |
| 124 | 126 |
| 125 base::ScopedCallbackFactory<PPB_FileIO_Impl> callback_factory_; | 127 base::ScopedCallbackFactory<PPB_FileIO_Impl> callback_factory_; |
| 126 | 128 |
| 127 base::PlatformFile file_; | 129 base::PlatformFile file_; |
| 128 PP_FileSystemType file_system_type_; | 130 PP_FileSystemType file_system_type_; |
| 129 | 131 |
| 132 // Valid only for PP_FILESYSTEMTYPE_LOCAL{PERSISTENT,TEMPORARY}. |
| 133 GURL file_system_url_; |
| 134 |
| 130 std::queue<CallbackEntry> callbacks_; | 135 std::queue<CallbackEntry> callbacks_; |
| 131 OperationType pending_op_; | 136 OperationType pending_op_; |
| 132 | 137 |
| 133 // Output buffer pointer for |Query()|; only non-null when a callback is | 138 // Output buffer pointer for |Query()|; only non-null when a callback is |
| 134 // pending for it. | 139 // pending for it. |
| 135 PP_FileInfo* info_; | 140 PP_FileInfo* info_; |
| 136 | 141 |
| 142 // Pointer to a QuotaFileIO instance, which is valid only while a file |
| 143 // of type PP_FILESYSTEMTYPE_LOCAL{PERSISTENT,TEMPORARY} is opened. |
| 144 scoped_ptr<QuotaFileIO> quota_file_io_; |
| 145 |
| 137 DISALLOW_COPY_AND_ASSIGN(PPB_FileIO_Impl); | 146 DISALLOW_COPY_AND_ASSIGN(PPB_FileIO_Impl); |
| 138 }; | 147 }; |
| 139 | 148 |
| 140 } // namespace ppapi | 149 } // namespace ppapi |
| 141 } // namespace webkit | 150 } // namespace webkit |
| 142 | 151 |
| 143 #endif // WEBKIT_PLUGINS_PPAPI_PPB_FILE_IO_IMPL_H_ | 152 #endif // WEBKIT_PLUGINS_PPAPI_PPB_FILE_IO_IMPL_H_ |
| OLD | NEW |