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" |
13 #include "webkit/plugins/ppapi/resource.h" | 14 #include "webkit/plugins/ppapi/resource.h" |
14 | 15 |
15 namespace webkit { | 16 namespace webkit { |
16 namespace ppapi { | 17 namespace ppapi { |
17 | 18 |
18 class PPB_FileSystem_Impl; | 19 class PPB_FileSystem_Impl; |
19 class PluginInstance; | 20 class PluginInstance; |
20 class PluginModule; | 21 class PluginModule; |
21 | 22 |
22 class PPB_FileRef_Impl : public Resource { | 23 class PPB_FileRef_Impl : public Resource, |
| 24 public ::ppapi::thunk::PPB_FileRef_API { |
23 public: | 25 public: |
24 PPB_FileRef_Impl(); | 26 PPB_FileRef_Impl(); |
25 PPB_FileRef_Impl(PluginInstance* instance, | 27 PPB_FileRef_Impl(PluginInstance* instance, |
26 scoped_refptr<PPB_FileSystem_Impl> file_system, | 28 scoped_refptr<PPB_FileSystem_Impl> file_system, |
27 const std::string& validated_path); | 29 const std::string& validated_path); |
28 PPB_FileRef_Impl(PluginInstance* instance, | 30 PPB_FileRef_Impl(PluginInstance* instance, |
29 const FilePath& external_file_path); | 31 const FilePath& external_file_path); |
30 virtual ~PPB_FileRef_Impl(); | 32 virtual ~PPB_FileRef_Impl(); |
31 | 33 |
32 // Returns a pointer to the interface implementing PPB_FileRef that is | 34 static PP_Resource Create(PP_Resource file_system, const char* path); |
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 // PPB_FileRef implementation. | 39 // ResourceObjectBase overrides. |
40 std::string GetName() const; | 40 virtual ::ppapi::thunk::PPB_FileRef_API* AsPPB_FileRef_API() OVERRIDE; |
41 scoped_refptr<PPB_FileRef_Impl> GetParent(); | |
42 | 41 |
43 // Returns the file system to which this PPB_FileRef_Impl belongs. | 42 // PPB_FileRef_API implementation. |
44 scoped_refptr<PPB_FileSystem_Impl> GetFileSystem() const; | 43 virtual PP_FileSystemType_Dev GetFileSystemType() const OVERRIDE; |
| 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; |
45 | 55 |
46 // Returns the type of the file system to which this PPB_FileRef_Impl belongs. | 56 PPB_FileSystem_Impl* file_system() const { return file_system_.get(); } |
47 PP_FileSystemType_Dev GetFileSystemType() const; | 57 const std::string& virtual_path() const { return virtual_path_; } |
48 | 58 |
49 // Returns the virtual path (i.e., the path that the pepper plugin sees) | 59 // Returns the virtual path (i.e., the path that the pepper plugin sees) |
50 // corresponding to this file. | |
51 std::string GetPath() const; | |
52 | |
53 // Returns the system path corresponding to this file. | 60 // Returns the system path corresponding to this file. |
54 FilePath GetSystemPath() const; | 61 FilePath GetSystemPath() const; |
55 | 62 |
56 // Returns the FileSystem API URL corresponding to this file. | 63 // Returns the FileSystem API URL corresponding to this file. |
57 GURL GetFileSystemURL() const; | 64 GURL GetFileSystemURL() const; |
58 | 65 |
59 private: | 66 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 |
60 scoped_refptr<PPB_FileSystem_Impl> file_system_; | 72 scoped_refptr<PPB_FileSystem_Impl> file_system_; |
61 std::string virtual_path_; // UTF-8 encoded | 73 std::string virtual_path_; // UTF-8 encoded |
62 FilePath system_path_; | 74 FilePath system_path_; |
63 | 75 |
64 DISALLOW_COPY_AND_ASSIGN(PPB_FileRef_Impl); | 76 DISALLOW_COPY_AND_ASSIGN(PPB_FileRef_Impl); |
65 }; | 77 }; |
66 | 78 |
67 } // namespace ppapi | 79 } // namespace ppapi |
68 } // namespace webkit | 80 } // namespace webkit |
69 | 81 |
70 #endif // WEBKIT_PLUGINS_PPAPI_PPB_FILE_REF_IMPL_H_ | 82 #endif // WEBKIT_PLUGINS_PPAPI_PPB_FILE_REF_IMPL_H_ |
OLD | NEW |