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