1 // Copyright (c) 2012 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 WEBKIT_PLUGINS_PPAPI_PPB_FILE_REF_IMPL_H_
6 #define WEBKIT_PLUGINS_PPAPI_PPB_FILE_REF_IMPL_H_
10 #include "base/files/file_path.h"
11 #include "googleurl/src/gurl.h"
12 #include "ppapi/c/pp_file_info.h"
13 #include "ppapi/c/ppb_file_ref.h"
14 #include "ppapi/shared_impl/ppb_file_ref_shared.h"
15 #include "ppapi/shared_impl/var.h"
16 #include "webkit/glue/webkit_glue_export.h"
21 using ::ppapi::StringVar
;
23 class PPB_FileSystem_Impl
;
25 class WEBKIT_GLUE_EXPORT PPB_FileRef_Impl
26 : public ::ppapi::PPB_FileRef_Shared
{
28 PPB_FileRef_Impl(const ::ppapi::PPB_FileRef_CreateInfo
& info
,
29 PPB_FileSystem_Impl
* file_system
);
30 PPB_FileRef_Impl(const ::ppapi::PPB_FileRef_CreateInfo
& info
,
31 const base::FilePath
& external_file_path
);
32 virtual ~PPB_FileRef_Impl();
34 // The returned object will have a refcount of 0 (just like "new").
35 static PPB_FileRef_Impl
* CreateInternal(PP_Resource pp_file_system
,
36 const std::string
& path
);
38 // The returned object will have a refcount of 0 (just like "new").
39 static PPB_FileRef_Impl
* CreateExternal(PP_Instance instance
,
40 const base::FilePath
& external_file_path
,
41 const std::string
& display_name
);
43 // PPB_FileRef_API implementation (not provided by PPB_FileRef_Shared).
44 virtual PP_Resource
GetParent() OVERRIDE
;
45 virtual int32_t MakeDirectory(
46 PP_Bool make_ancestors
,
47 scoped_refptr
< ::ppapi::TrackedCallback
> callback
) OVERRIDE
;
48 virtual int32_t Touch(
49 PP_Time last_access_time
,
50 PP_Time last_modified_time
,
51 scoped_refptr
< ::ppapi::TrackedCallback
> callback
) OVERRIDE
;
52 virtual int32_t Delete(
53 scoped_refptr
< ::ppapi::TrackedCallback
> callback
) OVERRIDE
;
54 virtual int32_t Rename(
55 PP_Resource new_file_ref
,
56 scoped_refptr
< ::ppapi::TrackedCallback
> callback
) OVERRIDE
;
57 virtual int32_t Query(
59 scoped_refptr
< ::ppapi::TrackedCallback
> callback
) OVERRIDE
;
60 virtual PP_Var
GetAbsolutePath();
62 PPB_FileSystem_Impl
* file_system() const { return file_system_
.get(); }
64 // Returns the system path corresponding to this file. Valid only for
65 // external filesystems.
66 base::FilePath
GetSystemPath() const;
68 // Returns the FileSystem API URL corresponding to this file.
69 GURL
GetFileSystemURL() const;
71 // Checks if file ref has file system instance and if the instance is opened.
72 bool HasValidFileSystem() const;
74 // Many mutation functions are allow only to non-external filesystems, This
75 // function returns true if the filesystem is opened and isn't external as an
76 // access check for these functions.
77 bool IsValidNonExternalFileSystem() const;
79 // Null for external filesystems.
80 scoped_refptr
<PPB_FileSystem_Impl
> file_system_
;
82 // Used only for external filesystems.
83 base::FilePath external_file_system_path_
;
85 // Lazily initialized var created from the external path. This is so we can
86 // return the identical string object every time it is requested.
87 scoped_refptr
<StringVar
> external_path_var_
;
89 DISALLOW_COPY_AND_ASSIGN(PPB_FileRef_Impl
);
95 #endif // WEBKIT_PLUGINS_PPAPI_PPB_FILE_REF_IMPL_H_