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/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "googleurl/src/gurl.h" | 11 #include "googleurl/src/gurl.h" |
12 #include "ppapi/c/pp_file_info.h" | 12 #include "ppapi/c/pp_file_info.h" |
13 #include "ppapi/c/ppb_file_ref.h" | 13 #include "ppapi/c/ppb_file_ref.h" |
14 #include "ppapi/shared_impl/ppb_file_ref_shared.h" | 14 #include "ppapi/shared_impl/ppb_file_ref_shared.h" |
15 #include "ppapi/shared_impl/var.h" | 15 #include "ppapi/shared_impl/var.h" |
16 #include "webkit/glue/webkit_glue_export.h" | 16 #include "webkit/glue/webkit_glue_export.h" |
17 | 17 |
18 namespace webkit { | 18 namespace webkit { |
19 namespace ppapi { | 19 namespace ppapi { |
20 | 20 |
21 using ::ppapi::StringVar; | 21 using ::ppapi::StringVar; |
22 | 22 |
23 class PPB_FileSystem_Impl; | 23 class PPB_FileSystem_Impl; |
24 | 24 |
25 class WEBKIT_GLUE_EXPORT PPB_FileRef_Impl | 25 class WEBKIT_GLUE_EXPORT PPB_FileRef_Impl |
26 : public ::ppapi::PPB_FileRef_Shared { | 26 : public ::ppapi::PPB_FileRef_Shared { |
27 public: | 27 public: |
28 PPB_FileRef_Impl(const ::ppapi::PPB_FileRef_CreateInfo& info, | 28 PPB_FileRef_Impl(const ::ppapi::PPB_FileRef_CreateInfo& info, |
29 PPB_FileSystem_Impl* file_system); | 29 PP_Resource file_system); |
30 PPB_FileRef_Impl(const ::ppapi::PPB_FileRef_CreateInfo& info, | 30 PPB_FileRef_Impl(const ::ppapi::PPB_FileRef_CreateInfo& info, |
31 const base::FilePath& external_file_path); | 31 const base::FilePath& external_file_path); |
32 virtual ~PPB_FileRef_Impl(); | 32 virtual ~PPB_FileRef_Impl(); |
33 | 33 |
34 // The returned object will have a refcount of 0 (just like "new"). | 34 // The returned object will have a refcount of 0 (just like "new"). |
35 static PPB_FileRef_Impl* CreateInternal(PP_Resource pp_file_system, | 35 static PPB_FileRef_Impl* CreateInternal(PP_Instance instance, |
36 PP_Resource pp_file_system, | |
36 const std::string& path); | 37 const std::string& path); |
37 | 38 |
38 // The returned object will have a refcount of 0 (just like "new"). | 39 // The returned object will have a refcount of 0 (just like "new"). |
39 static PPB_FileRef_Impl* CreateExternal(PP_Instance instance, | 40 static PPB_FileRef_Impl* CreateExternal( |
40 const base::FilePath& external_file_pa th, | 41 PP_Instance instance, |
41 const std::string& display_name); | 42 const base::FilePath& external_file_path, |
43 const std::string& display_name); | |
42 | 44 |
43 // PPB_FileRef_API implementation (not provided by PPB_FileRef_Shared). | 45 // PPB_FileRef_API implementation (not provided by PPB_FileRef_Shared). |
44 virtual PP_Resource GetParent() OVERRIDE; | 46 virtual PP_Resource GetParent() OVERRIDE; |
45 virtual int32_t MakeDirectory( | 47 virtual int32_t MakeDirectory( |
46 PP_Bool make_ancestors, | 48 PP_Bool make_ancestors, |
47 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE; | 49 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE; |
48 virtual int32_t Touch( | 50 virtual int32_t Touch( |
49 PP_Time last_access_time, | 51 PP_Time last_access_time, |
50 PP_Time last_modified_time, | 52 PP_Time last_modified_time, |
51 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE; | 53 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE; |
52 virtual int32_t Delete( | 54 virtual int32_t Delete( |
53 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE; | 55 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE; |
54 virtual int32_t Rename( | 56 virtual int32_t Rename( |
55 PP_Resource new_file_ref, | 57 PP_Resource new_file_ref, |
56 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE; | 58 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE; |
57 virtual int32_t Query( | 59 virtual int32_t Query( |
58 PP_FileInfo* info, | 60 PP_FileInfo* info, |
59 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE; | 61 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE; |
60 virtual PP_Var GetAbsolutePath(); | 62 virtual PP_Var GetAbsolutePath(); |
61 | 63 |
62 PPB_FileSystem_Impl* file_system() const { return file_system_.get(); } | 64 PP_Resource file_system_resource() const { return file_system_; } |
63 | 65 |
64 // Returns the system path corresponding to this file. Valid only for | 66 // Returns the system path corresponding to this file. Valid only for |
65 // external filesystems. | 67 // external filesystems. |
66 base::FilePath GetSystemPath() const; | 68 base::FilePath GetSystemPath() const; |
67 | 69 |
68 // Returns the FileSystem API URL corresponding to this file. | 70 // Returns the FileSystem API URL corresponding to this file. |
69 GURL GetFileSystemURL() const; | 71 GURL GetFileSystemURL() const; |
70 | 72 |
71 // Checks if file ref has file system instance and if the instance is opened. | 73 // Checks if file ref has file system instance and if the instance is opened. |
72 bool HasValidFileSystem() const; | 74 bool HasValidFileSystem() const; |
75 | |
73 private: | 76 private: |
74 // Many mutation functions are allow only to non-external filesystems, This | 77 // 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 | 78 // function returns true if the filesystem is opened and isn't external as an |
76 // access check for these functions. | 79 // access check for these functions. |
77 bool IsValidNonExternalFileSystem() const; | 80 bool IsValidNonExternalFileSystem() const; |
78 | 81 |
79 // Null for external filesystems. | 82 // 0 for external filesystems. |
80 scoped_refptr<PPB_FileSystem_Impl> file_system_; | 83 PP_Resource file_system_; |
yzshen1
2013/04/08 21:05:16
Could you please comment that this is a 'plugin-si
victorhsieh
2013/04/08 23:44:38
Comment added. It should be safe now as plugin de
yzshen1
2013/04/09 17:25:42
Let's discuss offline. It is too long to type. :)
victorhsieh
2013/04/10 19:07:10
Done. Please verify the implementation is correct
| |
81 | 84 |
82 // Used only for external filesystems. | 85 // Used only for external filesystems. |
83 base::FilePath external_file_system_path_; | 86 base::FilePath external_file_system_path_; |
84 | 87 |
85 // Lazily initialized var created from the external path. This is so we can | 88 // Lazily initialized var created from the external path. This is so we can |
86 // return the identical string object every time it is requested. | 89 // return the identical string object every time it is requested. |
87 scoped_refptr<StringVar> external_path_var_; | 90 scoped_refptr<StringVar> external_path_var_; |
88 | 91 |
89 DISALLOW_COPY_AND_ASSIGN(PPB_FileRef_Impl); | 92 DISALLOW_COPY_AND_ASSIGN(PPB_FileRef_Impl); |
90 }; | 93 }; |
91 | 94 |
92 } // namespace ppapi | 95 } // namespace ppapi |
93 } // namespace webkit | 96 } // namespace webkit |
94 | 97 |
95 #endif // WEBKIT_PLUGINS_PPAPI_PPB_FILE_REF_IMPL_H_ | 98 #endif // WEBKIT_PLUGINS_PPAPI_PPB_FILE_REF_IMPL_H_ |
OLD | NEW |