| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "ppapi/shared_impl/ppb_file_io_shared.h" | 13 #include "ppapi/shared_impl/ppb_file_io_shared.h" |
| 14 #include "webkit/plugins/ppapi/plugin_delegate.h" | 14 #include "webkit/plugins/ppapi/plugin_delegate.h" |
| 15 | 15 |
| 16 struct PP_CompletionCallback; | |
| 17 | |
| 18 namespace webkit { | 16 namespace webkit { |
| 19 namespace ppapi { | 17 namespace ppapi { |
| 20 | 18 |
| 21 class QuotaFileIO; | 19 class QuotaFileIO; |
| 22 | 20 |
| 23 class PPB_FileIO_Impl : public ::ppapi::PPB_FileIO_Shared { | 21 class PPB_FileIO_Impl : public ::ppapi::PPB_FileIO_Shared { |
| 24 public: | 22 public: |
| 25 explicit PPB_FileIO_Impl(PP_Instance instance); | 23 explicit PPB_FileIO_Impl(PP_Instance instance); |
| 26 virtual ~PPB_FileIO_Impl(); | 24 virtual ~PPB_FileIO_Impl(); |
| 27 | 25 |
| 28 // PPB_FileIO_API implementation (most of the operations are implemented | 26 // PPB_FileIO_API implementation (most of the operations are implemented |
| 29 // as the "Validated" versions below). | 27 // as the "Validated" versions below). |
| 30 virtual void Close() OVERRIDE; | 28 virtual void Close() OVERRIDE; |
| 31 virtual int32_t GetOSFileDescriptor() OVERRIDE; | 29 virtual int32_t GetOSFileDescriptor() OVERRIDE; |
| 32 virtual int32_t WillWrite(int64_t offset, | 30 virtual int32_t WillWrite(int64_t offset, |
| 33 int32_t bytes_to_write, | 31 int32_t bytes_to_write, |
| 34 PP_CompletionCallback callback) OVERRIDE; | 32 ::ppapi::ApiCallbackType callback) OVERRIDE; |
| 35 virtual int32_t WillSetLength(int64_t length, | 33 virtual int32_t WillSetLength(int64_t length, |
| 36 PP_CompletionCallback callback) OVERRIDE; | 34 ::ppapi::ApiCallbackType callback) OVERRIDE; |
| 37 | 35 |
| 38 private: | 36 private: |
| 39 // FileIOImpl overrides. | 37 // FileIOImpl overrides. |
| 40 virtual int32_t OpenValidated(PP_Resource file_ref_resource, | 38 virtual int32_t OpenValidated(PP_Resource file_ref_resource, |
| 41 ::ppapi::thunk::PPB_FileRef_API* file_ref_api, | 39 ::ppapi::thunk::PPB_FileRef_API* file_ref_api, |
| 42 int32_t open_flags, | 40 int32_t open_flags, |
| 43 PP_CompletionCallback callback) OVERRIDE; | 41 ::ppapi::ApiCallbackType callback) OVERRIDE; |
| 44 virtual int32_t QueryValidated(PP_FileInfo* info, | 42 virtual int32_t QueryValidated(PP_FileInfo* info, |
| 45 PP_CompletionCallback callback) OVERRIDE; | 43 ::ppapi::ApiCallbackType callback) OVERRIDE; |
| 46 virtual int32_t TouchValidated(PP_Time last_access_time, | 44 virtual int32_t TouchValidated(PP_Time last_access_time, |
| 47 PP_Time last_modified_time, | 45 PP_Time last_modified_time, |
| 48 PP_CompletionCallback callback) OVERRIDE; | 46 ::ppapi::ApiCallbackType callback) OVERRIDE; |
| 49 virtual int32_t ReadValidated(int64_t offset, | 47 virtual int32_t ReadValidated(int64_t offset, |
| 50 char* buffer, | 48 char* buffer, |
| 51 int32_t bytes_to_read, | 49 int32_t bytes_to_read, |
| 52 PP_CompletionCallback callback) OVERRIDE; | 50 ::ppapi::ApiCallbackType callback) OVERRIDE; |
| 53 virtual int32_t WriteValidated(int64_t offset, | 51 virtual int32_t WriteValidated(int64_t offset, |
| 54 const char* buffer, | 52 const char* buffer, |
| 55 int32_t bytes_to_write, | 53 int32_t bytes_to_write, |
| 56 PP_CompletionCallback callback) OVERRIDE; | 54 ::ppapi::ApiCallbackType callback) OVERRIDE; |
| 57 virtual int32_t SetLengthValidated(int64_t length, | 55 virtual int32_t SetLengthValidated( |
| 58 PP_CompletionCallback callback) OVERRIDE; | 56 int64_t length, |
| 59 virtual int32_t FlushValidated(PP_CompletionCallback callback) OVERRIDE; | 57 ::ppapi::ApiCallbackType callback) OVERRIDE; |
| 58 virtual int32_t FlushValidated(::ppapi::ApiCallbackType callback) OVERRIDE; |
| 60 | 59 |
| 61 // Returns the plugin delegate for this resource if it exists, or NULL if it | 60 // Returns the plugin delegate for this resource if it exists, or NULL if it |
| 62 // doesn't. Calling code should always check for NULL. | 61 // doesn't. Calling code should always check for NULL. |
| 63 PluginDelegate* GetPluginDelegate(); | 62 PluginDelegate* GetPluginDelegate(); |
| 64 | 63 |
| 65 // Callback handlers. These mostly convert the PlatformFileError to the | 64 // Callback handlers. These mostly convert the PlatformFileError to the |
| 66 // PP_Error code and call the shared (non-"Platform") version. | 65 // PP_Error code and call the shared (non-"Platform") version. |
| 67 void ExecutePlatformGeneralCallback(base::PlatformFileError error_code); | 66 void ExecutePlatformGeneralCallback(base::PlatformFileError error_code); |
| 68 void ExecutePlatformOpenFileCallback(base::PlatformFileError error_code, | 67 void ExecutePlatformOpenFileCallback(base::PlatformFileError error_code, |
| 69 base::PassPlatformFile file); | 68 base::PassPlatformFile file); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 87 | 86 |
| 88 base::WeakPtrFactory<PPB_FileIO_Impl> weak_factory_; | 87 base::WeakPtrFactory<PPB_FileIO_Impl> weak_factory_; |
| 89 | 88 |
| 90 DISALLOW_COPY_AND_ASSIGN(PPB_FileIO_Impl); | 89 DISALLOW_COPY_AND_ASSIGN(PPB_FileIO_Impl); |
| 91 }; | 90 }; |
| 92 | 91 |
| 93 } // namespace ppapi | 92 } // namespace ppapi |
| 94 } // namespace webkit | 93 } // namespace webkit |
| 95 | 94 |
| 96 #endif // WEBKIT_PLUGINS_PPAPI_PPB_FILE_IO_IMPL_H_ | 95 #endif // WEBKIT_PLUGINS_PPAPI_PPB_FILE_IO_IMPL_H_ |
| OLD | NEW |