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/ppb_file_ref.h" | 12 #include "ppapi/c/ppb_file_ref.h" |
13 #include "ppapi/shared_impl/resource.h" | 13 #include "ppapi/shared_impl/file_ref_impl.h" |
14 #include "ppapi/thunk/ppb_file_ref_api.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 PluginDelegate; | |
21 class PluginModule; | |
22 | 19 |
23 class PPB_FileRef_Impl : public ::ppapi::Resource, | 20 class PPB_FileRef_Impl : public ::ppapi::FileRefImpl { |
24 public ::ppapi::thunk::PPB_FileRef_API { | |
25 public: | 21 public: |
26 PPB_FileRef_Impl(); | 22 PPB_FileRef_Impl(const ::ppapi::PPB_FileRef_CreateInfo& info, |
27 PPB_FileRef_Impl(PP_Instance instance, | 23 PPB_FileSystem_Impl* file_system); |
28 scoped_refptr<PPB_FileSystem_Impl> file_system, | 24 PPB_FileRef_Impl(const ::ppapi::PPB_FileRef_CreateInfo& info, |
29 const std::string& validated_path); | |
30 PPB_FileRef_Impl(PP_Instance instance, | |
31 const FilePath& external_file_path); | 25 const FilePath& external_file_path); |
32 virtual ~PPB_FileRef_Impl(); | 26 virtual ~PPB_FileRef_Impl(); |
33 | 27 |
34 static PP_Resource Create(PP_Resource file_system, const char* path); | 28 // The returned object will have a refcount of 0 (just like "new"). |
| 29 static PPB_FileRef_Impl* CreateInternal(PP_Resource pp_file_system, |
| 30 const std::string& path); |
35 | 31 |
36 // Resource overrides. | 32 // The returned object will have a refcount of 0 (just like "new"). |
37 virtual PPB_FileRef_Impl* AsPPB_FileRef_Impl(); | 33 static PPB_FileRef_Impl* CreateExternal(PP_Instance instance, |
| 34 const FilePath& external_file_path); |
38 | 35 |
39 // Resource overrides. | 36 // PPB_FileRef_API implementation (not provided by FileRefImpl). |
40 virtual ::ppapi::thunk::PPB_FileRef_API* AsPPB_FileRef_API() OVERRIDE; | |
41 | |
42 // PPB_FileRef_API implementation. | |
43 virtual PP_FileSystemType GetFileSystemType() const OVERRIDE; | |
44 virtual PP_Var GetName() const OVERRIDE; | |
45 virtual PP_Var GetPath() const OVERRIDE; | |
46 virtual PP_Resource GetParent() OVERRIDE; | 37 virtual PP_Resource GetParent() OVERRIDE; |
47 virtual int32_t MakeDirectory(PP_Bool make_ancestors, | 38 virtual int32_t MakeDirectory(PP_Bool make_ancestors, |
48 PP_CompletionCallback callback) OVERRIDE; | 39 PP_CompletionCallback callback) OVERRIDE; |
49 virtual int32_t Touch(PP_Time last_access_time, | 40 virtual int32_t Touch(PP_Time last_access_time, |
50 PP_Time last_modified_time, | 41 PP_Time last_modified_time, |
51 PP_CompletionCallback callback) OVERRIDE; | 42 PP_CompletionCallback callback) OVERRIDE; |
52 virtual int32_t Delete(PP_CompletionCallback callback) OVERRIDE; | 43 virtual int32_t Delete(PP_CompletionCallback callback) OVERRIDE; |
53 virtual int32_t Rename(PP_Resource new_file_ref, | 44 virtual int32_t Rename(PP_Resource new_file_ref, |
54 PP_CompletionCallback callback) OVERRIDE; | 45 PP_CompletionCallback callback) OVERRIDE; |
55 | 46 |
56 PPB_FileSystem_Impl* file_system() const { return file_system_.get(); } | 47 PPB_FileSystem_Impl* file_system() const { return file_system_.get(); } |
57 | 48 |
58 // Returns the virtual path (i.e., the path that the pepper plugin sees) | 49 // Returns the system path corresponding to this file. Valid only for |
59 const std::string& virtual_path() const { return virtual_path_; } | 50 // external filesystems. |
60 | |
61 // Returns the system path corresponding to this file. | |
62 FilePath GetSystemPath() const; | 51 FilePath GetSystemPath() const; |
63 | 52 |
64 // Returns the FileSystem API URL corresponding to this file. | 53 // Returns the FileSystem API URL corresponding to this file. |
65 GURL GetFileSystemURL() const; | 54 GURL GetFileSystemURL() const; |
66 | 55 |
67 private: | 56 private: |
68 // Many mutation functions are allow only to non-external filesystems, This | 57 // Many mutation functions are allow only to non-external filesystems, This |
69 // function returns true if the filesystem is opened and isn't external as an | 58 // function returns true if the filesystem is opened and isn't external as an |
70 // access check for these functions. | 59 // access check for these functions. |
71 bool IsValidNonExternalFileSystem() const; | 60 bool IsValidNonExternalFileSystem() const; |
72 | 61 |
| 62 // Null for external filesystems. |
73 scoped_refptr<PPB_FileSystem_Impl> file_system_; | 63 scoped_refptr<PPB_FileSystem_Impl> file_system_; |
74 std::string virtual_path_; // UTF-8 encoded | 64 |
75 FilePath system_path_; | 65 // Used only for external filesystems. |
| 66 FilePath external_file_system_path_; |
76 | 67 |
77 DISALLOW_COPY_AND_ASSIGN(PPB_FileRef_Impl); | 68 DISALLOW_COPY_AND_ASSIGN(PPB_FileRef_Impl); |
78 }; | 69 }; |
79 | 70 |
80 } // namespace ppapi | 71 } // namespace ppapi |
81 } // namespace webkit | 72 } // namespace webkit |
82 | 73 |
83 #endif // WEBKIT_PLUGINS_PPAPI_PPB_FILE_REF_IMPL_H_ | 74 #endif // WEBKIT_PLUGINS_PPAPI_PPB_FILE_REF_IMPL_H_ |
OLD | NEW |