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 #include "chrome/browser/file_system/file_system_dispatcher_host.h" | 5 #include "chrome/browser/file_system/file_system_dispatcher_host.h" |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/thread.h" | 8 #include "base/thread.h" |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 bool handled = true; | 108 bool handled = true; |
109 IPC_BEGIN_MESSAGE_MAP_EX(FileSystemDispatcherHost, message, *message_was_ok) | 109 IPC_BEGIN_MESSAGE_MAP_EX(FileSystemDispatcherHost, message, *message_was_ok) |
110 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenFileSystemRequest, OnOpenFileSystem) | 110 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenFileSystemRequest, OnOpenFileSystem) |
111 IPC_MESSAGE_HANDLER(ViewHostMsg_FileSystem_Move, OnMove) | 111 IPC_MESSAGE_HANDLER(ViewHostMsg_FileSystem_Move, OnMove) |
112 IPC_MESSAGE_HANDLER(ViewHostMsg_FileSystem_Copy, OnCopy) | 112 IPC_MESSAGE_HANDLER(ViewHostMsg_FileSystem_Copy, OnCopy) |
113 IPC_MESSAGE_HANDLER(ViewHostMsg_FileSystem_Remove, OnRemove) | 113 IPC_MESSAGE_HANDLER(ViewHostMsg_FileSystem_Remove, OnRemove) |
114 IPC_MESSAGE_HANDLER(ViewHostMsg_FileSystem_ReadMetadata, OnReadMetadata) | 114 IPC_MESSAGE_HANDLER(ViewHostMsg_FileSystem_ReadMetadata, OnReadMetadata) |
115 IPC_MESSAGE_HANDLER(ViewHostMsg_FileSystem_Create, OnCreate) | 115 IPC_MESSAGE_HANDLER(ViewHostMsg_FileSystem_Create, OnCreate) |
116 IPC_MESSAGE_HANDLER(ViewHostMsg_FileSystem_Exists, OnExists) | 116 IPC_MESSAGE_HANDLER(ViewHostMsg_FileSystem_Exists, OnExists) |
117 IPC_MESSAGE_HANDLER(ViewHostMsg_FileSystem_ReadDirectory, OnReadDirectory) | 117 IPC_MESSAGE_HANDLER(ViewHostMsg_FileSystem_ReadDirectory, OnReadDirectory) |
| 118 IPC_MESSAGE_HANDLER(ViewHostMsg_FileSystem_TouchFile, OnTouchFile) |
118 IPC_MESSAGE_UNHANDLED(handled = false) | 119 IPC_MESSAGE_UNHANDLED(handled = false) |
119 IPC_END_MESSAGE_MAP_EX() | 120 IPC_END_MESSAGE_MAP_EX() |
120 return handled; | 121 return handled; |
121 } | 122 } |
122 | 123 |
123 void FileSystemDispatcherHost::OnOpenFileSystem( | 124 void FileSystemDispatcherHost::OnOpenFileSystem( |
124 const ViewHostMsg_OpenFileSystemRequest_Params& params) { | 125 const ViewHostMsg_OpenFileSystemRequest_Params& params) { |
125 | 126 |
126 // TODO(kinuko): hook up ContentSettings cookies type checks. | 127 // TODO(kinuko): hook up ContentSettings cookies type checks. |
127 | 128 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 GetNewOperation(request_id)->FileExists(path); | 200 GetNewOperation(request_id)->FileExists(path); |
200 } | 201 } |
201 | 202 |
202 void FileSystemDispatcherHost::OnReadDirectory( | 203 void FileSystemDispatcherHost::OnReadDirectory( |
203 int request_id, const FilePath& path) { | 204 int request_id, const FilePath& path) { |
204 if (!CheckValidFileSystemPath(path, request_id)) | 205 if (!CheckValidFileSystemPath(path, request_id)) |
205 return; | 206 return; |
206 GetNewOperation(request_id)->ReadDirectory(path); | 207 GetNewOperation(request_id)->ReadDirectory(path); |
207 } | 208 } |
208 | 209 |
| 210 void FileSystemDispatcherHost::OnTouchFile( |
| 211 int request_id, |
| 212 const FilePath& path, |
| 213 const base::Time& last_access_time, |
| 214 const base::Time& last_modified_time) { |
| 215 if (!CheckValidFileSystemPath(path, request_id)) |
| 216 return; |
| 217 GetNewOperation(request_id)->TouchFile( |
| 218 path, last_access_time, last_modified_time); |
| 219 } |
| 220 |
209 void FileSystemDispatcherHost::Send(IPC::Message* message) { | 221 void FileSystemDispatcherHost::Send(IPC::Message* message) { |
210 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); | 222 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); |
211 if (!shutdown_ && message_sender_) | 223 if (!shutdown_ && message_sender_) |
212 message_sender_->Send(message); | 224 message_sender_->Send(message); |
213 else | 225 else |
214 delete message; | 226 delete message; |
215 } | 227 } |
216 | 228 |
217 bool FileSystemDispatcherHost::CheckValidFileSystemPath( | 229 bool FileSystemDispatcherHost::CheckValidFileSystemPath( |
218 const FilePath& path, int request_id) { | 230 const FilePath& path, int request_id) { |
(...skipping 15 matching lines...) Expand all Loading... |
234 dispatcher, | 246 dispatcher, |
235 ChromeThread::GetMessageLoopProxyForThread(ChromeThread::FILE)); | 247 ChromeThread::GetMessageLoopProxyForThread(ChromeThread::FILE)); |
236 operations_.AddWithID(operation, request_id); | 248 operations_.AddWithID(operation, request_id); |
237 return operation; | 249 return operation; |
238 } | 250 } |
239 | 251 |
240 void FileSystemDispatcherHost::RemoveCompletedOperation(int request_id) { | 252 void FileSystemDispatcherHost::RemoveCompletedOperation(int request_id) { |
241 DCHECK(operations_.Lookup(request_id)); | 253 DCHECK(operations_.Lookup(request_id)); |
242 operations_.Remove(request_id); | 254 operations_.Remove(request_id); |
243 } | 255 } |
OLD | NEW |