Chromium Code Reviews| 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_FILE_CALLBACKS_H_ | 5 #ifndef WEBKIT_PLUGINS_PPAPI_FILE_CALLBACKS_H_ |
| 6 #define WEBKIT_PLUGINS_PPAPI_FILE_CALLBACKS_H_ | 6 #define WEBKIT_PLUGINS_PPAPI_FILE_CALLBACKS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/files/file_util_proxy.h" | |
| 11 #include "base/memory/linked_ptr.h" | 12 #include "base/memory/linked_ptr.h" |
| 12 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 14 #include "base/platform_file.h" | 15 #include "base/platform_file.h" |
| 15 #include "googleurl/src/gurl.h" | 16 #include "googleurl/src/gurl.h" |
| 16 #include "ppapi/c/pp_array_output.h" | 17 #include "ppapi/c/pp_array_output.h" |
| 17 #include "ppapi/c/pp_completion_callback.h" | 18 #include "ppapi/c/pp_completion_callback.h" |
| 18 #include "ppapi/c/pp_file_info.h" | 19 #include "ppapi/c/pp_file_info.h" |
| 19 #include "ppapi/c/pp_resource.h" | 20 #include "ppapi/c/pp_resource.h" |
| 20 #include "webkit/fileapi/file_system_callback_dispatcher.h" | |
| 21 | 21 |
| 22 struct PP_FileInfo; | 22 struct PP_FileInfo; |
| 23 | 23 |
| 24 namespace base { | 24 namespace base { |
| 25 class FilePath; | 25 class FilePath; |
| 26 } | 26 } |
| 27 | 27 |
| 28 namespace ppapi { | 28 namespace ppapi { |
| 29 class Resource; | 29 class Resource; |
| 30 class TrackedCallback; | 30 class TrackedCallback; |
| 31 struct PPB_FileRef_CreateInfo; | 31 struct PPB_FileRef_CreateInfo; |
| 32 } | 32 } |
| 33 | 33 |
| 34 namespace webkit { | 34 namespace webkit { |
| 35 namespace ppapi { | 35 namespace ppapi { |
| 36 | 36 |
| 37 class PPB_FileRef_Impl; | 37 class PPB_FileRef_Impl; |
| 38 | 38 |
| 39 // Instances of this class are deleted by FileSystemDispatcher. | 39 // Callback handler implementation for FileSystem related API. |
| 40 class FileCallbacks : public fileapi::FileSystemCallbackDispatcher { | 40 class FileCallbacks { |
|
yzshen1
2013/05/14 16:50:09
It seems good to change ppb_file_ref_impl and get
kinuko
2013/05/15 13:58:03
Done.
I was going to cut a separate CL, but have
| |
| 41 typedef std::vector< ::ppapi::PPB_FileRef_CreateInfo> CreateInfos; | 41 typedef std::vector< ::ppapi::PPB_FileRef_CreateInfo> CreateInfos; |
| 42 typedef std::vector<PP_FileType> FileTypes; | 42 typedef std::vector<PP_FileType> FileTypes; |
| 43 | 43 |
| 44 public: | 44 public: |
| 45 // Doesn't take the ownership of members. | 45 // Doesn't take the ownership of members. |
| 46 struct ReadDirectoryEntriesParams { | 46 struct ReadDirectoryEntriesParams { |
| 47 PPB_FileRef_Impl* dir_ref; | 47 PPB_FileRef_Impl* dir_ref; |
| 48 linked_ptr<CreateInfos> files; | 48 linked_ptr<CreateInfos> files; |
| 49 linked_ptr<FileTypes> file_types; | 49 linked_ptr<FileTypes> file_types; |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 FileCallbacks(::ppapi::Resource* resource, | 52 FileCallbacks(::ppapi::Resource* resource, |
| 53 scoped_refptr< ::ppapi::TrackedCallback> callback); | 53 scoped_refptr< ::ppapi::TrackedCallback> callback); |
| 54 FileCallbacks(::ppapi::Resource* resource, | 54 FileCallbacks(::ppapi::Resource* resource, |
| 55 scoped_refptr< ::ppapi::TrackedCallback> callback, | 55 scoped_refptr< ::ppapi::TrackedCallback> callback, |
| 56 linked_ptr<PP_FileInfo> info, | 56 linked_ptr<PP_FileInfo> info, |
| 57 PP_FileSystemType file_system_type); | 57 PP_FileSystemType file_system_type); |
| 58 FileCallbacks(::ppapi::Resource* resource, | 58 FileCallbacks(::ppapi::Resource* resource, |
| 59 scoped_refptr< ::ppapi::TrackedCallback> callback, | 59 scoped_refptr< ::ppapi::TrackedCallback> callback, |
| 60 const ReadDirectoryEntriesParams& params); | 60 const ReadDirectoryEntriesParams& params); |
| 61 virtual ~FileCallbacks(); | 61 virtual ~FileCallbacks(); |
| 62 | 62 |
| 63 // FileSystemCallbackDispatcher implementation. | 63 void DidFinish(base::PlatformFileError error_code); |
| 64 virtual void DidSucceed(); | 64 void DidReadMetadata( |
| 65 virtual void DidReadMetadata( | 65 base::PlatformFileError error_code, |
| 66 const base::PlatformFileInfo& file_info, | 66 const base::PlatformFileInfo& file_info, |
| 67 const base::FilePath& unused); | 67 const base::FilePath& unused); |
| 68 virtual void DidCreateSnapshotFile( | 68 void DidReadDirectory( |
| 69 const base::PlatformFileInfo& file_info, | 69 base::PlatformFileError error_code, |
| 70 const base::FilePath& path); | 70 const std::vector<base::FileUtilProxy::Entry>& entries, |
| 71 virtual void DidReadDirectory( | 71 bool has_more); |
| 72 const std::vector<base::FileUtilProxy::Entry>& entries, bool has_more); | |
| 73 virtual void DidOpenFileSystem(const std::string&, | |
| 74 const GURL& root_url); | |
| 75 virtual void DidFail(base::PlatformFileError error_code); | |
| 76 virtual void DidWrite(int64 bytes, bool complete); | |
| 77 | 72 |
| 78 scoped_refptr< ::ppapi::TrackedCallback> GetTrackedCallback() const; | 73 scoped_refptr< ::ppapi::TrackedCallback> GetTrackedCallback() const; |
| 79 | 74 |
| 80 private: | 75 private: |
| 81 void RunCallback(base::PlatformFileError error_code); | 76 void RunCallback(base::PlatformFileError error_code); |
| 82 | 77 |
| 83 scoped_refptr< ::ppapi::TrackedCallback> callback_; | 78 scoped_refptr< ::ppapi::TrackedCallback> callback_; |
| 84 linked_ptr<PP_FileInfo> info_; | 79 linked_ptr<PP_FileInfo> info_; |
| 85 PP_FileSystemType file_system_type_; | 80 PP_FileSystemType file_system_type_; |
| 86 PPB_FileRef_Impl* read_entries_dir_ref_; | 81 PPB_FileRef_Impl* read_entries_dir_ref_; |
| 87 linked_ptr<CreateInfos> read_entries_files_; | 82 linked_ptr<CreateInfos> read_entries_files_; |
| 88 linked_ptr<FileTypes> read_entries_file_types_; | 83 linked_ptr<FileTypes> read_entries_file_types_; |
| 89 }; | 84 }; |
| 90 | 85 |
| 91 } // namespace ppapi | 86 } // namespace ppapi |
| 92 } // namespace webkit | 87 } // namespace webkit |
| 93 | 88 |
| 94 #endif // WEBKIT_PLUGINS_PPAPI_FILE_CALLBACKS_H_ | 89 #endif // WEBKIT_PLUGINS_PPAPI_FILE_CALLBACKS_H_ |
| OLD | NEW |