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 PPAPI_PROXY_FILE_REF_RESOURCE_H_
6 #define PPAPI_PROXY_FILE_REF_RESOURCE_H_
10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "ppapi/c/pp_instance.h"
13 #include "ppapi/c/pp_resource.h"
14 #include "ppapi/c/pp_time.h"
15 #include "ppapi/proxy/plugin_resource.h"
16 #include "ppapi/proxy/ppapi_proxy_export.h"
17 #include "ppapi/shared_impl/file_ref_create_info.h"
18 #include "ppapi/shared_impl/scoped_pp_resource.h"
19 #include "ppapi/thunk/ppb_file_ref_api.h"
26 class PPAPI_PROXY_EXPORT FileRefResource
27 : public PluginResource
,
28 public thunk::PPB_FileRef_API
{
30 static PP_Resource
CreateFileRef(Connection connection
,
32 const FileRefCreateInfo
& info
);
34 ~FileRefResource() override
;
36 // Resource implementation.
37 thunk::PPB_FileRef_API
* AsPPB_FileRef_API() override
;
39 // PPB_FileRef_API implementation.
40 PP_FileSystemType
GetFileSystemType() const override
;
41 PP_Var
GetName() const override
;
42 PP_Var
GetPath() const override
;
43 PP_Resource
GetParent() override
;
44 int32_t MakeDirectory(int32_t make_directory_flags
,
45 scoped_refptr
<TrackedCallback
> callback
) override
;
46 int32_t Touch(PP_Time last_access_time
,
47 PP_Time last_modified_time
,
48 scoped_refptr
<TrackedCallback
> callback
) override
;
49 int32_t Delete(scoped_refptr
<TrackedCallback
> callback
) override
;
50 int32_t Rename(PP_Resource new_file_ref
,
51 scoped_refptr
<TrackedCallback
> callback
) override
;
52 int32_t Query(PP_FileInfo
* info
,
53 scoped_refptr
<TrackedCallback
> callback
) override
;
54 int32_t ReadDirectoryEntries(
55 const PP_ArrayOutput
& output
,
56 scoped_refptr
<TrackedCallback
> callback
) override
;
57 const FileRefCreateInfo
& GetCreateInfo() const override
;
60 PP_Var
GetAbsolutePath() override
;
63 FileRefResource(Connection connection
,
65 const FileRefCreateInfo
& info
);
67 void RunTrackedCallback(scoped_refptr
<TrackedCallback
> callback
,
68 const ResourceMessageReplyParams
& params
);
70 void OnQueryReply(PP_FileInfo
* out_info
,
71 scoped_refptr
<TrackedCallback
> callback
,
72 const ResourceMessageReplyParams
& params
,
73 const PP_FileInfo
& info
);
75 void OnDirectoryEntriesReply(
76 const PP_ArrayOutput
& output
,
77 scoped_refptr
<TrackedCallback
> callback
,
78 const ResourceMessageReplyParams
& params
,
79 const std::vector
<ppapi::FileRefCreateInfo
>& infos
,
80 const std::vector
<PP_FileType
>& file_types
);
82 bool uses_internal_paths() const;
84 // Populated after creation.
85 FileRefCreateInfo create_info_
;
87 // Some file ref operations may fail if the the file system resource inside
88 // create_info_ is destroyed. Therefore, we explicitly hold a reference to
89 // the file system resource to make sure it outlives the file ref.
90 ScopedPPResource file_system_resource_
;
92 scoped_refptr
<StringVar
> name_var_
;
93 scoped_refptr
<StringVar
> path_var_
;
94 scoped_refptr
<StringVar
> absolute_path_var_
;
96 DISALLOW_COPY_AND_ASSIGN(FileRefResource
);
102 #endif // PPAPI_PROXY_FILE_REF_RESOURCE_H_