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

Side by Side Diff: webkit/browser/fileapi/file_system_operation_impl.cc

Issue 291513003: Remove PlatformFile from fileapi::FileSystemOperation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "webkit/browser/fileapi/file_system_operation_impl.h" 5 #include "webkit/browser/fileapi/file_system_operation_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/single_thread_task_runner.h" 8 #include "base/single_thread_task_runner.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 base::Bind(&FileSystemOperationImpl::DidFinishOperation, 196 base::Bind(&FileSystemOperationImpl::DidFinishOperation,
197 weak_factory_.GetWeakPtr(), callback)); 197 weak_factory_.GetWeakPtr(), callback));
198 } 198 }
199 199
200 void FileSystemOperationImpl::OpenFile(const FileSystemURL& url, 200 void FileSystemOperationImpl::OpenFile(const FileSystemURL& url,
201 int file_flags, 201 int file_flags,
202 const OpenFileCallback& callback) { 202 const OpenFileCallback& callback) {
203 DCHECK(SetPendingOperationType(kOperationOpenFile)); 203 DCHECK(SetPendingOperationType(kOperationOpenFile));
204 204
205 if (file_flags & 205 if (file_flags &
206 (base::PLATFORM_FILE_TEMPORARY | base::PLATFORM_FILE_HIDDEN)) { 206 (base::File::FLAG_TEMPORARY | base::File::FLAG_HIDDEN)) {
207 callback.Run(base::File::FILE_ERROR_FAILED, 207 callback.Run(base::File(base::File::FILE_ERROR_FAILED),
208 base::kInvalidPlatformFileValue,
209 base::Closure()); 208 base::Closure());
210 return; 209 return;
211 } 210 }
212 GetUsageAndQuotaThenRunTask( 211 GetUsageAndQuotaThenRunTask(
213 url, 212 url,
214 base::Bind(&FileSystemOperationImpl::DoOpenFile, 213 base::Bind(&FileSystemOperationImpl::DoOpenFile,
215 weak_factory_.GetWeakPtr(), 214 weak_factory_.GetWeakPtr(),
216 url, callback, file_flags), 215 url, callback, file_flags),
217 base::Bind(callback, base::File::FILE_ERROR_FAILED, 216 base::Bind(callback, Passed(base::File(base::File::FILE_ERROR_FAILED)),
218 base::kInvalidPlatformFileValue,
219 base::Closure())); 217 base::Closure()));
220 } 218 }
221 219
222 // We can only get here on a write or truncate that's not yet completed. 220 // We can only get here on a write or truncate that's not yet completed.
223 // We don't support cancelling any other operation at this time. 221 // We don't support cancelling any other operation at this time.
224 void FileSystemOperationImpl::Cancel(const StatusCallback& cancel_callback) { 222 void FileSystemOperationImpl::Cancel(const StatusCallback& cancel_callback) {
225 DCHECK(cancel_callback_.is_null()); 223 DCHECK(cancel_callback_.is_null());
226 cancel_callback_ = cancel_callback; 224 cancel_callback_ = cancel_callback;
227 225
228 if (file_writer_delegate_.get()) { 226 if (file_writer_delegate_.get()) {
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 StatusCallback cancel_callback = cancel_callback_; 538 StatusCallback cancel_callback = cancel_callback_;
541 write_callback.Run(rv, bytes, complete); 539 write_callback.Run(rv, bytes, complete);
542 if (!cancel_callback.is_null()) 540 if (!cancel_callback.is_null())
543 cancel_callback.Run(base::File::FILE_OK); 541 cancel_callback.Run(base::File::FILE_OK);
544 } 542 }
545 543
546 void FileSystemOperationImpl::DidOpenFile( 544 void FileSystemOperationImpl::DidOpenFile(
547 const OpenFileCallback& callback, 545 const OpenFileCallback& callback,
548 base::File file, 546 base::File file,
549 const base::Closure& on_close_callback) { 547 const base::Closure& on_close_callback) {
550 // TODO(rvargas): Remove PlatformFile from FileSystemOperation. 548 callback.Run(file.Pass(), on_close_callback);
551 base::File::Error error;
552 base::PlatformFile platform_file;
553 if (file.IsValid()) {
554 error = base::File::FILE_OK;
555 platform_file = file.TakePlatformFile();
556 } else {
557 error = file.error_details();
558 platform_file = base::kInvalidPlatformFileValue;
559 }
560 callback.Run(error, platform_file, on_close_callback);
561 } 549 }
562 550
563 bool FileSystemOperationImpl::SetPendingOperationType(OperationType type) { 551 bool FileSystemOperationImpl::SetPendingOperationType(OperationType type) {
564 if (pending_operation_ != kOperationNone) 552 if (pending_operation_ != kOperationNone)
565 return false; 553 return false;
566 pending_operation_ = type; 554 pending_operation_ = type;
567 return true; 555 return true;
568 } 556 }
569 557
570 } // namespace fileapi 558 } // namespace fileapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698