| 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 CONTENT_RENDERER_PEPPER_PPB_FILE_REF_IMPL_H_ |
| 6 #define WEBKIT_PLUGINS_PPAPI_PPB_FILE_REF_IMPL_H_ | 6 #define CONTENT_RENDERER_PEPPER_PPB_FILE_REF_IMPL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/memory/linked_ptr.h" | 12 #include "base/memory/linked_ptr.h" |
| 13 #include "ppapi/c/pp_file_info.h" | 13 #include "ppapi/c/pp_file_info.h" |
| 14 #include "ppapi/c/ppb_file_ref.h" | 14 #include "ppapi/c/ppb_file_ref.h" |
| 15 #include "ppapi/shared_impl/ppb_file_ref_shared.h" | 15 #include "ppapi/shared_impl/ppb_file_ref_shared.h" |
| 16 #include "ppapi/shared_impl/scoped_pp_resource.h" | 16 #include "ppapi/shared_impl/scoped_pp_resource.h" |
| 17 #include "ppapi/shared_impl/var.h" | 17 #include "ppapi/shared_impl/var.h" |
| 18 #include "url/gurl.h" | 18 #include "url/gurl.h" |
| 19 #include "webkit/plugins/webkit_plugins_export.h" | |
| 20 | 19 |
| 21 namespace webkit { | 20 namespace webkit { |
| 22 namespace ppapi { | 21 namespace ppapi { |
| 23 | 22 |
| 24 using ::ppapi::StringVar; | 23 using ::ppapi::StringVar; |
| 25 | 24 |
| 26 class PPB_FileSystem_Impl; | 25 class PPB_FileSystem_Impl; |
| 27 | 26 |
| 28 class WEBKIT_PLUGINS_EXPORT PPB_FileRef_Impl | 27 class PPB_FileRef_Impl : public ::ppapi::PPB_FileRef_Shared { |
| 29 : public ::ppapi::PPB_FileRef_Shared { | |
| 30 public: | 28 public: |
| 31 PPB_FileRef_Impl(const ::ppapi::PPB_FileRef_CreateInfo& info, | 29 PPB_FileRef_Impl(const ::ppapi::PPB_FileRef_CreateInfo& info, |
| 32 PP_Resource file_system); | 30 PP_Resource file_system); |
| 33 PPB_FileRef_Impl(const ::ppapi::PPB_FileRef_CreateInfo& info, | 31 PPB_FileRef_Impl(const ::ppapi::PPB_FileRef_CreateInfo& info, |
| 34 const base::FilePath& external_file_path); | 32 const base::FilePath& external_file_path); |
| 35 virtual ~PPB_FileRef_Impl(); | |
| 36 | 33 |
| 37 // 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"). |
| 38 static PPB_FileRef_Impl* CreateInternal(PP_Instance instance, | 35 static PPB_FileRef_Impl* CreateInternal(PP_Instance instance, |
| 39 PP_Resource pp_file_system, | 36 PP_Resource pp_file_system, |
| 40 const std::string& path); | 37 const std::string& path); |
| 41 | 38 |
| 42 // 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"). |
| 43 static PPB_FileRef_Impl* CreateExternal( | 40 static PPB_FileRef_Impl* CreateExternal( |
| 44 PP_Instance instance, | 41 PP_Instance instance, |
| 45 const base::FilePath& external_file_path, | 42 const base::FilePath& external_file_path, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 65 virtual int32_t ReadDirectoryEntries( | 62 virtual int32_t ReadDirectoryEntries( |
| 66 const PP_ArrayOutput& output, | 63 const PP_ArrayOutput& output, |
| 67 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE; | 64 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE; |
| 68 virtual int32_t QueryInHost( | 65 virtual int32_t QueryInHost( |
| 69 linked_ptr<PP_FileInfo> info, | 66 linked_ptr<PP_FileInfo> info, |
| 70 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE; | 67 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE; |
| 71 virtual int32_t ReadDirectoryEntriesInHost( | 68 virtual int32_t ReadDirectoryEntriesInHost( |
| 72 linked_ptr<std::vector< ::ppapi::PPB_FileRef_CreateInfo> > files, | 69 linked_ptr<std::vector< ::ppapi::PPB_FileRef_CreateInfo> > files, |
| 73 linked_ptr<std::vector<PP_FileType> > file_types, | 70 linked_ptr<std::vector<PP_FileType> > file_types, |
| 74 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE; | 71 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE; |
| 75 virtual PP_Var GetAbsolutePath(); | 72 virtual PP_Var GetAbsolutePath() OVERRIDE; |
| 76 | 73 |
| 77 PP_Resource file_system_resource() const { return file_system_; } | 74 PP_Resource file_system_resource() const { return file_system_; } |
| 78 | 75 |
| 79 // Returns the system path corresponding to this file. Valid only for | 76 // Returns the system path corresponding to this file. Valid only for |
| 80 // external filesystems. | 77 // external filesystems. |
| 81 base::FilePath GetSystemPath() const; | 78 base::FilePath GetSystemPath() const; |
| 82 | 79 |
| 83 // Returns the FileSystem API URL corresponding to this file. | 80 // Returns the FileSystem API URL corresponding to this file. |
| 84 GURL GetFileSystemURL() const; | 81 GURL GetFileSystemURL() const; |
| 85 | 82 |
| 86 // Checks if file ref has file system instance and if the instance is opened. | 83 // Checks if file ref has file system instance and if the instance is opened. |
| 87 bool HasValidFileSystem() const; | 84 bool HasValidFileSystem() const; |
| 88 | 85 |
| 89 void AddFileSystemRefCount() { | 86 void AddFileSystemRefCount() { |
| 90 file_system_ref_ = file_system_; | 87 file_system_ref_ = file_system_; |
| 91 } | 88 } |
| 92 | 89 |
| 93 private: | 90 private: |
| 91 virtual ~PPB_FileRef_Impl(); |
| 92 |
| 94 // Many mutation functions are allow only to non-external filesystems, This | 93 // Many mutation functions are allow only to non-external filesystems, This |
| 95 // function returns true if the filesystem is opened and isn't external as an | 94 // function returns true if the filesystem is opened and isn't external as an |
| 96 // access check for these functions. | 95 // access check for these functions. |
| 97 bool IsValidNonExternalFileSystem() const; | 96 bool IsValidNonExternalFileSystem() const; |
| 98 | 97 |
| 99 // 0 for external filesystems. This is a plugin side resource that we don't | 98 // 0 for external filesystems. This is a plugin side resource that we don't |
| 100 // hold a reference here, so file_system_ could be destroyed earlier than | 99 // hold a reference here, so file_system_ could be destroyed earlier than |
| 101 // this object. Right now we checked the existance in plugin delegate before | 100 // this object. Right now we checked the existance in plugin delegate before |
| 102 // use. But it's better to hold a reference once we migrate FileRef to the | 101 // use. But it's better to hold a reference once we migrate FileRef to the |
| 103 // new design. | 102 // new design. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 117 // Lazily initialized var created from the external path. This is so we can | 116 // Lazily initialized var created from the external path. This is so we can |
| 118 // return the identical string object every time it is requested. | 117 // return the identical string object every time it is requested. |
| 119 scoped_refptr<StringVar> external_path_var_; | 118 scoped_refptr<StringVar> external_path_var_; |
| 120 | 119 |
| 121 DISALLOW_COPY_AND_ASSIGN(PPB_FileRef_Impl); | 120 DISALLOW_COPY_AND_ASSIGN(PPB_FileRef_Impl); |
| 122 }; | 121 }; |
| 123 | 122 |
| 124 } // namespace ppapi | 123 } // namespace ppapi |
| 125 } // namespace webkit | 124 } // namespace webkit |
| 126 | 125 |
| 127 #endif // WEBKIT_PLUGINS_PPAPI_PPB_FILE_REF_IMPL_H_ | 126 #endif // CONTENT_RENDERER_PEPPER_PPB_FILE_REF_IMPL_H_ |
| OLD | NEW |