| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef WEBKIT_PLUGINS_PPAPI_FILE_CALLBACKS_H_ | |
| 6 #define WEBKIT_PLUGINS_PPAPI_FILE_CALLBACKS_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/memory/linked_ptr.h" | |
| 12 #include "base/memory/ref_counted.h" | |
| 13 #include "base/memory/weak_ptr.h" | |
| 14 #include "base/platform_file.h" | |
| 15 #include "googleurl/src/gurl.h" | |
| 16 #include "ppapi/c/pp_array_output.h" | |
| 17 #include "ppapi/c/pp_completion_callback.h" | |
| 18 #include "ppapi/c/pp_file_info.h" | |
| 19 #include "ppapi/c/pp_resource.h" | |
| 20 #include "webkit/fileapi/file_system_callback_dispatcher.h" | |
| 21 | |
| 22 struct PP_FileInfo; | |
| 23 | |
| 24 namespace base { | |
| 25 class FilePath; | |
| 26 } | |
| 27 | |
| 28 namespace ppapi { | |
| 29 class Resource; | |
| 30 class TrackedCallback; | |
| 31 struct PPB_FileRef_CreateInfo; | |
| 32 } | |
| 33 | |
| 34 namespace webkit { | |
| 35 namespace ppapi { | |
| 36 | |
| 37 class PPB_FileRef_Impl; | |
| 38 | |
| 39 // Instances of this class are deleted by FileSystemDispatcher. | |
| 40 class FileCallbacks : public fileapi::FileSystemCallbackDispatcher { | |
| 41 typedef std::vector< ::ppapi::PPB_FileRef_CreateInfo> CreateInfos; | |
| 42 typedef std::vector<PP_FileType> FileTypes; | |
| 43 | |
| 44 public: | |
| 45 // Doesn't take the ownership of members. | |
| 46 struct ReadDirectoryEntriesParams { | |
| 47 PPB_FileRef_Impl* dir_ref; | |
| 48 linked_ptr<CreateInfos> files; | |
| 49 linked_ptr<FileTypes> file_types; | |
| 50 }; | |
| 51 | |
| 52 FileCallbacks(::ppapi::Resource* resource, | |
| 53 scoped_refptr< ::ppapi::TrackedCallback> callback); | |
| 54 FileCallbacks(::ppapi::Resource* resource, | |
| 55 scoped_refptr< ::ppapi::TrackedCallback> callback, | |
| 56 linked_ptr<PP_FileInfo> info, | |
| 57 PP_FileSystemType file_system_type); | |
| 58 FileCallbacks(::ppapi::Resource* resource, | |
| 59 scoped_refptr< ::ppapi::TrackedCallback> callback, | |
| 60 const ReadDirectoryEntriesParams& params); | |
| 61 virtual ~FileCallbacks(); | |
| 62 | |
| 63 // FileSystemCallbackDispatcher implementation. | |
| 64 virtual void DidSucceed(); | |
| 65 virtual void DidReadMetadata( | |
| 66 const base::PlatformFileInfo& file_info, | |
| 67 const base::FilePath& unused); | |
| 68 virtual void DidCreateSnapshotFile( | |
| 69 const base::PlatformFileInfo& file_info, | |
| 70 const base::FilePath& path); | |
| 71 virtual void DidReadDirectory( | |
| 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 | |
| 78 scoped_refptr< ::ppapi::TrackedCallback> GetTrackedCallback() const; | |
| 79 | |
| 80 private: | |
| 81 void RunCallback(base::PlatformFileError error_code); | |
| 82 | |
| 83 scoped_refptr< ::ppapi::TrackedCallback> callback_; | |
| 84 linked_ptr<PP_FileInfo> info_; | |
| 85 PP_FileSystemType file_system_type_; | |
| 86 PPB_FileRef_Impl* read_entries_dir_ref_; | |
| 87 linked_ptr<CreateInfos> read_entries_files_; | |
| 88 linked_ptr<FileTypes> read_entries_file_types_; | |
| 89 }; | |
| 90 | |
| 91 } // namespace ppapi | |
| 92 } // namespace webkit | |
| 93 | |
| 94 #endif // WEBKIT_PLUGINS_PPAPI_FILE_CALLBACKS_H_ | |
| OLD | NEW |