Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(349)

Side by Side Diff: webkit/plugins/ppapi/ppb_flash_file_impl.cc

Issue 6592071: Pepper/Flapper: Add an interface to do sync file ops on FileRefs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/renderer
Patch Set: oops, forgot one Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "webkit/plugins/ppapi/ppb_flash_file_impl.h" 5 #include "webkit/plugins/ppapi/ppb_flash_file_impl.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 }; 215 };
216 216
217 } // namespace 217 } // namespace
218 218
219 // static 219 // static
220 const PPB_Flash_File_ModuleLocal* 220 const PPB_Flash_File_ModuleLocal*
221 PPB_Flash_File_ModuleLocal_Impl::GetInterface() { 221 PPB_Flash_File_ModuleLocal_Impl::GetInterface() {
222 return &ppb_flash_file_modulelocal; 222 return &ppb_flash_file_modulelocal;
223 } 223 }
224 224
225 // PPB_Flash_File_FileRef_Impl -------------------------------------------------
226
227 namespace {
228
229 int32_t OpenFileRefFile(PP_Resource file_ref_id,
230 int32_t mode,
231 PP_FileHandle* file) {
232 int flags = 0;
233 if (!ConvertFromPPFileOpenFlags(mode, &flags) || !file)
234 return PP_ERROR_BADARGUMENT;
235
236 scoped_refptr<PPB_FileRef_Impl> file_ref(
237 Resource::GetAs<PPB_FileRef_Impl>(file_ref_id));
238 if (!file_ref)
239 return PP_ERROR_BADRESOURCE;
240
241 PluginInstance* instance = file_ref->instance();
242 if (!instance)
243 return PP_ERROR_FAILED;
244
245 base::PlatformFile base_file;
246 base::PlatformFileError result = instance->delegate()->OpenFile(
247 PepperFilePath::MakeAbsolute(file_ref->GetSystemPath()),
248 flags,
249 &base_file);
250 *file = base_file;
251 return PlatformFileErrorToPepperError(result);
252 }
253
254 int32_t RenameFileRefFile(PP_Resource from_file_ref_id,
255 PP_Resource to_file_ref_id) {
256 // If it proves necessary, it's easy enough to implement.
257 NOTIMPLEMENTED();
258 return PP_ERROR_FAILED;
259 }
260
261 int32_t DeleteFileRefFileOrDir(PP_Resource file_ref_id,
262 PP_Bool recursive) {
263 // If it proves necessary, it's easy enough to implement.
264 NOTIMPLEMENTED();
265 return PP_ERROR_FAILED;
266 }
267
268 int32_t CreateFileRefDir(PP_Resource file_ref_id) {
269 // If it proves necessary, it's easy enough to implement.
270 NOTIMPLEMENTED();
271 return PP_ERROR_FAILED;
272 }
273
274 int32_t QueryFileRefFile(PP_Resource file_ref_id,
275 PP_FileInfo_Dev* info) {
276 scoped_refptr<PPB_FileRef_Impl> file_ref(
277 Resource::GetAs<PPB_FileRef_Impl>(file_ref_id));
278 if (!file_ref)
279 return PP_ERROR_BADRESOURCE;
280
281 PluginInstance* instance = file_ref->instance();
282 if (!instance)
283 return PP_ERROR_FAILED;
284
285 base::PlatformFileInfo file_info;
286 base::PlatformFileError result = instance->delegate()->QueryFile(
287 PepperFilePath::MakeAbsolute(file_ref->GetSystemPath()),
288 &file_info);
289 if (result == base::PLATFORM_FILE_OK) {
290 info->size = file_info.size;
291 info->creation_time = file_info.creation_time.ToDoubleT();
292 info->last_access_time = file_info.last_accessed.ToDoubleT();
293 info->last_modified_time = file_info.last_modified.ToDoubleT();
294 info->system_type = PP_FILESYSTEMTYPE_EXTERNAL;
295 if (file_info.is_directory)
296 info->type = PP_FILETYPE_DIRECTORY;
297 else
298 info->type = PP_FILETYPE_REGULAR;
299 }
300 return PlatformFileErrorToPepperError(result);
301 }
302
303 int32_t GetFileRefDirContents(PP_Resource file_ref_id,
304 PP_DirContents_Dev** contents) {
305 // If it proves necessary, it's easy enough to implement.
306 NOTIMPLEMENTED();
307 return PP_ERROR_FAILED;
308 }
309
310 const PPB_Flash_File_FileRef ppb_flash_file_fileref = {
311 &OpenFileRefFile,
312 &RenameFileRefFile,
313 &DeleteFileRefFileOrDir,
314 &CreateFileRefDir,
315 &QueryFileRefFile,
316 &GetFileRefDirContents,
317 &FreeDirContents,
318 };
319
320 } // namespace
321
322 // static
323 const PPB_Flash_File_FileRef* PPB_Flash_File_FileRef_Impl::GetInterface() {
324 return &ppb_flash_file_fileref;
325 }
326
225 } // namespace ppapi 327 } // namespace ppapi
226 } // namespace webkit 328 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/ppb_flash_file_impl.h ('k') | webkit/plugins/ppapi/ppb_url_request_info_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698