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

Side by Side Diff: trunk/src/webkit/browser/fileapi/file_system_operation_runner.cc

Issue 60323002: Revert 232547 "Pepper: Move FileIO host from renderer to browser." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 1 month 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 | « trunk/src/webkit/browser/fileapi/file_system_operation_runner.h ('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 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_runner.h" 5 #include "webkit/browser/fileapi/file_system_operation_runner.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop_proxy.h" 8 #include "base/message_loop/message_loop_proxy.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "net/url_request/url_request_context.h" 10 #include "net/url_request/url_request_context.h"
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 operation->TouchFile( 332 operation->TouchFile(
333 url, last_access_time, last_modified_time, 333 url, last_access_time, last_modified_time,
334 base::Bind(&FileSystemOperationRunner::DidFinish, AsWeakPtr(), 334 base::Bind(&FileSystemOperationRunner::DidFinish, AsWeakPtr(),
335 handle, callback)); 335 handle, callback));
336 return handle.id; 336 return handle.id;
337 } 337 }
338 338
339 OperationID FileSystemOperationRunner::OpenFile( 339 OperationID FileSystemOperationRunner::OpenFile(
340 const FileSystemURL& url, 340 const FileSystemURL& url,
341 int file_flags, 341 int file_flags,
342 base::ProcessHandle peer_handle,
342 const OpenFileCallback& callback) { 343 const OpenFileCallback& callback) {
343 base::PlatformFileError error = base::PLATFORM_FILE_OK; 344 base::PlatformFileError error = base::PLATFORM_FILE_OK;
344 FileSystemOperation* operation = 345 FileSystemOperation* operation =
345 file_system_context_->CreateFileSystemOperation(url, &error); 346 file_system_context_->CreateFileSystemOperation(url, &error);
346 BeginOperationScoper scope; 347 BeginOperationScoper scope;
347 OperationHandle handle = BeginOperation(operation, scope.AsWeakPtr()); 348 OperationHandle handle = BeginOperation(operation, scope.AsWeakPtr());
348 if (!operation) { 349 if (!operation) {
349 DidOpenFile(handle, callback, error, base::kInvalidPlatformFileValue, 350 DidOpenFile(handle, callback, error, base::kInvalidPlatformFileValue,
350 base::Closure()); 351 base::Closure(), base::ProcessHandle());
351 return handle.id; 352 return handle.id;
352 } 353 }
353 if (file_flags & 354 if (file_flags &
354 (base::PLATFORM_FILE_CREATE | base::PLATFORM_FILE_OPEN_ALWAYS | 355 (base::PLATFORM_FILE_CREATE | base::PLATFORM_FILE_OPEN_ALWAYS |
355 base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_OPEN_TRUNCATED | 356 base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_OPEN_TRUNCATED |
356 base::PLATFORM_FILE_WRITE | base::PLATFORM_FILE_EXCLUSIVE_WRITE | 357 base::PLATFORM_FILE_WRITE | base::PLATFORM_FILE_EXCLUSIVE_WRITE |
357 base::PLATFORM_FILE_DELETE_ON_CLOSE | 358 base::PLATFORM_FILE_DELETE_ON_CLOSE |
358 base::PLATFORM_FILE_WRITE_ATTRIBUTES)) { 359 base::PLATFORM_FILE_WRITE_ATTRIBUTES)) {
359 PrepareForWrite(handle.id, url); 360 PrepareForWrite(handle.id, url);
360 } else { 361 } else {
361 PrepareForRead(handle.id, url); 362 PrepareForRead(handle.id, url);
362 } 363 }
363 operation->OpenFile( 364 operation->OpenFile(
364 url, file_flags, 365 url, file_flags, peer_handle,
365 base::Bind(&FileSystemOperationRunner::DidOpenFile, AsWeakPtr(), 366 base::Bind(&FileSystemOperationRunner::DidOpenFile, AsWeakPtr(),
366 handle, callback)); 367 handle, callback));
367 return handle.id; 368 return handle.id;
368 } 369 }
369 370
370 OperationID FileSystemOperationRunner::CreateSnapshotFile( 371 OperationID FileSystemOperationRunner::CreateSnapshotFile(
371 const FileSystemURL& url, 372 const FileSystemURL& url,
372 const SnapshotFileCallback& callback) { 373 const SnapshotFileCallback& callback) {
373 base::PlatformFileError error = base::PLATFORM_FILE_OK; 374 base::PlatformFileError error = base::PLATFORM_FILE_OK;
374 FileSystemOperation* operation = 375 FileSystemOperation* operation =
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 callback.Run(rv, bytes, complete); 571 callback.Run(rv, bytes, complete);
571 if (rv != base::PLATFORM_FILE_OK || complete) 572 if (rv != base::PLATFORM_FILE_OK || complete)
572 FinishOperation(handle.id); 573 FinishOperation(handle.id);
573 } 574 }
574 575
575 void FileSystemOperationRunner::DidOpenFile( 576 void FileSystemOperationRunner::DidOpenFile(
576 const OperationHandle& handle, 577 const OperationHandle& handle,
577 const OpenFileCallback& callback, 578 const OpenFileCallback& callback,
578 base::PlatformFileError rv, 579 base::PlatformFileError rv,
579 base::PlatformFile file, 580 base::PlatformFile file,
580 const base::Closure& on_close_callback) { 581 const base::Closure& on_close_callback,
582 base::ProcessHandle peer_handle) {
581 if (handle.scope) { 583 if (handle.scope) {
582 finished_operations_.insert(handle.id); 584 finished_operations_.insert(handle.id);
583 base::MessageLoopProxy::current()->PostTask( 585 base::MessageLoopProxy::current()->PostTask(
584 FROM_HERE, base::Bind(&FileSystemOperationRunner::DidOpenFile, 586 FROM_HERE, base::Bind(&FileSystemOperationRunner::DidOpenFile,
585 AsWeakPtr(), handle, callback, rv, file, 587 AsWeakPtr(), handle, callback, rv, file,
586 on_close_callback)); 588 on_close_callback, peer_handle));
587 return; 589 return;
588 } 590 }
589 callback.Run(rv, file, on_close_callback); 591 callback.Run(rv, file, on_close_callback, peer_handle);
590 FinishOperation(handle.id); 592 FinishOperation(handle.id);
591 } 593 }
592 594
593 void FileSystemOperationRunner::DidCreateSnapshot( 595 void FileSystemOperationRunner::DidCreateSnapshot(
594 const OperationHandle& handle, 596 const OperationHandle& handle,
595 const SnapshotFileCallback& callback, 597 const SnapshotFileCallback& callback,
596 base::PlatformFileError rv, 598 base::PlatformFileError rv,
597 const base::PlatformFileInfo& file_info, 599 const base::PlatformFileInfo& file_info,
598 const base::FilePath& platform_path, 600 const base::FilePath& platform_path,
599 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref) { 601 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref) {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 stray_cancel_callbacks_.find(id); 680 stray_cancel_callbacks_.find(id);
679 if (found_cancel != stray_cancel_callbacks_.end()) { 681 if (found_cancel != stray_cancel_callbacks_.end()) {
680 // This cancel has been requested after the operation has finished, 682 // This cancel has been requested after the operation has finished,
681 // so report that we failed to stop it. 683 // so report that we failed to stop it.
682 found_cancel->second.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION); 684 found_cancel->second.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION);
683 stray_cancel_callbacks_.erase(found_cancel); 685 stray_cancel_callbacks_.erase(found_cancel);
684 } 686 }
685 } 687 }
686 688
687 } // namespace fileapi 689 } // namespace fileapi
OLDNEW
« no previous file with comments | « trunk/src/webkit/browser/fileapi/file_system_operation_runner.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698