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 PPAPI_PROXY_FILE_IO_RESOURCE_H_ | 5 #ifndef PPAPI_PROXY_FILE_IO_RESOURCE_H_ |
6 #define PPAPI_PROXY_FILE_IO_RESOURCE_H_ | 6 #define PPAPI_PROXY_FILE_IO_RESOURCE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "ppapi/c/private/pp_file_handle.h" | 10 #include "ppapi/c/private/pp_file_handle.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
60 PP_FileHandle* handle, | 60 PP_FileHandle* handle, |
61 scoped_refptr<TrackedCallback> callback) OVERRIDE; | 61 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
62 virtual int32_t WillWrite(int64_t offset, | 62 virtual int32_t WillWrite(int64_t offset, |
63 int32_t bytes_to_write, | 63 int32_t bytes_to_write, |
64 scoped_refptr<TrackedCallback> callback) OVERRIDE; | 64 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
65 virtual int32_t WillSetLength( | 65 virtual int32_t WillSetLength( |
66 int64_t length, | 66 int64_t length, |
67 scoped_refptr<TrackedCallback> callback) OVERRIDE; | 67 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
68 | 68 |
69 private: | 69 private: |
70 // Class to perform file query operations across multiple threads. | |
71 class QueryOp : public base::RefCountedThreadSafe<QueryOp> { | |
72 public: | |
73 QueryOp(PP_FileHandle file_handle); | |
dmichael (off chromium)
2013/08/09 22:20:56
nit: explicit
bbudge
2013/08/09 23:05:28
Done.
| |
74 | |
75 // Queries the file. Called on the file thread (non-blocking) or the plugin | |
76 // thread (blocking). | |
dmichael (off chromium)
2013/08/09 22:20:56
please note it does not hold the ProxyLock (same f
bbudge
2013/08/09 23:05:28
Done.
| |
77 int32_t DoWork(); | |
78 | |
79 const base::PlatformFileInfo& file_info() const { return file_info_; } | |
80 | |
81 private: | |
82 friend class base::RefCountedThreadSafe<QueryOp>; | |
83 virtual ~QueryOp(); | |
dmichael (off chromium)
2013/08/09 22:20:56
FWIW... You don't actually need to make it virtua
bbudge
2013/08/09 23:05:28
Done.
| |
84 | |
85 PP_FileHandle file_handle_; | |
86 base::PlatformFileInfo file_info_; | |
87 }; | |
88 | |
89 // Class to perform file read operations across multiple threads. | |
90 class ReadOp : public base::RefCountedThreadSafe<ReadOp> { | |
91 public: | |
92 ReadOp(PP_FileHandle file_handle, int64_t offset, int32_t bytes_to_read); | |
93 | |
94 // Reads the file. Called on the file thread (non-blocking) or the plugin | |
95 // thread (blocking). | |
96 int32_t DoWork(); | |
97 | |
98 char* buffer() const { return buffer_.get(); } | |
99 | |
100 private: | |
101 friend class base::RefCountedThreadSafe<ReadOp>; | |
102 virtual ~ReadOp(); | |
103 | |
104 PP_FileHandle file_handle_; | |
105 int64_t offset_; | |
106 int32_t bytes_to_read_; | |
107 scoped_ptr<char[]> buffer_; | |
108 }; | |
109 | |
70 int32_t ReadValidated(int64_t offset, | 110 int32_t ReadValidated(int64_t offset, |
71 int32_t bytes_to_read, | 111 int32_t bytes_to_read, |
72 const PP_ArrayOutput& array_output, | 112 const PP_ArrayOutput& array_output, |
73 scoped_refptr<TrackedCallback> callback); | 113 scoped_refptr<TrackedCallback> callback); |
74 | 114 |
75 void CloseFileHandle(); | 115 void CloseFileHandle(); |
76 | 116 |
117 | |
118 void OnFileTaskComplete(scoped_refptr<TrackedCallback> callback, | |
119 int32_t result); | |
120 | |
121 // Completion tasks for file operations that are done in the plugin. | |
122 int32_t OnQueryComplete(scoped_refptr<QueryOp> query_op, | |
123 PP_FileInfo* info, | |
124 int32_t result); | |
125 int32_t OnReadComplete(scoped_refptr<ReadOp> read_op, | |
126 PP_ArrayOutput array_output, | |
127 int32_t result); | |
128 | |
77 // Reply message handlers for operations that are done in the host. | 129 // Reply message handlers for operations that are done in the host. |
78 void OnPluginMsgGeneralComplete(scoped_refptr<TrackedCallback> callback, | 130 void OnPluginMsgGeneralComplete(scoped_refptr<TrackedCallback> callback, |
79 const ResourceMessageReplyParams& params); | 131 const ResourceMessageReplyParams& params); |
80 void OnPluginMsgOpenFileComplete(scoped_refptr<TrackedCallback> callback, | 132 void OnPluginMsgOpenFileComplete(scoped_refptr<TrackedCallback> callback, |
81 const ResourceMessageReplyParams& params); | 133 const ResourceMessageReplyParams& params); |
82 void OnPluginMsgQueryComplete(scoped_refptr<TrackedCallback> callback, | |
83 PP_FileInfo* output_info_, | |
84 const ResourceMessageReplyParams& params, | |
85 const PP_FileInfo& info); | |
86 void OnPluginMsgReadComplete(scoped_refptr<TrackedCallback> callback, | |
87 PP_ArrayOutput array_output, | |
88 const ResourceMessageReplyParams& params, | |
89 const std::string& data); | |
90 void OnPluginMsgRequestOSFileHandleComplete( | 134 void OnPluginMsgRequestOSFileHandleComplete( |
91 scoped_refptr<TrackedCallback> callback, | 135 scoped_refptr<TrackedCallback> callback, |
92 PP_FileHandle* output_handle, | 136 PP_FileHandle* output_handle, |
93 const ResourceMessageReplyParams& params); | 137 const ResourceMessageReplyParams& params); |
94 | 138 |
95 PP_FileHandle file_handle_; | 139 PP_FileHandle file_handle_; |
96 PP_FileSystemType file_system_type_; | 140 PP_FileSystemType file_system_type_; |
97 FileIOStateManager state_manager_; | 141 FileIOStateManager state_manager_; |
98 | 142 |
99 DISALLOW_COPY_AND_ASSIGN(FileIOResource); | 143 DISALLOW_COPY_AND_ASSIGN(FileIOResource); |
100 }; | 144 }; |
101 | 145 |
102 } // namespace proxy | 146 } // namespace proxy |
103 } // namespace ppapi | 147 } // namespace ppapi |
104 | 148 |
105 #endif // PPAPI_PROXY_FILE_IO_RESOURCE_H_ | 149 #endif // PPAPI_PROXY_FILE_IO_RESOURCE_H_ |
OLD | NEW |