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.
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_
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 "storage/browser/fileapi/file_system_context.h"
16 #include "storage/browser/fileapi/file_system_operation.h"
17 #include "storage/browser/fileapi/file_system_url.h"
21 class PepperFileSystemBrowserHost
;
23 // Implementations of FileRef operations for internal filesystems.
24 class PepperInternalFileRefBackend
: public PepperFileRefBackend
{
26 PepperInternalFileRefBackend(
27 ppapi::host::PpapiHost
* host
,
28 int render_process_id
,
29 base::WeakPtr
<PepperFileSystemBrowserHost
> fs_host
,
30 const std::string
& path
);
31 ~PepperInternalFileRefBackend() override
;
33 // PepperFileRefBackend overrides.
34 int32_t MakeDirectory(ppapi::host::ReplyMessageContext context
,
35 int32_t make_directory_flags
) override
;
36 int32_t Touch(ppapi::host::ReplyMessageContext context
,
37 PP_Time last_accessed_time
,
38 PP_Time last_modified_time
) override
;
39 int32_t Delete(ppapi::host::ReplyMessageContext context
) override
;
40 int32_t Rename(ppapi::host::ReplyMessageContext context
,
41 PepperFileRefHost
* new_file_ref
) override
;
42 int32_t Query(ppapi::host::ReplyMessageContext context
) override
;
43 int32_t ReadDirectoryEntries(
44 ppapi::host::ReplyMessageContext context
) override
;
45 int32_t GetAbsolutePath(ppapi::host::ReplyMessageContext context
) override
;
46 storage::FileSystemURL
GetFileSystemURL() const override
;
47 base::FilePath
GetExternalFilePath() const override
;
49 int32_t CanRead() const override
;
50 int32_t CanWrite() const override
;
51 int32_t CanCreate() const override
;
52 int32_t CanReadWrite() const override
;
55 // Generic reply callback.
56 void DidFinish(ppapi::host::ReplyMessageContext reply_context
,
57 const IPC::Message
& msg
,
58 base::File::Error error
);
60 // Operation specific callbacks.
61 void GetMetadataComplete(ppapi::host::ReplyMessageContext reply_context
,
62 base::File::Error error
,
63 const base::File::Info
& file_info
);
64 void ReadDirectoryComplete(
65 ppapi::host::ReplyMessageContext context
,
66 storage::FileSystemOperation::FileEntryList
* accumulated_file_list
,
67 base::File::Error error
,
68 const storage::FileSystemOperation::FileEntryList
& file_list
,
71 scoped_refptr
<storage::FileSystemContext
> GetFileSystemContext() const;
73 ppapi::host::PpapiHost
* host_
;
74 int render_process_id_
;
75 base::WeakPtr
<PepperFileSystemBrowserHost
> fs_host_
;
76 PP_FileSystemType fs_type_
;
79 mutable storage::FileSystemURL fs_url_
;
81 base::WeakPtrFactory
<PepperInternalFileRefBackend
> weak_factory_
;
83 DISALLOW_COPY_AND_ASSIGN(PepperInternalFileRefBackend
);
86 } // namespace content
88 #endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_INTERNAL_FILE_REF_BACKEND_H_