#ifndef CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_FILE_REF_HOST_H_
#define CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_FILE_REF_HOST_H_
#include <string>
#include "base/memory/weak_ptr.h"
#include "content/public/browser/browser_ppapi_host.h"
#include "ppapi/c/pp_file_info.h"
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_time.h"
#include "ppapi/host/host_message_context.h"
#include "ppapi/host/resource_host.h"
#include "webkit/browser/fileapi/file_system_url.h"
namespace content {
class PepperFileRefHost;
class PepperFileSystemBrowserHost;
class PepperFileRefBackend {
public:
virtual ~PepperFileRefBackend();
virtual int32_t MakeDirectory(ppapi::host::ReplyMessageContext context,
int32_t make_directory_flags) = 0;
virtual int32_t Touch(ppapi::host::ReplyMessageContext context,
PP_Time last_accessed_time,
PP_Time last_modified_time) = 0;
virtual int32_t Delete(ppapi::host::ReplyMessageContext context) = 0;
virtual int32_t Rename(ppapi::host::ReplyMessageContext context,
PepperFileRefHost* new_file_ref) = 0;
virtual int32_t Query(ppapi::host::ReplyMessageContext context) = 0;
virtual int32_t ReadDirectoryEntries(
ppapi::host::ReplyMessageContext context) = 0;
virtual int32_t GetAbsolutePath(
ppapi::host::ReplyMessageContext context) = 0;
virtual fileapi::FileSystemURL GetFileSystemURL() const = 0;
virtual base::FilePath GetExternalFilePath() const = 0;
virtual int32_t CanRead() const = 0;
virtual int32_t CanWrite() const = 0;
virtual int32_t CanCreate() const = 0;
virtual int32_t CanReadWrite() const = 0;
};
class CONTENT_EXPORT PepperFileRefHost
: public ppapi::host::ResourceHost,
public base::SupportsWeakPtr<PepperFileRefHost> {
public:
PepperFileRefHost(BrowserPpapiHost* host,
PP_Instance instance,
PP_Resource resource,
PP_Resource file_system,
const std::string& internal_path);
PepperFileRefHost(BrowserPpapiHost* host,
PP_Instance instance,
PP_Resource resource,
const base::FilePath& external_path);
virtual ~PepperFileRefHost();
virtual int32_t OnResourceMessageReceived(
const IPC::Message& msg,
ppapi::host::HostMessageContext* context) OVERRIDE;
virtual bool IsFileRefHost() OVERRIDE;
PP_FileSystemType GetFileSystemType() const;
fileapi::FileSystemURL GetFileSystemURL() const;
base::FilePath GetExternalFilePath() const;
base::WeakPtr<PepperFileSystemBrowserHost> GetFileSystemHost() const;
int32_t CanRead() const;
int32_t CanWrite() const;
int32_t CanCreate() const;
int32_t CanReadWrite() const;
private:
int32_t OnMakeDirectory(ppapi::host::HostMessageContext* context,
int32_t make_directory_flags);
int32_t OnTouch(ppapi::host::HostMessageContext* context,
PP_Time last_access_time,
PP_Time last_modified_time);
int32_t OnDelete(ppapi::host::HostMessageContext* context);
int32_t OnRename(ppapi::host::HostMessageContext* context,
PP_Resource new_file_ref);
int32_t OnQuery(ppapi::host::HostMessageContext* context);
int32_t OnReadDirectoryEntries(ppapi::host::HostMessageContext* context);
int32_t OnGetAbsolutePath(ppapi::host::HostMessageContext* context);
BrowserPpapiHost* host_;
scoped_ptr<PepperFileRefBackend> backend_;
base::WeakPtr<PepperFileSystemBrowserHost> file_system_host_;
PP_FileSystemType fs_type_;
DISALLOW_COPY_AND_ASSIGN(PepperFileRefHost);
};
}
#endif