OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/dev/ppb_file_ref_dev.h" | 12 #include "ppapi/c/dev/ppb_file_ref_dev.h" |
13 #include "ppapi/thunk/ppb_file_ref_api.h" | |
14 #include "webkit/plugins/ppapi/resource.h" | 13 #include "webkit/plugins/ppapi/resource.h" |
15 | 14 |
16 namespace webkit { | 15 namespace webkit { |
17 namespace ppapi { | 16 namespace ppapi { |
18 | 17 |
19 class PPB_FileSystem_Impl; | 18 class PPB_FileSystem_Impl; |
20 class PluginInstance; | 19 class PluginInstance; |
21 class PluginModule; | 20 class PluginModule; |
22 | 21 |
23 class PPB_FileRef_Impl : public Resource, | 22 class PPB_FileRef_Impl : public Resource { |
24 public ::ppapi::thunk::PPB_FileRef_API { | |
25 public: | 23 public: |
26 PPB_FileRef_Impl(); | 24 PPB_FileRef_Impl(); |
27 PPB_FileRef_Impl(PluginInstance* instance, | 25 PPB_FileRef_Impl(PluginInstance* instance, |
28 scoped_refptr<PPB_FileSystem_Impl> file_system, | 26 scoped_refptr<PPB_FileSystem_Impl> file_system, |
29 const std::string& validated_path); | 27 const std::string& validated_path); |
30 PPB_FileRef_Impl(PluginInstance* instance, | 28 PPB_FileRef_Impl(PluginInstance* instance, |
31 const FilePath& external_file_path); | 29 const FilePath& external_file_path); |
32 virtual ~PPB_FileRef_Impl(); | 30 virtual ~PPB_FileRef_Impl(); |
33 | 31 |
34 static PP_Resource Create(PP_Resource file_system, const char* path); | 32 // Returns a pointer to the interface implementing PPB_FileRef that is |
| 33 // exposed to the plugin. |
| 34 static const PPB_FileRef_Dev* GetInterface(); |
35 | 35 |
36 // Resource overrides. | 36 // Resource overrides. |
37 virtual PPB_FileRef_Impl* AsPPB_FileRef_Impl(); | 37 virtual PPB_FileRef_Impl* AsPPB_FileRef_Impl(); |
38 | 38 |
39 // ResourceObjectBase overrides. | 39 // PPB_FileRef implementation. |
40 virtual ::ppapi::thunk::PPB_FileRef_API* AsPPB_FileRef_API() OVERRIDE; | 40 std::string GetName() const; |
| 41 scoped_refptr<PPB_FileRef_Impl> GetParent(); |
41 | 42 |
42 // PPB_FileRef_API implementation. | 43 // Returns the file system to which this PPB_FileRef_Impl belongs. |
43 virtual PP_FileSystemType_Dev GetFileSystemType() const OVERRIDE; | 44 scoped_refptr<PPB_FileSystem_Impl> GetFileSystem() const; |
44 virtual PP_Var GetName() const OVERRIDE; | |
45 virtual PP_Var GetPath() const OVERRIDE; | |
46 virtual PP_Resource GetParent() OVERRIDE; | |
47 virtual int32_t MakeDirectory(PP_Bool make_ancestors, | |
48 PP_CompletionCallback callback) OVERRIDE; | |
49 virtual int32_t Touch(PP_Time last_access_time, | |
50 PP_Time last_modified_time, | |
51 PP_CompletionCallback callback) OVERRIDE; | |
52 virtual int32_t Delete(PP_CompletionCallback callback) OVERRIDE; | |
53 virtual int32_t Rename(PP_Resource new_file_ref, | |
54 PP_CompletionCallback callback) OVERRIDE; | |
55 | 45 |
56 PPB_FileSystem_Impl* file_system() const { return file_system_.get(); } | 46 // Returns the type of the file system to which this PPB_FileRef_Impl belongs. |
57 const std::string& virtual_path() const { return virtual_path_; } | 47 PP_FileSystemType_Dev GetFileSystemType() const; |
58 | 48 |
59 // Returns the virtual path (i.e., the path that the pepper plugin sees) | 49 // Returns the virtual path (i.e., the path that the pepper plugin sees) |
| 50 // corresponding to this file. |
| 51 std::string GetPath() const; |
| 52 |
60 // Returns the system path corresponding to this file. | 53 // Returns the system path corresponding to this file. |
61 FilePath GetSystemPath() const; | 54 FilePath GetSystemPath() const; |
62 | 55 |
63 // Returns the FileSystem API URL corresponding to this file. | 56 // Returns the FileSystem API URL corresponding to this file. |
64 GURL GetFileSystemURL() const; | 57 GURL GetFileSystemURL() const; |
65 | 58 |
66 private: | 59 private: |
67 // Many mutation functions are allow only to non-external filesystems, This | |
68 // function returns true if the filesystem is opened and isn't external as an | |
69 // access check for these functions. | |
70 bool IsValidNonExternalFileSystem() const; | |
71 | |
72 scoped_refptr<PPB_FileSystem_Impl> file_system_; | 60 scoped_refptr<PPB_FileSystem_Impl> file_system_; |
73 std::string virtual_path_; // UTF-8 encoded | 61 std::string virtual_path_; // UTF-8 encoded |
74 FilePath system_path_; | 62 FilePath system_path_; |
75 | 63 |
76 DISALLOW_COPY_AND_ASSIGN(PPB_FileRef_Impl); | 64 DISALLOW_COPY_AND_ASSIGN(PPB_FileRef_Impl); |
77 }; | 65 }; |
78 | 66 |
79 } // namespace ppapi | 67 } // namespace ppapi |
80 } // namespace webkit | 68 } // namespace webkit |
81 | 69 |
82 #endif // WEBKIT_PLUGINS_PPAPI_PPB_FILE_REF_IMPL_H_ | 70 #endif // WEBKIT_PLUGINS_PPAPI_PPB_FILE_REF_IMPL_H_ |
OLD | NEW |