| 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 "base/memory/weak_ptr.h" |
| 11 #include "googleurl/src/gurl.h" | 12 #include "googleurl/src/gurl.h" |
| 13 #include "ppapi/c/pp_file_info.h" |
| 12 #include "ppapi/c/ppb_file_ref.h" | 14 #include "ppapi/c/ppb_file_ref.h" |
| 13 #include "ppapi/shared_impl/ppb_file_ref_shared.h" | 15 #include "ppapi/shared_impl/ppb_file_ref_shared.h" |
| 14 #include "ppapi/shared_impl/var.h" | 16 #include "ppapi/shared_impl/var.h" |
| 15 #include "webkit/glue/webkit_glue_export.h" | 17 #include "webkit/glue/webkit_glue_export.h" |
| 16 | 18 |
| 17 namespace webkit { | 19 namespace webkit { |
| 18 namespace ppapi { | 20 namespace ppapi { |
| 19 | 21 |
| 20 using ::ppapi::StringVar; | 22 using ::ppapi::StringVar; |
| 21 | 23 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 46 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE; | 48 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE; |
| 47 virtual int32_t Touch( | 49 virtual int32_t Touch( |
| 48 PP_Time last_access_time, | 50 PP_Time last_access_time, |
| 49 PP_Time last_modified_time, | 51 PP_Time last_modified_time, |
| 50 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE; | 52 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE; |
| 51 virtual int32_t Delete( | 53 virtual int32_t Delete( |
| 52 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE; | 54 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE; |
| 53 virtual int32_t Rename( | 55 virtual int32_t Rename( |
| 54 PP_Resource new_file_ref, | 56 PP_Resource new_file_ref, |
| 55 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE; | 57 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE; |
| 58 virtual int32_t Query( |
| 59 PP_FileInfo* info, |
| 60 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE; |
| 56 virtual PP_Var GetAbsolutePath(); | 61 virtual PP_Var GetAbsolutePath(); |
| 57 | 62 |
| 58 PPB_FileSystem_Impl* file_system() const { return file_system_.get(); } | 63 PPB_FileSystem_Impl* file_system() const { return file_system_.get(); } |
| 59 | 64 |
| 60 // Returns the system path corresponding to this file. Valid only for | 65 // Returns the system path corresponding to this file. Valid only for |
| 61 // external filesystems. | 66 // external filesystems. |
| 62 base::FilePath GetSystemPath() const; | 67 base::FilePath GetSystemPath() const; |
| 63 | 68 |
| 64 // Returns the FileSystem API URL corresponding to this file. | 69 // Returns the FileSystem API URL corresponding to this file. |
| 65 GURL GetFileSystemURL() const; | 70 GURL GetFileSystemURL() const; |
| 66 | 71 |
| 67 // Checks if file ref has file system instance and if the instance is opened. | 72 // Checks if file ref has file system instance and if the instance is opened. |
| 68 bool HasValidFileSystem() const; | 73 bool HasValidFileSystem() const; |
| 69 private: | 74 private: |
| 75 void QueryCallback(PP_FileInfo* info, |
| 76 scoped_refptr< ::ppapi::TrackedCallback> callback, |
| 77 base::PlatformFileError error_code, |
| 78 base::PassPlatformFile passed_file); |
| 79 void GetFileInfoCallback(PP_FileInfo* info, |
| 80 scoped_refptr< ::ppapi::TrackedCallback> callback, |
| 81 base::PlatformFileError error_code, |
| 82 const base::PlatformFileInfo& file_info); |
| 83 |
| 70 // Many mutation functions are allow only to non-external filesystems, This | 84 // Many mutation functions are allow only to non-external filesystems, This |
| 71 // function returns true if the filesystem is opened and isn't external as an | 85 // function returns true if the filesystem is opened and isn't external as an |
| 72 // access check for these functions. | 86 // access check for these functions. |
| 73 bool IsValidNonExternalFileSystem() const; | 87 bool IsValidNonExternalFileSystem() const; |
| 74 | 88 |
| 75 // Null for external filesystems. | 89 // Null for external filesystems. |
| 76 scoped_refptr<PPB_FileSystem_Impl> file_system_; | 90 scoped_refptr<PPB_FileSystem_Impl> file_system_; |
| 77 | 91 |
| 78 // Used only for external filesystems. | 92 // Used only for external filesystems. |
| 79 base::FilePath external_file_system_path_; | 93 base::FilePath external_file_system_path_; |
| 80 | 94 |
| 81 // Lazily initialized var created from the external path. This is so we can | 95 // Lazily initialized var created from the external path. This is so we can |
| 82 // return the identical string object every time it is requested. | 96 // return the identical string object every time it is requested. |
| 83 scoped_refptr<StringVar> external_path_var_; | 97 scoped_refptr<StringVar> external_path_var_; |
| 84 | 98 |
| 99 // This class makes asynchronous calls to perform file operations to support |
| 100 // Query(). |
| 101 base::WeakPtrFactory<PPB_FileRef_Impl> weak_factory_; |
| 102 |
| 85 DISALLOW_COPY_AND_ASSIGN(PPB_FileRef_Impl); | 103 DISALLOW_COPY_AND_ASSIGN(PPB_FileRef_Impl); |
| 86 }; | 104 }; |
| 87 | 105 |
| 88 } // namespace ppapi | 106 } // namespace ppapi |
| 89 } // namespace webkit | 107 } // namespace webkit |
| 90 | 108 |
| 91 #endif // WEBKIT_PLUGINS_PPAPI_PPB_FILE_REF_IMPL_H_ | 109 #endif // WEBKIT_PLUGINS_PPAPI_PPB_FILE_REF_IMPL_H_ |
| OLD | NEW |