Cleanup: Only build extensions renderer code when extensions are enabled.
[chromium-blink-merge.git] / ppapi / proxy / file_ref_resource.h
blob0437b23ab942d8b583822c8ee48be972e87a21e8
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_
8 #include <string>
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"
21 namespace ppapi {
22 class StringVar;
24 namespace proxy {
26 class 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,
32 const FileRefCreateInfo& info);
34 virtual ~FileRefResource();
36 // Resource implementation.
37 virtual thunk::PPB_FileRef_API* AsPPB_FileRef_API() OVERRIDE;
39 // PPB_FileRef_API implementation.
40 virtual PP_FileSystemType GetFileSystemType() const OVERRIDE;
41 virtual PP_Var GetName() const OVERRIDE;
42 virtual PP_Var GetPath() const OVERRIDE;
43 virtual PP_Resource GetParent() OVERRIDE;
44 virtual int32_t MakeDirectory(
45 int32_t make_directory_flags,
46 scoped_refptr<TrackedCallback> callback) OVERRIDE;
47 virtual int32_t Touch(PP_Time last_access_time,
48 PP_Time last_modified_time,
49 scoped_refptr<TrackedCallback> callback) OVERRIDE;
50 virtual int32_t Delete(scoped_refptr<TrackedCallback> callback) OVERRIDE;
51 virtual int32_t Rename(PP_Resource new_file_ref,
52 scoped_refptr<TrackedCallback> callback) OVERRIDE;
53 virtual int32_t Query(PP_FileInfo* info,
54 scoped_refptr<TrackedCallback> callback) OVERRIDE;
55 virtual int32_t ReadDirectoryEntries(
56 const PP_ArrayOutput& output,
57 scoped_refptr<TrackedCallback> callback) OVERRIDE;
58 virtual const FileRefCreateInfo& GetCreateInfo() const OVERRIDE;
60 // Private API
61 virtual PP_Var GetAbsolutePath() OVERRIDE;
63 private:
64 FileRefResource(Connection connection,
65 PP_Instance instance,
66 const FileRefCreateInfo& info);
68 void RunTrackedCallback(scoped_refptr<TrackedCallback> callback,
69 const ResourceMessageReplyParams& params);
71 void OnQueryReply(PP_FileInfo* out_info,
72 scoped_refptr<TrackedCallback> callback,
73 const ResourceMessageReplyParams& params,
74 const PP_FileInfo& info);
76 void OnDirectoryEntriesReply(
77 const PP_ArrayOutput& output,
78 scoped_refptr<TrackedCallback> callback,
79 const ResourceMessageReplyParams& params,
80 const std::vector<ppapi::FileRefCreateInfo>& infos,
81 const std::vector<PP_FileType>& file_types);
83 bool uses_internal_paths() const;
85 // Populated after creation.
86 FileRefCreateInfo create_info_;
88 // Some file ref operations may fail if the the file system resource inside
89 // create_info_ is destroyed. Therefore, we explicitly hold a reference to
90 // the file system resource to make sure it outlives the file ref.
91 ScopedPPResource file_system_resource_;
93 scoped_refptr<StringVar> name_var_;
94 scoped_refptr<StringVar> path_var_;
95 scoped_refptr<StringVar> absolute_path_var_;
97 DISALLOW_COPY_AND_ASSIGN(FileRefResource);
100 } // namespace proxy
101 } // namespace ppapi
103 #endif // PPAPI_PROXY_FILE_REF_RESOURCE_H_