Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(332)

Side by Side Diff: chrome/browser/chromeos/file_system_provider/throttled_file_system.cc

Issue 971303003: Simplify file_system_provider::Queue. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/chromeos/file_system_provider/queue_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 // 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))
203 open_queue_->Complete(queue_token);
204
205 // If the file is opened successfully then hold the queue token until the file 198 // If the file is opened successfully then hold the queue token until the file
206 // is closed. 199 // is closed.
207 if (result == base::File::FILE_OK) 200 if (result == base::File::FILE_OK)
208 opened_files_[file_handle] = queue_token; 201 opened_files_[file_handle] = queue_token;
209 else 202 else
210 open_queue_->Remove(queue_token); 203 open_queue_->Complete(queue_token);
211 204
212 callback.Run(file_handle, result); 205 callback.Run(file_handle, result);
213 } 206 }
214 207
215 void ThrottledFileSystem::OnCloseFileCompleted( 208 void ThrottledFileSystem::OnCloseFileCompleted(
216 int file_handle, 209 int file_handle,
217 const storage::AsyncFileUtil::StatusCallback& callback, 210 const storage::AsyncFileUtil::StatusCallback& callback,
218 base::File::Error result) { 211 base::File::Error result) {
219 // Closing is always final. Even if an error happened, the file is considered 212 // Closing is always final. Even if an error happened, the file is considered
220 // closed on the C++ side. Release the task from the queue, so other files 213 // closed on the C++ side. Release the task from the queue, so other files
221 // which are enqueued can be opened. 214 // which are enqueued can be opened.
222 const auto it = opened_files_.find(file_handle); 215 const auto it = opened_files_.find(file_handle);
223 CHECK(it != opened_files_.end()); 216 DCHECK(it != opened_files_.end());
224 217
225 const int queue_token = it->second; 218 const int queue_token = it->second;
226 open_queue_->Remove(queue_token); 219 open_queue_->Complete(queue_token);
227 opened_files_.erase(file_handle); 220 opened_files_.erase(file_handle);
228 221
229 callback.Run(result); 222 callback.Run(result);
230 } 223 }
231 224
232 } // namespace file_system_provider 225 } // namespace file_system_provider
233 } // namespace chromeos 226 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/file_system_provider/queue_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698