| 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_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/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/platform_file.h" | 13 #include "base/platform_file.h" |
| 14 #include "ppapi/c/pp_completion_callback.h" | 14 #include "ppapi/c/pp_completion_callback.h" |
| 15 #include "ppapi/c/pp_resource.h" | 15 #include "ppapi/c/pp_resource.h" |
| 16 #include "webkit/fileapi/file_system_callback_dispatcher.h" | 16 #include "webkit/fileapi/file_system_callback_dispatcher.h" |
| 17 | 17 |
| 18 struct PP_FileInfo; | 18 struct PP_FileInfo; |
| 19 | 19 |
| 20 namespace base { | 20 namespace base { |
| 21 class FilePath; | 21 class FilePath; |
| 22 } | 22 } |
| 23 | 23 |
| 24 namespace ppapi { |
| 25 class Resource; |
| 26 class TrackedCallback; |
| 27 } |
| 28 |
| 24 namespace webkit { | 29 namespace webkit { |
| 25 namespace ppapi { | 30 namespace ppapi { |
| 26 | 31 |
| 27 class PPB_DirectoryReader_Impl; | 32 class PPB_DirectoryReader_Impl; |
| 28 class PPB_FileSystem_Impl; | 33 class PPB_FileSystem_Impl; |
| 29 class PluginModule; | |
| 30 class TrackedCompletionCallback; | |
| 31 | 34 |
| 32 // Instances of this class are deleted by FileSystemDispatcher. | 35 // Instances of this class are deleted by FileSystemDispatcher. |
| 33 class FileCallbacks : public fileapi::FileSystemCallbackDispatcher { | 36 class FileCallbacks : public fileapi::FileSystemCallbackDispatcher { |
| 34 public: | 37 public: |
| 35 FileCallbacks(const base::WeakPtr<PluginModule>& module, | 38 FileCallbacks(::ppapi::Resource* resource, |
| 36 PP_Resource resource_id, | |
| 37 PP_CompletionCallback callback, | 39 PP_CompletionCallback callback, |
| 38 PP_FileInfo* info, | 40 PP_FileInfo* info, |
| 39 scoped_refptr<PPB_FileSystem_Impl> file_system, | 41 scoped_refptr<PPB_FileSystem_Impl> file_system, |
| 40 scoped_refptr<PPB_DirectoryReader_Impl> directory_reader); | 42 scoped_refptr<PPB_DirectoryReader_Impl> directory_reader); |
| 41 virtual ~FileCallbacks(); | 43 virtual ~FileCallbacks(); |
| 42 | 44 |
| 43 // FileSystemCallbackDispatcher implementation. | 45 // FileSystemCallbackDispatcher implementation. |
| 44 virtual void DidSucceed(); | 46 virtual void DidSucceed(); |
| 45 virtual void DidReadMetadata( | 47 virtual void DidReadMetadata( |
| 46 const base::PlatformFileInfo& file_info, | 48 const base::PlatformFileInfo& file_info, |
| 47 const FilePath& unused); | 49 const FilePath& unused); |
| 48 virtual void DidReadDirectory( | 50 virtual void DidReadDirectory( |
| 49 const std::vector<base::FileUtilProxy::Entry>& entries, bool has_more); | 51 const std::vector<base::FileUtilProxy::Entry>& entries, bool has_more); |
| 50 virtual void DidOpenFileSystem(const std::string&, | 52 virtual void DidOpenFileSystem(const std::string&, |
| 51 const GURL& root_url); | 53 const GURL& root_url); |
| 52 virtual void DidFail(base::PlatformFileError error_code); | 54 virtual void DidFail(base::PlatformFileError error_code); |
| 53 virtual void DidWrite(int64 bytes, bool complete); | 55 virtual void DidWrite(int64 bytes, bool complete); |
| 54 | 56 |
| 55 scoped_refptr<TrackedCompletionCallback> GetTrackedCompletionCallback() const; | 57 scoped_refptr< ::ppapi::TrackedCallback> GetTrackedCallback() const; |
| 56 | 58 |
| 57 private: | 59 private: |
| 58 void RunCallback(base::PlatformFileError error_code); | 60 void RunCallback(base::PlatformFileError error_code); |
| 59 | 61 |
| 60 scoped_refptr<TrackedCompletionCallback> callback_; | 62 scoped_refptr< ::ppapi::TrackedCallback> callback_; |
| 61 PP_FileInfo* info_; | 63 PP_FileInfo* info_; |
| 62 scoped_refptr<PPB_FileSystem_Impl> file_system_; | 64 scoped_refptr<PPB_FileSystem_Impl> file_system_; |
| 63 scoped_refptr<PPB_DirectoryReader_Impl> directory_reader_; | 65 scoped_refptr<PPB_DirectoryReader_Impl> directory_reader_; |
| 64 }; | 66 }; |
| 65 | 67 |
| 66 } // namespace ppapi | 68 } // namespace ppapi |
| 67 } // namespace webkit | 69 } // namespace webkit |
| 68 | 70 |
| 69 #endif // WEBKIT_PLUGINS_PPAPI_FILE_CALLBACKS_H_ | 71 #endif // WEBKIT_PLUGINS_PPAPI_FILE_CALLBACKS_H_ |
| OLD | NEW |