Home | History | Annotate | Download | only in pepper
      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_INTERNAL_FILE_REF_BACKEND_H_
      6 #define CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_INTERNAL_FILE_REF_BACKEND_H_
      7 
      8 #include <string>
      9 
     10 #include "content/browser/renderer_host/pepper/pepper_file_ref_host.h"
     11 #include "ppapi/c/pp_instance.h"
     12 #include "ppapi/c/pp_resource.h"
     13 #include "ppapi/c/pp_time.h"
     14 #include "ppapi/host/ppapi_host.h"
     15 #include "webkit/browser/fileapi/file_system_context.h"
     16 #include "webkit/browser/fileapi/file_system_operation.h"
     17 #include "webkit/browser/fileapi/file_system_url.h"
     18 
     19 namespace content {
     20 
     21 class PepperFileSystemBrowserHost;
     22 
     23 // Implementations of FileRef operations for internal filesystems.
     24 class PepperInternalFileRefBackend : public PepperFileRefBackend {
     25  public:
     26   PepperInternalFileRefBackend(
     27       ppapi::host::PpapiHost* host,
     28       int render_process_id,
     29       base::WeakPtr<PepperFileSystemBrowserHost> fs_host,
     30       const std::string& path);
     31   virtual ~PepperInternalFileRefBackend();
     32 
     33   // PepperFileRefBackend overrides.
     34   virtual int32_t MakeDirectory(ppapi::host::ReplyMessageContext context,
     35                                 bool make_ancestors) OVERRIDE;
     36   virtual int32_t Touch(ppapi::host::ReplyMessageContext context,
     37                         PP_Time last_accessed_time,
     38                         PP_Time last_modified_time) OVERRIDE;
     39   virtual int32_t Delete(ppapi::host::ReplyMessageContext context) OVERRIDE;
     40   virtual int32_t Rename(ppapi::host::ReplyMessageContext context,
     41                          PepperFileRefHost* new_file_ref) OVERRIDE;
     42   virtual int32_t Query(ppapi::host::ReplyMessageContext context) OVERRIDE;
     43   virtual int32_t ReadDirectoryEntries(
     44       ppapi::host::ReplyMessageContext context) OVERRIDE;
     45   virtual int32_t GetAbsolutePath(ppapi::host::ReplyMessageContext context)
     46       OVERRIDE;
     47 
     48   virtual fileapi::FileSystemURL GetFileSystemURL() const OVERRIDE;
     49   virtual std::string GetFileSystemURLSpec() const OVERRIDE;
     50   virtual base::FilePath GetExternalPath() const OVERRIDE;
     51 
     52   virtual int32_t CanRead() const OVERRIDE;
     53   virtual int32_t CanWrite() const OVERRIDE;
     54   virtual int32_t CanCreate() const OVERRIDE;
     55   virtual int32_t CanReadWrite() const OVERRIDE;
     56 
     57  private:
     58   // Generic reply callback.
     59   void DidFinish(ppapi::host::ReplyMessageContext reply_context,
     60                  const IPC::Message& msg,
     61                  base::PlatformFileError error);
     62 
     63   // Operation specific callbacks.
     64   void GetMetadataComplete(
     65     ppapi::host::ReplyMessageContext reply_context,
     66     base::PlatformFileError error,
     67     const base::PlatformFileInfo& file_info);
     68   void ReadDirectoryComplete(
     69       ppapi::host::ReplyMessageContext context,
     70       base::PlatformFileError error,
     71       const fileapi::FileSystemOperation::FileEntryList& file_list,
     72       bool has_more);
     73 
     74   scoped_refptr<fileapi::FileSystemContext> GetFileSystemContext() const;
     75 
     76   ppapi::host::PpapiHost* host_;
     77   int render_process_id_;
     78   base::WeakPtr<PepperFileSystemBrowserHost> fs_host_;
     79   PP_FileSystemType fs_type_;
     80   std::string path_;
     81 
     82   mutable fileapi::FileSystemURL fs_url_;
     83 
     84   base::WeakPtrFactory<PepperInternalFileRefBackend> weak_factory_;
     85 };
     86 
     87 }  // namespace content
     88 
     89 #endif  // CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_INTERNAL_FILE_REF_BACKEND_H_
     90