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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_callback_factory.h" | 11 #include "base/memory/scoped_callback_factory.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/platform_file.h" | 13 #include "base/platform_file.h" |
14 #include "ppapi/c/dev/pp_file_info_dev.h" | 14 #include "ppapi/c/pp_file_info.h" |
15 #include "ppapi/c/pp_time.h" | 15 #include "ppapi/c/pp_time.h" |
16 #include "ppapi/thunk/ppb_file_io_api.h" | 16 #include "ppapi/thunk/ppb_file_io_api.h" |
17 #include "webkit/plugins/ppapi/callbacks.h" | 17 #include "webkit/plugins/ppapi/callbacks.h" |
18 #include "webkit/plugins/ppapi/plugin_delegate.h" | 18 #include "webkit/plugins/ppapi/plugin_delegate.h" |
19 #include "webkit/plugins/ppapi/resource.h" | 19 #include "webkit/plugins/ppapi/resource.h" |
20 | 20 |
21 struct PP_CompletionCallback; | 21 struct PP_CompletionCallback; |
22 struct PPB_FileIO_Dev; | 22 struct PPB_FileIO; |
23 struct PPB_FileIOTrusted_Dev; | 23 struct PPB_FileIOTrusted; |
24 | 24 |
25 namespace webkit { | 25 namespace webkit { |
26 namespace ppapi { | 26 namespace ppapi { |
27 | 27 |
28 class PluginModule; | 28 class PluginModule; |
29 class PPB_FileRef_Impl; | 29 class PPB_FileRef_Impl; |
30 | 30 |
31 class PPB_FileIO_Impl : public Resource, | 31 class PPB_FileIO_Impl : public Resource, |
32 public ::ppapi::thunk::PPB_FileIO_API { | 32 public ::ppapi::thunk::PPB_FileIO_API { |
33 public: | 33 public: |
34 explicit PPB_FileIO_Impl(PluginInstance* instance); | 34 explicit PPB_FileIO_Impl(PluginInstance* instance); |
35 virtual ~PPB_FileIO_Impl(); | 35 virtual ~PPB_FileIO_Impl(); |
36 | 36 |
37 // ResourceObjectBase overrides. | 37 // ResourceObjectBase overrides. |
38 virtual ::ppapi::thunk::PPB_FileIO_API* AsPPB_FileIO_API() OVERRIDE; | 38 virtual ::ppapi::thunk::PPB_FileIO_API* AsPPB_FileIO_API() OVERRIDE; |
39 | 39 |
40 // PPB_FileIO_API implementation. | 40 // PPB_FileIO_API implementation. |
41 virtual int32_t Open(PP_Resource file_ref, | 41 virtual int32_t Open(PP_Resource file_ref, |
42 int32_t open_flags, | 42 int32_t open_flags, |
43 PP_CompletionCallback callback) OVERRIDE; | 43 PP_CompletionCallback callback) OVERRIDE; |
44 virtual int32_t Query(PP_FileInfo_Dev* info, | 44 virtual int32_t Query(PP_FileInfo* info, |
45 PP_CompletionCallback callback) OVERRIDE; | 45 PP_CompletionCallback callback) OVERRIDE; |
46 virtual int32_t Touch(PP_Time last_access_time, | 46 virtual int32_t Touch(PP_Time last_access_time, |
47 PP_Time last_modified_time, | 47 PP_Time last_modified_time, |
48 PP_CompletionCallback callback) OVERRIDE; | 48 PP_CompletionCallback callback) OVERRIDE; |
49 virtual int32_t Read(int64_t offset, | 49 virtual int32_t Read(int64_t offset, |
50 char* buffer, | 50 char* buffer, |
51 int32_t bytes_to_read, | 51 int32_t bytes_to_read, |
52 PP_CompletionCallback callback) OVERRIDE; | 52 PP_CompletionCallback callback) OVERRIDE; |
53 virtual int32_t Write(int64_t offset, | 53 virtual int32_t Write(int64_t offset, |
54 const char* buffer, | 54 const char* buffer, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 base::PlatformFile file); | 86 base::PlatformFile file); |
87 void QueryInfoCallback(base::PlatformFileError error_code, | 87 void QueryInfoCallback(base::PlatformFileError error_code, |
88 const base::PlatformFileInfo& file_info); | 88 const base::PlatformFileInfo& file_info); |
89 void ReadCallback(base::PlatformFileError error_code, | 89 void ReadCallback(base::PlatformFileError error_code, |
90 const char* data, int bytes_read); | 90 const char* data, int bytes_read); |
91 void WriteCallback(base::PlatformFileError error_code, int bytes_written); | 91 void WriteCallback(base::PlatformFileError error_code, int bytes_written); |
92 | 92 |
93 base::ScopedCallbackFactory<PPB_FileIO_Impl> callback_factory_; | 93 base::ScopedCallbackFactory<PPB_FileIO_Impl> callback_factory_; |
94 | 94 |
95 base::PlatformFile file_; | 95 base::PlatformFile file_; |
96 PP_FileSystemType_Dev file_system_type_; | 96 PP_FileSystemType file_system_type_; |
97 | 97 |
98 // Any pending callback for any PPB_FileIO(Trusted) call taking a callback. | 98 // Any pending callback for any PPB_FileIO(Trusted) call taking a callback. |
99 scoped_refptr<TrackedCompletionCallback> callback_; | 99 scoped_refptr<TrackedCompletionCallback> callback_; |
100 | 100 |
101 // Output buffer pointer for |Query()|; only non-null when a callback is | 101 // Output buffer pointer for |Query()|; only non-null when a callback is |
102 // pending for it. | 102 // pending for it. |
103 PP_FileInfo_Dev* info_; | 103 PP_FileInfo* info_; |
104 | 104 |
105 // Pointer back to the caller's read buffer; used by |Read()|. Not owned. | 105 // Pointer back to the caller's read buffer; used by |Read()|. Not owned. |
106 char* read_buffer_; | 106 char* read_buffer_; |
107 | 107 |
108 DISALLOW_COPY_AND_ASSIGN(PPB_FileIO_Impl); | 108 DISALLOW_COPY_AND_ASSIGN(PPB_FileIO_Impl); |
109 }; | 109 }; |
110 | 110 |
111 } // namespace ppapi | 111 } // namespace ppapi |
112 } // namespace webkit | 112 } // namespace webkit |
113 | 113 |
114 #endif // WEBKIT_PLUGINS_PPAPI_PPB_FILE_IO_IMPL_H_ | 114 #endif // WEBKIT_PLUGINS_PPAPI_PPB_FILE_IO_IMPL_H_ |
OLD | NEW |