OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "webkit/plugins/ppapi/ppb_file_ref_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_file_ref_impl.h" |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "ppapi/c/pp_errors.h" | 9 #include "ppapi/c/pp_errors.h" |
10 #include "webkit/plugins/ppapi/common.h" | 10 #include "webkit/plugins/ppapi/common.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 PluginInstance* instance = file_system->instance(); | 127 PluginInstance* instance = file_system->instance(); |
128 if (!instance->delegate()->MakeDirectory( | 128 if (!instance->delegate()->MakeDirectory( |
129 directory_ref->GetSystemPath(), PPBoolToBool(make_ancestors), | 129 directory_ref->GetSystemPath(), PPBoolToBool(make_ancestors), |
130 new FileCallbacks(instance->module()->AsWeakPtr(), directory_ref_id, | 130 new FileCallbacks(instance->module()->AsWeakPtr(), directory_ref_id, |
131 callback, NULL, NULL, NULL))) | 131 callback, NULL, NULL, NULL))) |
132 return PP_ERROR_FAILED; | 132 return PP_ERROR_FAILED; |
133 | 133 |
134 return PP_ERROR_WOULDBLOCK; | 134 return PP_ERROR_WOULDBLOCK; |
135 } | 135 } |
136 | 136 |
137 int32_t Query(PP_Resource file_ref_id, | |
138 PP_FileInfo_Dev* info, | |
139 PP_CompletionCallback callback) { | |
140 scoped_refptr<PPB_FileRef_Impl> file_ref( | |
141 Resource::GetAs<PPB_FileRef_Impl>(file_ref_id)); | |
142 if (!file_ref) | |
143 return PP_ERROR_BADRESOURCE; | |
144 | |
145 scoped_refptr<PPB_FileSystem_Impl> file_system = file_ref->GetFileSystem(); | |
146 if (!file_system || !file_system->opened() || | |
147 (file_system->type() == PP_FILESYSTEMTYPE_EXTERNAL)) | |
148 return PP_ERROR_NOACCESS; | |
149 | |
150 PluginInstance* instance = file_system->instance(); | |
151 if (!instance->delegate()->Query( | |
152 file_ref->GetSystemPath(), | |
153 new FileCallbacks(instance->module()->AsWeakPtr(), file_ref_id, | |
154 callback, info, file_system, NULL))) | |
155 return PP_ERROR_FAILED; | |
156 | |
157 return PP_ERROR_WOULDBLOCK; | |
158 } | |
159 | |
160 int32_t Touch(PP_Resource file_ref_id, | 137 int32_t Touch(PP_Resource file_ref_id, |
161 PP_Time last_access_time, | 138 PP_Time last_access_time, |
162 PP_Time last_modified_time, | 139 PP_Time last_modified_time, |
163 PP_CompletionCallback callback) { | 140 PP_CompletionCallback callback) { |
164 scoped_refptr<PPB_FileRef_Impl> file_ref( | 141 scoped_refptr<PPB_FileRef_Impl> file_ref( |
165 Resource::GetAs<PPB_FileRef_Impl>(file_ref_id)); | 142 Resource::GetAs<PPB_FileRef_Impl>(file_ref_id)); |
166 if (!file_ref) | 143 if (!file_ref) |
167 return PP_ERROR_BADRESOURCE; | 144 return PP_ERROR_BADRESOURCE; |
168 | 145 |
169 scoped_refptr<PPB_FileSystem_Impl> file_system = file_ref->GetFileSystem(); | 146 scoped_refptr<PPB_FileSystem_Impl> file_system = file_ref->GetFileSystem(); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 } | 213 } |
237 | 214 |
238 const PPB_FileRef_Dev ppb_fileref = { | 215 const PPB_FileRef_Dev ppb_fileref = { |
239 &Create, | 216 &Create, |
240 &IsFileRef, | 217 &IsFileRef, |
241 &GetFileSystemType, | 218 &GetFileSystemType, |
242 &GetName, | 219 &GetName, |
243 &GetPath, | 220 &GetPath, |
244 &GetParent, | 221 &GetParent, |
245 &MakeDirectory, | 222 &MakeDirectory, |
246 &Query, | |
247 &Touch, | 223 &Touch, |
248 &Delete, | 224 &Delete, |
249 &Rename | 225 &Rename |
250 }; | 226 }; |
251 | 227 |
252 } // namespace | 228 } // namespace |
253 | 229 |
254 PPB_FileRef_Impl::PPB_FileRef_Impl() | 230 PPB_FileRef_Impl::PPB_FileRef_Impl() |
255 : Resource(NULL), | 231 : Resource(NULL), |
256 file_system_(NULL) { | 232 file_system_(NULL) { |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 #else | 332 #else |
357 #error "Unsupported platform." | 333 #error "Unsupported platform." |
358 #endif | 334 #endif |
359 ); | 335 ); |
360 return file_system_->root_path().Append(virtual_file_path); | 336 return file_system_->root_path().Append(virtual_file_path); |
361 } | 337 } |
362 | 338 |
363 } // namespace ppapi | 339 } // namespace ppapi |
364 } // namespace webkit | 340 } // namespace webkit |
365 | 341 |
OLD | NEW |