1 // Copyright 2013 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_EXTERNAL_FILE_REF_BACKEND_H_ 6 #define CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_EXTERNAL_FILE_REF_BACKEND_H_ 7 8 #include <string> 9 10 #include "base/files/file_path.h" 11 #include "base/memory/ref_counted.h" 12 #include "base/task_runner.h" 13 #include "content/browser/renderer_host/pepper/pepper_file_ref_host.h" 14 #include "ppapi/c/pp_instance.h" 15 #include "ppapi/c/pp_resource.h" 16 #include "ppapi/c/pp_time.h" 17 #include "ppapi/host/ppapi_host.h" 18 19 namespace content { 20 21 // Implementations of FileRef operations for external filesystems. 22 class PepperExternalFileRefBackend : public PepperFileRefBackend { 23 public: 24 PepperExternalFileRefBackend(ppapi::host::PpapiHost* host, 25 int render_process_id, 26 const base::FilePath& path); 27 virtual ~PepperExternalFileRefBackend(); 28 29 // PepperFileRefBackend overrides. 30 virtual int32_t MakeDirectory(ppapi::host::ReplyMessageContext context, 31 bool make_ancestors) OVERRIDE; 32 virtual int32_t Touch(ppapi::host::ReplyMessageContext context, 33 PP_Time last_accessed_time, 34 PP_Time last_modified_time) OVERRIDE; 35 virtual int32_t Delete(ppapi::host::ReplyMessageContext context) OVERRIDE; 36 virtual int32_t Rename(ppapi::host::ReplyMessageContext context, 37 PepperFileRefHost* new_file_ref) OVERRIDE; 38 virtual int32_t Query(ppapi::host::ReplyMessageContext context) OVERRIDE; 39 virtual int32_t ReadDirectoryEntries( 40 ppapi::host::ReplyMessageContext context) OVERRIDE; 41 virtual int32_t GetAbsolutePath(ppapi::host::ReplyMessageContext context) 42 OVERRIDE; 43 virtual fileapi::FileSystemURL GetFileSystemURL() const OVERRIDE; 44 virtual std::string GetFileSystemURLSpec() const OVERRIDE; 45 virtual base::FilePath GetExternalPath() const OVERRIDE; 46 47 virtual int32_t CanRead() const OVERRIDE; 48 virtual int32_t CanWrite() const OVERRIDE; 49 virtual int32_t CanCreate() const OVERRIDE; 50 virtual int32_t CanReadWrite() const OVERRIDE; 51 52 private: 53 // Generic reply callback. 54 void DidFinish(ppapi::host::ReplyMessageContext reply_context, 55 const IPC::Message& msg, 56 base::PlatformFileError error); 57 58 // Operation specific callbacks. 59 void GetMetadataComplete( 60 ppapi::host::ReplyMessageContext reply_context, 61 base::PlatformFileError error, 62 const base::PlatformFileInfo& file_info); 63 64 ppapi::host::PpapiHost* host_; 65 base::FilePath path_; 66 int render_process_id_; 67 68 scoped_refptr<base::TaskRunner> task_runner_; 69 70 base::WeakPtrFactory<PepperExternalFileRefBackend> weak_factory_; 71 }; 72 73 } // namespace content 74 75 #endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_EXTERNAL_FILE_REF_BACKEND_H_ 76