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

Side by Side Diff: webkit/fileapi/local_file_system_operation.cc

Issue 14472008: [FileAPI] Add file open ID and close callback (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 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
« no previous file with comments | « webkit/fileapi/file_system_operation.h ('k') | webkit/fileapi/remote_file_system_proxy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/fileapi/local_file_system_operation.h" 5 #include "webkit/fileapi/local_file_system_operation.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/time.h" 9 #include "base/time.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 15 matching lines...) Expand all
26 #include "webkit/fileapi/remove_operation_delegate.h" 26 #include "webkit/fileapi/remove_operation_delegate.h"
27 #include "webkit/fileapi/sandbox_file_stream_writer.h" 27 #include "webkit/fileapi/sandbox_file_stream_writer.h"
28 #include "webkit/quota/quota_manager.h" 28 #include "webkit/quota/quota_manager.h"
29 #include "webkit/quota/quota_types.h" 29 #include "webkit/quota/quota_types.h"
30 30
31 using webkit_blob::ScopedFile; 31 using webkit_blob::ScopedFile;
32 using webkit_blob::ShareableFileReference; 32 using webkit_blob::ShareableFileReference;
33 33
34 namespace fileapi { 34 namespace fileapi {
35 35
36 namespace {
37 void NopCloseFileCallback() {}
38 }
39
36 LocalFileSystemOperation::LocalFileSystemOperation( 40 LocalFileSystemOperation::LocalFileSystemOperation(
37 FileSystemContext* file_system_context, 41 FileSystemContext* file_system_context,
38 scoped_ptr<FileSystemOperationContext> operation_context) 42 scoped_ptr<FileSystemOperationContext> operation_context)
39 : file_system_context_(file_system_context), 43 : file_system_context_(file_system_context),
40 operation_context_(operation_context.Pass()), 44 operation_context_(operation_context.Pass()),
41 async_file_util_(NULL), 45 async_file_util_(NULL),
42 peer_handle_(base::kNullProcessHandle), 46 peer_handle_(base::kNullProcessHandle),
43 pending_operation_(kOperationNone), 47 pending_operation_(kOperationNone),
44 weak_factory_(this) { 48 weak_factory_(this) {
45 DCHECK(operation_context_.get()); 49 DCHECK(operation_context_.get());
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 DCHECK(SetPendingOperationType(kOperationOpenFile)); 330 DCHECK(SetPendingOperationType(kOperationOpenFile));
327 scoped_ptr<LocalFileSystemOperation> deleter(this); 331 scoped_ptr<LocalFileSystemOperation> deleter(this);
328 332
329 peer_handle_ = peer_handle; 333 peer_handle_ = peer_handle;
330 334
331 if (file_flags & ( 335 if (file_flags & (
332 (base::PLATFORM_FILE_ENUMERATE | base::PLATFORM_FILE_TEMPORARY | 336 (base::PLATFORM_FILE_ENUMERATE | base::PLATFORM_FILE_TEMPORARY |
333 base::PLATFORM_FILE_HIDDEN))) { 337 base::PLATFORM_FILE_HIDDEN))) {
334 callback.Run(base::PLATFORM_FILE_ERROR_FAILED, 338 callback.Run(base::PLATFORM_FILE_ERROR_FAILED,
335 base::kInvalidPlatformFileValue, 339 base::kInvalidPlatformFileValue,
340 base::Closure(),
336 base::kNullProcessHandle); 341 base::kNullProcessHandle);
337 return; 342 return;
338 } 343 }
339 if (file_flags & 344 if (file_flags &
340 (base::PLATFORM_FILE_CREATE | base::PLATFORM_FILE_OPEN_ALWAYS | 345 (base::PLATFORM_FILE_CREATE | base::PLATFORM_FILE_OPEN_ALWAYS |
341 base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_OPEN_TRUNCATED | 346 base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_OPEN_TRUNCATED |
342 base::PLATFORM_FILE_WRITE | base::PLATFORM_FILE_EXCLUSIVE_WRITE | 347 base::PLATFORM_FILE_WRITE | base::PLATFORM_FILE_EXCLUSIVE_WRITE |
343 base::PLATFORM_FILE_DELETE_ON_CLOSE | 348 base::PLATFORM_FILE_DELETE_ON_CLOSE |
344 base::PLATFORM_FILE_WRITE_ATTRIBUTES)) { 349 base::PLATFORM_FILE_WRITE_ATTRIBUTES)) {
345 base::PlatformFileError result = SetUp(url, OPERATION_MODE_WRITE); 350 base::PlatformFileError result = SetUp(url, OPERATION_MODE_WRITE);
346 if (result != base::PLATFORM_FILE_OK) { 351 if (result != base::PLATFORM_FILE_OK) {
347 callback.Run(result, 352 callback.Run(result,
348 base::kInvalidPlatformFileValue, 353 base::kInvalidPlatformFileValue,
354 base::Closure(),
349 base::kNullProcessHandle); 355 base::kNullProcessHandle);
350 return; 356 return;
351 } 357 }
352 } else { 358 } else {
353 base::PlatformFileError result = SetUp(url, OPERATION_MODE_READ); 359 base::PlatformFileError result = SetUp(url, OPERATION_MODE_READ);
354 if (result != base::PLATFORM_FILE_OK) { 360 if (result != base::PLATFORM_FILE_OK) {
355 callback.Run(result, 361 callback.Run(result,
356 base::kInvalidPlatformFileValue, 362 base::kInvalidPlatformFileValue,
363 base::Closure(),
357 base::kNullProcessHandle); 364 base::kNullProcessHandle);
358 return; 365 return;
359 } 366 }
360 } 367 }
361 GetUsageAndQuotaThenRunTask( 368 GetUsageAndQuotaThenRunTask(
362 url, 369 url,
363 base::Bind(&LocalFileSystemOperation::DoOpenFile, 370 base::Bind(&LocalFileSystemOperation::DoOpenFile,
364 base::Unretained(deleter.release()), 371 base::Unretained(deleter.release()),
365 url, callback, file_flags), 372 url, callback, file_flags),
366 base::Bind(callback, base::PLATFORM_FILE_ERROR_FAILED, 373 base::Bind(callback, base::PLATFORM_FILE_ERROR_FAILED,
367 base::kInvalidPlatformFileValue, 374 base::kInvalidPlatformFileValue,
375 base::Closure(),
368 base::kNullProcessHandle)); 376 base::kNullProcessHandle));
369 } 377 }
370 378
371 void LocalFileSystemOperation::NotifyCloseFile(const FileSystemURL& url) { 379 void LocalFileSystemOperation::NotifyCloseFile(const FileSystemURL& url) {
372 // No particular task to do. This method is for remote file systems that 380 // No particular task to do. This method is for remote file systems that
373 // need synchronization with remote server. 381 // need synchronization with remote server.
374 delete this; 382 delete this;
375 } 383 }
376 384
377 // We can only get here on a write or truncate that's not yet completed. 385 // We can only get here on a write or truncate that's not yet completed.
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 callback.Run(rv); 826 callback.Run(rv);
819 } 827 }
820 828
821 void LocalFileSystemOperation::DidOpenFile( 829 void LocalFileSystemOperation::DidOpenFile(
822 const OpenFileCallback& callback, 830 const OpenFileCallback& callback,
823 base::PlatformFileError rv, 831 base::PlatformFileError rv,
824 base::PassPlatformFile file, 832 base::PassPlatformFile file,
825 bool unused) { 833 bool unused) {
826 if (rv == base::PLATFORM_FILE_OK) 834 if (rv == base::PLATFORM_FILE_OK)
827 CHECK_NE(base::kNullProcessHandle, peer_handle_); 835 CHECK_NE(base::kNullProcessHandle, peer_handle_);
828 callback.Run(rv, file.ReleaseValue(), peer_handle_); 836 callback.Run(rv, file.ReleaseValue(),
837 base::Bind(&NopCloseFileCallback),
838 peer_handle_);
829 } 839 }
830 840
831 void LocalFileSystemOperation::DidCreateSnapshotFile( 841 void LocalFileSystemOperation::DidCreateSnapshotFile(
832 const SnapshotFileCallback& callback, 842 const SnapshotFileCallback& callback,
833 base::PlatformFileError result, 843 base::PlatformFileError result,
834 const base::PlatformFileInfo& file_info, 844 const base::PlatformFileInfo& file_info,
835 const base::FilePath& platform_path, 845 const base::FilePath& platform_path,
836 const scoped_refptr<ShareableFileReference>& file_ref) { 846 const scoped_refptr<ShareableFileReference>& file_ref) {
837 callback.Run(result, file_info, platform_path, file_ref); 847 callback.Run(result, file_info, platform_path, file_ref);
838 } 848 }
(...skipping 29 matching lines...) Expand all
868 } 878 }
869 879
870 bool LocalFileSystemOperation::SetPendingOperationType(OperationType type) { 880 bool LocalFileSystemOperation::SetPendingOperationType(OperationType type) {
871 if (pending_operation_ != kOperationNone) 881 if (pending_operation_ != kOperationNone)
872 return false; 882 return false;
873 pending_operation_ = type; 883 pending_operation_ = type;
874 return true; 884 return true;
875 } 885 }
876 886
877 } // namespace fileapi 887 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/file_system_operation.h ('k') | webkit/fileapi/remote_file_system_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698