OLD | NEW |
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 11 matching lines...) Expand all Loading... |
22 #include "webkit/fileapi/file_system_types.h" | 22 #include "webkit/fileapi/file_system_types.h" |
23 #include "webkit/fileapi/file_system_url.h" | 23 #include "webkit/fileapi/file_system_url.h" |
24 #include "webkit/fileapi/file_system_util.h" | 24 #include "webkit/fileapi/file_system_util.h" |
25 | 25 |
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 gdata { | 32 namespace drive { |
33 | 33 |
34 namespace { | 34 namespace { |
35 | 35 |
36 const char kDriveRootDirectory[] = "drive"; | 36 const char kDriveRootDirectory[] = "drive"; |
37 const char kFeedField[] = "feed"; | 37 const char kFeedField[] = "feed"; |
38 | 38 |
39 // Helper function that creates platform file on blocking IO thread pool. | 39 // Helper function that creates platform file on blocking IO thread pool. |
40 void OpenPlatformFileOnIOPool(const FilePath& local_path, | 40 void OpenPlatformFileOnIOPool(const FilePath& local_path, |
41 int file_flags, | 41 int file_flags, |
42 base::PlatformFile* platform_file, | 42 base::PlatformFile* platform_file, |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 file_flags, | 514 file_flags, |
515 peer_handle, | 515 peer_handle, |
516 callback)); | 516 callback)); |
517 } else { | 517 } else { |
518 // Read-only file open. | 518 // Read-only file open. |
519 file_system_->GetFileByPath(file_path, | 519 file_system_->GetFileByPath(file_path, |
520 base::Bind(&OnGetFileByPathForOpen, | 520 base::Bind(&OnGetFileByPathForOpen, |
521 callback, | 521 callback, |
522 file_flags, | 522 file_flags, |
523 peer_handle), | 523 peer_handle), |
524 GetContentCallback()); | 524 gdata::GetContentCallback()); |
525 } | 525 } |
526 } else if ((file_flags & base::PLATFORM_FILE_CREATE) || | 526 } else if ((file_flags & base::PLATFORM_FILE_CREATE) || |
527 (file_flags & base::PLATFORM_FILE_CREATE_ALWAYS)) { | 527 (file_flags & base::PLATFORM_FILE_CREATE_ALWAYS)) { |
528 // Open existing file for writing. | 528 // Open existing file for writing. |
529 file_system_->CreateFile( | 529 file_system_->CreateFile( |
530 file_path, | 530 file_path, |
531 file_flags & base::PLATFORM_FILE_EXCLUSIVE_WRITE, | 531 file_flags & base::PLATFORM_FILE_EXCLUSIVE_WRITE, |
532 base::Bind(&DriveFileSystemProxy::OnCreateFileForOpen, | 532 base::Bind(&DriveFileSystemProxy::OnCreateFileForOpen, |
533 this, | 533 this, |
534 file_path, | 534 file_path, |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 | 610 |
611 base::PlatformFileInfo file_info; | 611 base::PlatformFileInfo file_info; |
612 DriveEntry::ConvertProtoToPlatformFileInfo( | 612 DriveEntry::ConvertProtoToPlatformFileInfo( |
613 entry_proto->file_info(), | 613 entry_proto->file_info(), |
614 &file_info); | 614 &file_info); |
615 | 615 |
616 file_system_->GetFileByPath(entry_path, | 616 file_system_->GetFileByPath(entry_path, |
617 base::Bind(&CallSnapshotFileCallback, | 617 base::Bind(&CallSnapshotFileCallback, |
618 callback, | 618 callback, |
619 file_info), | 619 file_info), |
620 GetContentCallback()); | 620 gdata::GetContentCallback()); |
621 } | 621 } |
622 | 622 |
623 void DriveFileSystemProxy::CreateWritableSnapshotFile( | 623 void DriveFileSystemProxy::CreateWritableSnapshotFile( |
624 const FileSystemURL& file_url, | 624 const FileSystemURL& file_url, |
625 const fileapi::WritableSnapshotFile& callback) { | 625 const fileapi::WritableSnapshotFile& callback) { |
626 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 626 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
627 | 627 |
628 FilePath file_path; | 628 FilePath file_path; |
629 if (!ValidateUrl(file_url, &file_path)) { | 629 if (!ValidateUrl(file_url, &file_path)) { |
630 MessageLoopProxy::current()->PostTask(FROM_HERE, | 630 MessageLoopProxy::current()->PostTask(FROM_HERE, |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
744 | 744 |
745 void DriveFileSystemProxy::CloseWritableSnapshotFile( | 745 void DriveFileSystemProxy::CloseWritableSnapshotFile( |
746 const FilePath& virtual_path, | 746 const FilePath& virtual_path, |
747 const FilePath& local_path) { | 747 const FilePath& local_path) { |
748 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 748 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
749 | 749 |
750 file_system_->CloseFile(virtual_path, | 750 file_system_->CloseFile(virtual_path, |
751 base::Bind(&EmitDebugLogForCloseFile, virtual_path)); | 751 base::Bind(&EmitDebugLogForCloseFile, virtual_path)); |
752 } | 752 } |
753 | 753 |
754 } // namespace gdata | 754 } // namespace drive |
OLD | NEW |