| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 CHROME_COMMON_FILE_SYSTEM_FILE_SYSTEM_DISPATCHER_H_ | 5 #ifndef CHROME_COMMON_FILE_SYSTEM_FILE_SYSTEM_DISPATCHER_H_ |
| 6 #define CHROME_COMMON_FILE_SYSTEM_FILE_SYSTEM_DISPATCHER_H_ | 6 #define CHROME_COMMON_FILE_SYSTEM_FILE_SYSTEM_DISPATCHER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/id_map.h" | 11 #include "base/id_map.h" |
| 12 #include "base/nullable_string16.h" | 12 #include "base/nullable_string16.h" |
| 13 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
| 14 #include "ipc/ipc_channel.h" | 14 #include "ipc/ipc_channel.h" |
| 15 #include "ipc/ipc_message.h" | 15 #include "ipc/ipc_message.h" |
| 16 #include "third_party/WebKit/WebKit/chromium/public/WebFileError.h" |
| 16 | 17 |
| 17 namespace WebKit { | 18 namespace WebKit { |
| 19 struct WebFileInfo; |
| 18 class WebFileSystemCallbacks; | 20 class WebFileSystemCallbacks; |
| 21 struct WebFileSystemEntry; |
| 19 } | 22 } |
| 20 | 23 |
| 24 namespace file_util { |
| 25 struct FileInfo; |
| 26 } |
| 27 |
| 28 struct ViewMsg_FileSystem_DidReadDirectory_Params; |
| 29 |
| 21 // Dispatches and sends file system related messages sent to/from a child | 30 // Dispatches and sends file system related messages sent to/from a child |
| 22 // process from/to the main browser process. There is one instance | 31 // process from/to the main browser process. There is one instance |
| 23 // per child process. Messages are dispatched on the main child thread. | 32 // per child process. Messages are dispatched on the main child thread. |
| 24 class FileSystemDispatcher { | 33 class FileSystemDispatcher { |
| 25 public: | 34 public: |
| 26 FileSystemDispatcher(); | 35 FileSystemDispatcher(); |
| 27 ~FileSystemDispatcher(); | 36 ~FileSystemDispatcher(); |
| 28 | 37 |
| 29 bool OnMessageReceived(const IPC::Message& msg); | 38 bool OnMessageReceived(const IPC::Message& msg); |
| 30 | 39 |
| 31 void Move( | 40 void Move( |
| 32 const string16& src_path, | 41 const string16& src_path, |
| 33 const string16& dest_path, | 42 const string16& dest_path, |
| 34 WebKit::WebFileSystemCallbacks* callbacks); | 43 WebKit::WebFileSystemCallbacks* callbacks); |
| 35 | 44 void Copy( |
| 36 // TODO(kinuko): add more implementation. | 45 const string16& src_path, |
| 46 const string16& dest_path, |
| 47 WebKit::WebFileSystemCallbacks* callbacks); |
| 48 void Remove( |
| 49 const string16& path, |
| 50 WebKit::WebFileSystemCallbacks* callbacks); |
| 51 void ReadMetadata( |
| 52 const string16& path, |
| 53 WebKit::WebFileSystemCallbacks* callbacks); |
| 54 void Create( |
| 55 const string16& path, |
| 56 bool exclusive, |
| 57 bool for_directory, |
| 58 WebKit::WebFileSystemCallbacks* callbacks); |
| 59 void Exists( |
| 60 const string16& path, |
| 61 bool for_directory, |
| 62 WebKit::WebFileSystemCallbacks* callbacks); |
| 63 void ReadDirectory( |
| 64 const string16& path, |
| 65 WebKit::WebFileSystemCallbacks* callbacks); |
| 37 | 66 |
| 38 private: | 67 private: |
| 39 void DidSucceed(int32 callbacks_id); | 68 void DidSucceed(int request_id); |
| 40 void DidFail(int32 callbacks_id, int code); | 69 void DidReadMetadata( |
| 41 // TODO(kinuko): add more callbacks. | 70 int request_id, |
| 71 const file_util::FileInfo& file_info); |
| 72 void DidReadDirectory( |
| 73 const ViewMsg_FileSystem_DidReadDirectory_Params& params); |
| 74 void DidFail( |
| 75 int request_id, |
| 76 WebKit::WebFileError); |
| 42 | 77 |
| 43 IDMap<WebKit::WebFileSystemCallbacks> callbacks_; | 78 IDMap<WebKit::WebFileSystemCallbacks> callbacks_; |
| 44 | 79 |
| 45 DISALLOW_COPY_AND_ASSIGN(FileSystemDispatcher); | 80 DISALLOW_COPY_AND_ASSIGN(FileSystemDispatcher); |
| 46 }; | 81 }; |
| 47 | 82 |
| 48 #endif // CHROME_COMMON_FILE_SYSTEM_FILE_SYSTEM_DISPATCHER_H_ | 83 #endif // CHROME_COMMON_FILE_SYSTEM_FILE_SYSTEM_DISPATCHER_H_ |
| OLD | NEW |