blob: 62926d72d4d6a2fdab78095de08103bc7df49408 [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
5#ifndef PPAPI_PROXY_PPB_FILE_REF_PROXY_H_
6#define PPAPI_PROXY_PPB_FILE_REF_PROXY_H_
7
8#include <string>
9
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/thunk/ppb_file_ref_api.h"
19
20namespace ppapi {
21class StringVar;
22
23namespace proxy {
24
25class PPAPI_PROXY_EXPORT FileRefResource
26 : public PluginResource,
27 public thunk::PPB_FileRef_API {
28 public:
29 static PP_Resource CreateFileRef(Connection connection,
30 PP_Instance instance,
31 FileRef_CreateInfo info);
32
33 virtual ~FileRefResource();
34
35 // Resource implementation.
36 virtual thunk::PPB_FileRef_API* AsPPB_FileRef_API() OVERRIDE;
37
38 // PPB_FileRef_API implementation.
39 virtual PP_FileSystemType GetFileSystemType() const OVERRIDE;
40 virtual PP_Var GetName() const OVERRIDE;
41 virtual PP_Var GetPath() const OVERRIDE;
42 virtual PP_Resource GetParent() OVERRIDE;
43 virtual int32_t MakeDirectory(
44 PP_Bool make_ancestors,
45 scoped_refptr<TrackedCallback> callback) OVERRIDE;
46 virtual int32_t Touch(PP_Time last_access_time,
47 PP_Time last_modified_time,
48 scoped_refptr<TrackedCallback> callback) OVERRIDE;
49 virtual int32_t Delete(scoped_refptr<TrackedCallback> callback) OVERRIDE;
50 virtual int32_t Rename(PP_Resource new_file_ref,
51 scoped_refptr<TrackedCallback> callback) OVERRIDE;
52 virtual int32_t Query(PP_FileInfo* info,
53 scoped_refptr<TrackedCallback> callback) OVERRIDE;
54 virtual int32_t ReadDirectoryEntries(
55 const PP_ArrayOutput& output,
56 scoped_refptr<TrackedCallback> callback) OVERRIDE;
57 virtual const PPB_FileRef_CreateInfo& GetCreateInfo() const OVERRIDE;
58 virtual int32_t QueryInHost(linked_ptr<PP_FileInfo> info,
59 scoped_refptr<TrackedCallback> callback) OVERRIDE;
60 virtual int32_t ReadDirectoryEntriesInHost(
61 linked_ptr<std::vector<ppapi::PPB_FileRef_CreateInfo> > files,
62 linked_ptr<std::vector<PP_FileType> > file_types,
63 scoped_refptr<TrackedCallback> callback) OVERRIDE;
64
65 // Private API
66 virtual PP_Var GetAbsolutePath() OVERRIDE;
67
68 private:
69 FileRefResource(Connection connection,
70 PP_Instance instance,
71 FileRef_CreateInfo info);
72
73 void RunTrackedCallback(scoped_refptr<TrackedCallback> callback,
74 const ResourceMessageReplyParams& params);
75
76 void OnQueryReply(PP_FileInfo* out_info,
77 scoped_refptr<TrackedCallback> callback,
78 const ResourceMessageReplyParams& params,
79 const PP_FileInfo& info);
80
81 void OnDirectoryEntriesReply(
82 const PP_ArrayOutput& output,
83 scoped_refptr<TrackedCallback> callback,
84 const ResourceMessageReplyParams& params,
85 const std::vector<ppapi::FileRef_CreateInfo>& infos,
86 const std::vector<PP_FileType>& file_types);
87
88 // Populated after creation.
89 FileRef_CreateInfo create_info_;
90
91 scoped_refptr<StringVar> name_var_;
92 scoped_refptr<StringVar> path_var_;
93 scoped_refptr<StringVar> absolute_path_var_;
94
95 DISALLOW_COPY_AND_ASSIGN(FileRefResource);
96};
97
98} // namespace proxy
99} // namespace ppapi
100
101#endif // PPAPI_PROXY_PPB_FILE_REF_PROXY_H_