OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/chromeos/file_system_provider/throttled_file_system.h" | 5 #include "chrome/browser/chromeos/file_system_provider/throttled_file_system.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 } | 188 } |
189 | 189 |
190 void ThrottledFileSystem::Abort(int queue_token) { | 190 void ThrottledFileSystem::Abort(int queue_token) { |
191 open_queue_->Abort(queue_token); | 191 open_queue_->Abort(queue_token); |
192 } | 192 } |
193 | 193 |
194 void ThrottledFileSystem::OnOpenFileCompleted(int queue_token, | 194 void ThrottledFileSystem::OnOpenFileCompleted(int queue_token, |
195 const OpenFileCallback& callback, | 195 const OpenFileCallback& callback, |
196 int file_handle, | 196 int file_handle, |
197 base::File::Error result) { | 197 base::File::Error result) { |
198 if (result != base::File::FILE_ERROR_ABORT) | 198 // The task may be aborted either via the callback, or by the operation, eg. |
| 199 // because of destroying the request manager or unmounting the file system |
| 200 // during the operation. Mark the task as completed only if it hasn't been |
| 201 // aborted before. |
| 202 if (!open_queue_->IsAborted(queue_token)) |
199 open_queue_->Complete(queue_token); | 203 open_queue_->Complete(queue_token); |
200 | 204 |
201 // If the file is opened successfully then hold the queue token until the file | 205 // If the file is opened successfully then hold the queue token until the file |
202 // is closed. | 206 // is closed. |
203 if (result == base::File::FILE_OK) | 207 if (result == base::File::FILE_OK) |
204 opened_files_[file_handle] = queue_token; | 208 opened_files_[file_handle] = queue_token; |
205 else | 209 else |
206 open_queue_->Remove(queue_token); | 210 open_queue_->Remove(queue_token); |
207 | 211 |
208 callback.Run(file_handle, result); | 212 callback.Run(file_handle, result); |
(...skipping 11 matching lines...) Expand all Loading... |
220 | 224 |
221 const int queue_token = it->second; | 225 const int queue_token = it->second; |
222 open_queue_->Remove(queue_token); | 226 open_queue_->Remove(queue_token); |
223 opened_files_.erase(file_handle); | 227 opened_files_.erase(file_handle); |
224 | 228 |
225 callback.Run(result); | 229 callback.Run(result); |
226 } | 230 } |
227 | 231 |
228 } // namespace file_system_provider | 232 } // namespace file_system_provider |
229 } // namespace chromeos | 233 } // namespace chromeos |
OLD | NEW |