| 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 // The cancel will eventually send both the write failure and the cancel | 241 write->Cancel(); |
| 242 // success. | 242 Send(new ViewMsg_FileSystem_DidSucceed(request_id)); |
| 243 write->Cancel(GetNewOperation(request_id)); | |
| 244 } else { | 243 } else { |
| 245 // The write already finished; report that we failed to stop it. | |
| 246 Send(new ViewMsg_FileSystem_DidFail( | 244 Send(new ViewMsg_FileSystem_DidFail( |
| 247 request_id, base::PLATFORM_FILE_ERROR_INVALID_OPERATION)); | 245 request_id, base::PLATFORM_FILE_ERROR_INVALID_OPERATION)); |
| 248 } | 246 } |
| 249 } | 247 } |
| 250 | 248 |
| 251 void FileSystemDispatcherHost::Send(IPC::Message* message) { | 249 void FileSystemDispatcherHost::Send(IPC::Message* message) { |
| 252 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); | 250 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); |
| 253 if (!shutdown_ && message_sender_) | 251 if (!shutdown_ && message_sender_) |
| 254 message_sender_->Send(message); | 252 message_sender_->Send(message); |
| 255 else | 253 else |
| (...skipping 20 matching lines...) Expand all Loading... |
| 276 dispatcher, | 274 dispatcher, |
| 277 ChromeThread::GetMessageLoopProxyForThread(ChromeThread::FILE)); | 275 ChromeThread::GetMessageLoopProxyForThread(ChromeThread::FILE)); |
| 278 operations_.AddWithID(operation, request_id); | 276 operations_.AddWithID(operation, request_id); |
| 279 return operation; | 277 return operation; |
| 280 } | 278 } |
| 281 | 279 |
| 282 void FileSystemDispatcherHost::RemoveCompletedOperation(int request_id) { | 280 void FileSystemDispatcherHost::RemoveCompletedOperation(int request_id) { |
| 283 DCHECK(operations_.Lookup(request_id)); | 281 DCHECK(operations_.Lookup(request_id)); |
| 284 operations_.Remove(request_id); | 282 operations_.Remove(request_id); |
| 285 } | 283 } |
| OLD | NEW |