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 "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 GetNewOperation(request_id)->TouchFile( | 231 GetNewOperation(request_id)->TouchFile( |
232 path, last_access_time, last_modified_time); | 232 path, last_access_time, last_modified_time); |
233 } | 233 } |
234 | 234 |
235 void FileSystemDispatcherHost::OnCancel( | 235 void FileSystemDispatcherHost::OnCancel( |
236 int request_id, | 236 int request_id, |
237 int request_id_to_cancel) { | 237 int request_id_to_cancel) { |
238 fileapi::FileSystemOperation* write = | 238 fileapi::FileSystemOperation* write = |
239 operations_.Lookup(request_id_to_cancel); | 239 operations_.Lookup(request_id_to_cancel); |
240 if (write) { | 240 if (write) { |
241 write->Cancel(); | 241 // The cancel will eventually send both the write failure and the cancel |
242 Send(new ViewMsg_FileSystem_DidSucceed(request_id)); | 242 // success. |
| 243 write->Cancel(GetNewOperation(request_id)); |
243 } else { | 244 } else { |
| 245 // The write already finished; report that we failed to stop it. |
244 Send(new ViewMsg_FileSystem_DidFail( | 246 Send(new ViewMsg_FileSystem_DidFail( |
245 request_id, base::PLATFORM_FILE_ERROR_INVALID_OPERATION)); | 247 request_id, base::PLATFORM_FILE_ERROR_INVALID_OPERATION)); |
246 } | 248 } |
247 } | 249 } |
248 | 250 |
249 void FileSystemDispatcherHost::Send(IPC::Message* message) { | 251 void FileSystemDispatcherHost::Send(IPC::Message* message) { |
250 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); | 252 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); |
251 if (!shutdown_ && message_sender_) | 253 if (!shutdown_ && message_sender_) |
252 message_sender_->Send(message); | 254 message_sender_->Send(message); |
253 else | 255 else |
(...skipping 20 matching lines...) Expand all Loading... |
274 dispatcher, | 276 dispatcher, |
275 ChromeThread::GetMessageLoopProxyForThread(ChromeThread::FILE)); | 277 ChromeThread::GetMessageLoopProxyForThread(ChromeThread::FILE)); |
276 operations_.AddWithID(operation, request_id); | 278 operations_.AddWithID(operation, request_id); |
277 return operation; | 279 return operation; |
278 } | 280 } |
279 | 281 |
280 void FileSystemDispatcherHost::RemoveCompletedOperation(int request_id) { | 282 void FileSystemDispatcherHost::RemoveCompletedOperation(int request_id) { |
281 DCHECK(operations_.Lookup(request_id)); | 283 DCHECK(operations_.Lookup(request_id)); |
282 operations_.Remove(request_id); | 284 operations_.Remove(request_id); |
283 } | 285 } |
OLD | NEW |