OLD | NEW |
---|---|
1 // Copyright (c) 2010 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/platform_file.h" | 10 #include "base/platform_file.h" |
11 #include "base/ref_counted.h" | |
11 #include "base/scoped_callback_factory.h" | 12 #include "base/scoped_callback_factory.h" |
12 #include "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
13 #include "ppapi/c/dev/pp_file_info_dev.h" | 14 #include "ppapi/c/dev/pp_file_info_dev.h" |
14 #include "ppapi/c/pp_completion_callback.h" | 15 #include "ppapi/c/pp_completion_callback.h" |
15 #include "ppapi/c/pp_time.h" | 16 #include "ppapi/c/pp_time.h" |
17 #include "webkit/plugins/ppapi/callbacks.h" | |
16 #include "webkit/plugins/ppapi/plugin_delegate.h" | 18 #include "webkit/plugins/ppapi/plugin_delegate.h" |
17 #include "webkit/plugins/ppapi/resource.h" | 19 #include "webkit/plugins/ppapi/resource.h" |
18 | 20 |
19 struct PP_CompletionCallback; | 21 struct PP_CompletionCallback; |
20 struct PPB_FileIO_Dev; | 22 struct PPB_FileIO_Dev; |
21 struct PPB_FileIOTrusted_Dev; | 23 struct PPB_FileIOTrusted_Dev; |
22 | 24 |
23 namespace webkit { | 25 namespace webkit { |
24 namespace ppapi { | 26 namespace ppapi { |
25 | 27 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
65 void Close(); | 67 void Close(); |
66 | 68 |
67 // PPB_FileIOTrusted implementation. | 69 // PPB_FileIOTrusted implementation. |
68 int32_t GetOSFileDescriptor(); | 70 int32_t GetOSFileDescriptor(); |
69 int32_t WillWrite(int64_t offset, | 71 int32_t WillWrite(int64_t offset, |
70 int32_t bytes_to_write, | 72 int32_t bytes_to_write, |
71 PP_CompletionCallback callback); | 73 PP_CompletionCallback callback); |
72 int32_t WillSetLength(int64_t length, | 74 int32_t WillSetLength(int64_t length, |
73 PP_CompletionCallback callback); | 75 PP_CompletionCallback callback); |
74 | 76 |
77 private: | |
78 // Verifies: | |
79 // - that |callback| is valid (only nonblocking operation supported); | |
80 // - that the file is already opened or not (depending on |is_opened|); and | |
81 // - that no callback is already pending. | |
82 // Returns |PP_OK| to indicate that everything is valid or |PP_ERROR_...| if | |
83 // the call should be aborted and that code returned to the plugin. | |
84 int32_t CommonCallValidation(bool is_opened, PP_CompletionCallback callback); | |
brettw
2011/01/11 21:15:41
A more clear name for the first arg might be "shou
| |
85 | |
86 // Sets up |callback| as the pending callback. This should only be called once | |
87 // it is certain that |PP_ERROR_WOULDBLOCK| will be returned. | |
88 void RegisterCallback(PP_CompletionCallback callback); | |
89 | |
75 void RunPendingCallback(int result); | 90 void RunPendingCallback(int result); |
91 | |
76 void StatusCallback(base::PlatformFileError error_code); | 92 void StatusCallback(base::PlatformFileError error_code); |
77 void AsyncOpenFileCallback(base::PlatformFileError error_code, | 93 void AsyncOpenFileCallback(base::PlatformFileError error_code, |
78 base::PlatformFile file); | 94 base::PlatformFile file); |
79 void QueryInfoCallback(base::PlatformFileError error_code, | 95 void QueryInfoCallback(base::PlatformFileError error_code, |
80 const base::PlatformFileInfo& file_info); | 96 const base::PlatformFileInfo& file_info); |
81 void ReadWriteCallback(base::PlatformFileError error_code, | 97 void ReadWriteCallback(base::PlatformFileError error_code, |
82 int bytes_read_or_written); | 98 int bytes_read_or_written); |
83 | 99 |
84 private: | |
85 PluginDelegate* delegate_; | 100 PluginDelegate* delegate_; |
86 base::ScopedCallbackFactory<PPB_FileIO_Impl> callback_factory_; | 101 base::ScopedCallbackFactory<PPB_FileIO_Impl> callback_factory_; |
87 | 102 |
88 base::PlatformFile file_; | 103 base::PlatformFile file_; |
89 PP_FileSystemType_Dev file_system_type_; | 104 PP_FileSystemType_Dev file_system_type_; |
90 | 105 |
91 PP_CompletionCallback callback_; | 106 // Any pending callback for any PPB_FileIO(Trusted) call taking a callback. |
107 scoped_refptr<TrackedCompletionCallback> callback_; | |
108 | |
109 // Output buffer pointer for |Query()|; only non-null when a callback is | |
110 // pending for it. | |
92 PP_FileInfo_Dev* info_; | 111 PP_FileInfo_Dev* info_; |
93 | 112 |
94 DISALLOW_COPY_AND_ASSIGN(PPB_FileIO_Impl); | 113 DISALLOW_COPY_AND_ASSIGN(PPB_FileIO_Impl); |
95 }; | 114 }; |
96 | 115 |
97 } // namespace ppapi | 116 } // namespace ppapi |
98 } // namespace webkit | 117 } // namespace webkit |
99 | 118 |
100 #endif // WEBKIT_PLUGINS_PPAPI_PPB_FILE_IO_IMPL_H_ | 119 #endif // WEBKIT_PLUGINS_PPAPI_PPB_FILE_IO_IMPL_H_ |
OLD | NEW |