blob: b6a1db7e877053c6dd42a07b93412ebc01c316f8 [file] [log] [blame]
[email protected]dc000e82013-06-26 04:10:411// 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
[email protected]2e0ec622014-04-11 07:18:325#ifndef PPAPI_PROXY_FILE_REF_RESOURCE_H_
6#define PPAPI_PROXY_FILE_REF_RESOURCE_H_
[email protected]dc000e82013-06-26 04:10:417
avie029c4132015-12-23 06:45:228#include <stdint.h>
9
[email protected]dc000e82013-06-26 04:10:4110#include <string>
11
[email protected]dc000e82013-06-26 04:10:4112#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"
[email protected]8abbb672013-07-03 23:30:0518#include "ppapi/shared_impl/scoped_pp_resource.h"
[email protected]dc000e82013-06-26 04:10:4119#include "ppapi/thunk/ppb_file_ref_api.h"
20
21namespace ppapi {
22class StringVar;
23
24namespace proxy {
25
26class PPAPI_PROXY_EXPORT FileRefResource
27 : public PluginResource,
28 public thunk::PPB_FileRef_API {
29 public:
30 static PP_Resource CreateFileRef(Connection connection,
31 PP_Instance instance,
[email protected]c6420f082013-09-18 22:42:4132 const FileRefCreateInfo& info);
[email protected]dc000e82013-06-26 04:10:4133
Peter Boström3d5b3cb2021-09-23 21:35:4534 FileRefResource(const FileRefResource&) = delete;
35 FileRefResource& operator=(const FileRefResource&) = delete;
36
nicke4784432015-04-23 14:01:4837 ~FileRefResource() override;
[email protected]dc000e82013-06-26 04:10:4138
39 // Resource implementation.
nicke4784432015-04-23 14:01:4840 thunk::PPB_FileRef_API* AsPPB_FileRef_API() override;
[email protected]dc000e82013-06-26 04:10:4141
42 // PPB_FileRef_API implementation.
nicke4784432015-04-23 14:01:4843 PP_FileSystemType GetFileSystemType() const override;
44 PP_Var GetName() const override;
45 PP_Var GetPath() const override;
46 PP_Resource GetParent() override;
47 int32_t MakeDirectory(int32_t make_directory_flags,
mostynb699af3c2014-10-06 18:03:3448 scoped_refptr<TrackedCallback> callback) override;
nicke4784432015-04-23 14:01:4849 int32_t Touch(PP_Time last_access_time,
50 PP_Time last_modified_time,
51 scoped_refptr<TrackedCallback> callback) override;
52 int32_t Delete(scoped_refptr<TrackedCallback> callback) override;
53 int32_t Rename(PP_Resource new_file_ref,
54 scoped_refptr<TrackedCallback> callback) override;
55 int32_t Query(PP_FileInfo* info,
56 scoped_refptr<TrackedCallback> callback) override;
57 int32_t ReadDirectoryEntries(
[email protected]dc000e82013-06-26 04:10:4158 const PP_ArrayOutput& output,
mostynb699af3c2014-10-06 18:03:3459 scoped_refptr<TrackedCallback> callback) override;
nicke4784432015-04-23 14:01:4860 const FileRefCreateInfo& GetCreateInfo() const override;
[email protected]dc000e82013-06-26 04:10:4161
62 // Private API
nicke4784432015-04-23 14:01:4863 PP_Var GetAbsolutePath() override;
[email protected]dc000e82013-06-26 04:10:4164
65 private:
66 FileRefResource(Connection connection,
67 PP_Instance instance,
[email protected]c6420f082013-09-18 22:42:4168 const FileRefCreateInfo& info);
[email protected]dc000e82013-06-26 04:10:4169
70 void RunTrackedCallback(scoped_refptr<TrackedCallback> callback,
71 const ResourceMessageReplyParams& params);
72
73 void OnQueryReply(PP_FileInfo* out_info,
74 scoped_refptr<TrackedCallback> callback,
75 const ResourceMessageReplyParams& params,
76 const PP_FileInfo& info);
77
78 void OnDirectoryEntriesReply(
79 const PP_ArrayOutput& output,
80 scoped_refptr<TrackedCallback> callback,
81 const ResourceMessageReplyParams& params,
[email protected]c6420f082013-09-18 22:42:4182 const std::vector<ppapi::FileRefCreateInfo>& infos,
[email protected]dc000e82013-06-26 04:10:4183 const std::vector<PP_FileType>& file_types);
84
[email protected]2e0ec622014-04-11 07:18:3285 bool uses_internal_paths() const;
86
[email protected]dc000e82013-06-26 04:10:4187 // Populated after creation.
[email protected]c6420f082013-09-18 22:42:4188 FileRefCreateInfo create_info_;
[email protected]dc000e82013-06-26 04:10:4189
[email protected]8abbb672013-07-03 23:30:0590 // Some file ref operations may fail if the the file system resource inside
91 // create_info_ is destroyed. Therefore, we explicitly hold a reference to
92 // the file system resource to make sure it outlives the file ref.
93 ScopedPPResource file_system_resource_;
94
[email protected]dc000e82013-06-26 04:10:4195 scoped_refptr<StringVar> name_var_;
96 scoped_refptr<StringVar> path_var_;
97 scoped_refptr<StringVar> absolute_path_var_;
[email protected]dc000e82013-06-26 04:10:4198};
99
100} // namespace proxy
101} // namespace ppapi
102
[email protected]2e0ec622014-04-11 07:18:32103#endif // PPAPI_PROXY_FILE_REF_RESOURCE_H_