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

Side by Side Diff: chrome/browser/chromeos/drive/drive_file_system_proxy.cc

Issue 14472008: [FileAPI] Add file open ID and close callback (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: chromeos part Created 7 years, 8 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 (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 "chrome/browser/chromeos/drive/drive_file_system_proxy.h" 5 #include "chrome/browser/chromeos/drive/drive_file_system_proxy.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 15 matching lines...) Expand all
26 using base::MessageLoopProxy; 26 using base::MessageLoopProxy;
27 using content::BrowserThread; 27 using content::BrowserThread;
28 using fileapi::FileSystemURL; 28 using fileapi::FileSystemURL;
29 using fileapi::FileSystemOperation; 29 using fileapi::FileSystemOperation;
30 using webkit_blob::ShareableFileReference; 30 using webkit_blob::ShareableFileReference;
31 31
32 namespace drive { 32 namespace drive {
33 33
34 namespace { 34 namespace {
35 35
36 typedef fileapi::RemoteFileSystemProxyInterface::OpenFileCallback
37 OpenFileCallback;
38
36 const char kFeedField[] = "feed"; 39 const char kFeedField[] = "feed";
37 40
38 // Helper function to run reply on results of base::CreatePlatformFile() on 41 // Helper function to run reply on results of base::CreatePlatformFile() on
39 // IO thread. 42 // IO thread.
40 void OnPlatformFileOpened( 43 void OnPlatformFileOpened(
41 const FileSystemOperation::OpenFileCallback& callback, 44 const OpenFileCallback& callback,
42 base::ProcessHandle peer_handle, 45 base::ProcessHandle peer_handle,
43 base::PlatformFileError* open_error, 46 base::PlatformFileError* open_error,
44 base::PlatformFile platform_file) { 47 base::PlatformFile platform_file) {
45 callback.Run(*open_error, platform_file, peer_handle); 48 callback.Run(*open_error, platform_file, peer_handle);
46 } 49 }
47 50
48 // Helper function to run OpenFileCallback from 51 // Helper function to run OpenFileCallback from
49 // DriveFileSystemProxy::OpenFile(). 52 // DriveFileSystemProxy::OpenFile().
50 void OnGetFileByPathForOpen( 53 void OnGetFileByPathForOpen(
51 const FileSystemOperation::OpenFileCallback& callback, 54 const OpenFileCallback& callback,
52 int file_flags, 55 int file_flags,
53 base::ProcessHandle peer_handle, 56 base::ProcessHandle peer_handle,
54 FileError file_error, 57 FileError file_error,
55 const base::FilePath& local_path, 58 const base::FilePath& local_path,
56 const std::string& unused_mime_type, 59 const std::string& unused_mime_type,
57 DriveFileType file_type) { 60 DriveFileType file_type) {
58 base::PlatformFileError error = 61 base::PlatformFileError error =
59 FileErrorToPlatformError(file_error); 62 FileErrorToPlatformError(file_error);
60 if (error != base::PLATFORM_FILE_OK) { 63 if (error != base::PLATFORM_FILE_OK) {
61 callback.Run(error, base::kInvalidPlatformFileValue, peer_handle); 64 callback.Run(error, base::kInvalidPlatformFileValue, peer_handle);
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 base::Bind(&DriveFileSystemProxy::OnFileOpenedForTruncate, 376 base::Bind(&DriveFileSystemProxy::OnFileOpenedForTruncate,
374 this, 377 this,
375 file_path, 378 file_path,
376 length, 379 length,
377 callback)))); 380 callback))));
378 } 381 }
379 382
380 void DriveFileSystemProxy::OnOpenFileForWriting( 383 void DriveFileSystemProxy::OnOpenFileForWriting(
381 int file_flags, 384 int file_flags,
382 base::ProcessHandle peer_handle, 385 base::ProcessHandle peer_handle,
383 const FileSystemOperation::OpenFileCallback& callback, 386 const OpenFileCallback& callback,
384 FileError file_error, 387 FileError file_error,
385 const base::FilePath& local_cache_path) { 388 const base::FilePath& local_cache_path) {
386 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 389 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
387 390
388 base::PlatformFileError error = 391 base::PlatformFileError error =
389 FileErrorToPlatformError(file_error); 392 FileErrorToPlatformError(file_error);
390 393
391 if (error != base::PLATFORM_FILE_OK) { 394 if (error != base::PLATFORM_FILE_OK) {
392 callback.Run(error, base::kInvalidPlatformFileValue, peer_handle); 395 callback.Run(error, base::kInvalidPlatformFileValue, peer_handle);
393 return; 396 return;
(...skipping 13 matching lines...) Expand all
407 callback, 410 callback,
408 peer_handle, 411 peer_handle,
409 base::Owned(result))); 412 base::Owned(result)));
410 DCHECK(posted); 413 DCHECK(posted);
411 } 414 }
412 415
413 void DriveFileSystemProxy::OnCreateFileForOpen( 416 void DriveFileSystemProxy::OnCreateFileForOpen(
414 const base::FilePath& file_path, 417 const base::FilePath& file_path,
415 int file_flags, 418 int file_flags,
416 base::ProcessHandle peer_handle, 419 base::ProcessHandle peer_handle,
417 const FileSystemOperation::OpenFileCallback& callback, 420 const OpenFileCallback& callback,
418 FileError file_error) { 421 FileError file_error) {
419 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 422 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
420 base::PlatformFileError create_result = 423 base::PlatformFileError create_result =
421 FileErrorToPlatformError(file_error); 424 FileErrorToPlatformError(file_error);
422 425
423 if ((create_result == base::PLATFORM_FILE_OK) || 426 if ((create_result == base::PLATFORM_FILE_OK) ||
424 ((create_result == base::PLATFORM_FILE_ERROR_EXISTS) && 427 ((create_result == base::PLATFORM_FILE_ERROR_EXISTS) &&
425 (file_flags & base::PLATFORM_FILE_CREATE_ALWAYS))) { 428 (file_flags & base::PLATFORM_FILE_CREATE_ALWAYS))) {
426 // If we are trying to always create an existing file, then 429 // If we are trying to always create an existing file, then
427 // if it really exists open it as truncated. 430 // if it really exists open it as truncated.
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 google_apis::CreateRelayCallback( 491 google_apis::CreateRelayCallback(
489 base::Bind(&DidCloseFileForTruncate, 492 base::Bind(&DidCloseFileForTruncate,
490 callback, 493 callback,
491 truncate_result)))); 494 truncate_result))));
492 } 495 }
493 496
494 void DriveFileSystemProxy::OpenFile( 497 void DriveFileSystemProxy::OpenFile(
495 const FileSystemURL& file_url, 498 const FileSystemURL& file_url,
496 int file_flags, 499 int file_flags,
497 base::ProcessHandle peer_handle, 500 base::ProcessHandle peer_handle,
498 const FileSystemOperation::OpenFileCallback& callback) { 501 const OpenFileCallback& callback) {
499 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 502 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
500 503
501 base::FilePath file_path; 504 base::FilePath file_path;
502 if (!ValidateUrl(file_url, &file_path)) { 505 if (!ValidateUrl(file_url, &file_path)) {
503 MessageLoopProxy::current()->PostTask(FROM_HERE, 506 MessageLoopProxy::current()->PostTask(FROM_HERE,
504 base::Bind(callback, 507 base::Bind(callback,
505 base::PLATFORM_FILE_ERROR_NOT_FOUND, 508 base::PLATFORM_FILE_ERROR_NOT_FOUND,
506 base::kInvalidPlatformFileValue, 509 base::kInvalidPlatformFileValue,
507 peer_handle)); 510 peer_handle));
508 return; 511 return;
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 CallDriveFileSystemMethodOnUIThread( 808 CallDriveFileSystemMethodOnUIThread(
806 base::Bind(&DriveFileSystemInterface::CloseFile, 809 base::Bind(&DriveFileSystemInterface::CloseFile,
807 base::Unretained(file_system_), 810 base::Unretained(file_system_),
808 virtual_path, 811 virtual_path,
809 google_apis::CreateRelayCallback( 812 google_apis::CreateRelayCallback(
810 base::Bind(&EmitDebugLogForCloseFile, 813 base::Bind(&EmitDebugLogForCloseFile,
811 virtual_path)))); 814 virtual_path))));
812 } 815 }
813 816
814 } // namespace drive 817 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698