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( |
33 int32_t bytes_to_write, | 31 int64_t offset, |
34 PP_CompletionCallback callback) OVERRIDE; | 32 int32_t bytes_to_write, |
35 virtual int32_t WillSetLength(int64_t length, | 33 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE; |
36 PP_CompletionCallback callback) OVERRIDE; | 34 virtual int32_t WillSetLength( |
| 35 int64_t length, |
| 36 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE; |
37 | 37 |
38 private: | 38 private: |
39 // FileIOImpl overrides. | 39 // FileIOImpl overrides. |
40 virtual int32_t OpenValidated(PP_Resource file_ref_resource, | 40 virtual int32_t OpenValidated( |
41 ::ppapi::thunk::PPB_FileRef_API* file_ref_api, | 41 PP_Resource file_ref_resource, |
42 int32_t open_flags, | 42 ::ppapi::thunk::PPB_FileRef_API* file_ref_api, |
43 PP_CompletionCallback callback) OVERRIDE; | 43 int32_t open_flags, |
44 virtual int32_t QueryValidated(PP_FileInfo* info, | 44 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE; |
45 PP_CompletionCallback callback) OVERRIDE; | 45 virtual int32_t QueryValidated( |
46 virtual int32_t TouchValidated(PP_Time last_access_time, | 46 PP_FileInfo* info, |
47 PP_Time last_modified_time, | 47 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE; |
48 PP_CompletionCallback callback) OVERRIDE; | 48 virtual int32_t TouchValidated( |
49 virtual int32_t ReadValidated(int64_t offset, | 49 PP_Time last_access_time, |
50 char* buffer, | 50 PP_Time last_modified_time, |
51 int32_t bytes_to_read, | 51 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE; |
52 PP_CompletionCallback callback) OVERRIDE; | 52 virtual int32_t ReadValidated( |
53 virtual int32_t WriteValidated(int64_t offset, | 53 int64_t offset, |
54 const char* buffer, | 54 char* buffer, |
55 int32_t bytes_to_write, | 55 int32_t bytes_to_read, |
56 PP_CompletionCallback callback) OVERRIDE; | 56 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE; |
57 virtual int32_t SetLengthValidated(int64_t length, | 57 virtual int32_t WriteValidated( |
58 PP_CompletionCallback callback) OVERRIDE; | 58 int64_t offset, |
59 virtual int32_t FlushValidated(PP_CompletionCallback callback) OVERRIDE; | 59 const char* buffer, |
| 60 int32_t bytes_to_write, |
| 61 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE; |
| 62 virtual int32_t SetLengthValidated( |
| 63 int64_t length, |
| 64 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE; |
| 65 virtual int32_t FlushValidated( |
| 66 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE; |
60 | 67 |
61 // Returns the plugin delegate for this resource if it exists, or NULL if it | 68 // Returns the plugin delegate for this resource if it exists, or NULL if it |
62 // doesn't. Calling code should always check for NULL. | 69 // doesn't. Calling code should always check for NULL. |
63 PluginDelegate* GetPluginDelegate(); | 70 PluginDelegate* GetPluginDelegate(); |
64 | 71 |
65 // Callback handlers. These mostly convert the PlatformFileError to the | 72 // Callback handlers. These mostly convert the PlatformFileError to the |
66 // PP_Error code and call the shared (non-"Platform") version. | 73 // PP_Error code and call the shared (non-"Platform") version. |
67 void ExecutePlatformGeneralCallback(base::PlatformFileError error_code); | 74 void ExecutePlatformGeneralCallback(base::PlatformFileError error_code); |
68 void ExecutePlatformOpenFileCallback(base::PlatformFileError error_code, | 75 void ExecutePlatformOpenFileCallback(base::PlatformFileError error_code, |
69 base::PassPlatformFile file); | 76 base::PassPlatformFile file); |
(...skipping 17 matching lines...) Expand all Loading... |
87 | 94 |
88 base::WeakPtrFactory<PPB_FileIO_Impl> weak_factory_; | 95 base::WeakPtrFactory<PPB_FileIO_Impl> weak_factory_; |
89 | 96 |
90 DISALLOW_COPY_AND_ASSIGN(PPB_FileIO_Impl); | 97 DISALLOW_COPY_AND_ASSIGN(PPB_FileIO_Impl); |
91 }; | 98 }; |
92 | 99 |
93 } // namespace ppapi | 100 } // namespace ppapi |
94 } // namespace webkit | 101 } // namespace webkit |
95 | 102 |
96 #endif // WEBKIT_PLUGINS_PPAPI_PPB_FILE_IO_IMPL_H_ | 103 #endif // WEBKIT_PLUGINS_PPAPI_PPB_FILE_IO_IMPL_H_ |
OLD | NEW |