OLD | NEW |
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 "chrome/browser/chromeos/extensions/file_manager/private_api_file_syste
m.h" | 5 #include "chrome/browser/chromeos/extensions/file_manager/private_api_file_syste
m.h" |
6 | 6 |
7 #include <sys/statvfs.h> | 7 #include <sys/statvfs.h> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 DiskMountManager::GetInstance()->FormatMountedDevice( | 595 DiskMountManager::GetInstance()->FormatMountedDevice( |
596 volume->mount_path().AsUTF8Unsafe()); | 596 volume->mount_path().AsUTF8Unsafe()); |
597 SendResponse(true); | 597 SendResponse(true); |
598 return true; | 598 return true; |
599 } | 599 } |
600 | 600 |
601 // Obtains file size of URL. | 601 // Obtains file size of URL. |
602 void GetFileMetadataOnIOThread( | 602 void GetFileMetadataOnIOThread( |
603 scoped_refptr<storage::FileSystemContext> file_system_context, | 603 scoped_refptr<storage::FileSystemContext> file_system_context, |
604 const FileSystemURL& url, | 604 const FileSystemURL& url, |
| 605 int fields, |
605 const storage::FileSystemOperation::GetMetadataCallback& callback) { | 606 const storage::FileSystemOperation::GetMetadataCallback& callback) { |
606 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 607 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
607 file_system_context->operation_runner()->GetMetadata( | 608 file_system_context->operation_runner()->GetMetadata( |
608 url, base::Bind(&GetFileMetadataRespondOnUIThread, callback)); | 609 url, fields, base::Bind(&GetFileMetadataRespondOnUIThread, callback)); |
609 } | 610 } |
610 | 611 |
611 // Checks if the available space of the |path| is enough for required |bytes|. | 612 // Checks if the available space of the |path| is enough for required |bytes|. |
612 bool CheckLocalDiskSpaceOnIOThread(const base::FilePath& path, int64 bytes) { | 613 bool CheckLocalDiskSpaceOnIOThread(const base::FilePath& path, int64 bytes) { |
613 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 614 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
614 return bytes <= base::SysInfo::AmountOfFreeDiskSpace(path) - | 615 return bytes <= base::SysInfo::AmountOfFreeDiskSpace(path) - |
615 cryptohome::kMinFreeSpaceInBytes; | 616 cryptohome::kMinFreeSpaceInBytes; |
616 } | 617 } |
617 | 618 |
618 bool FileManagerPrivateInternalStartCopyFunction::RunAsync() { | 619 bool FileManagerPrivateInternalStartCopyFunction::RunAsync() { |
(...skipping 30 matching lines...) Expand all Loading... |
649 return false; | 650 return false; |
650 } | 651 } |
651 | 652 |
652 // Check if the destination directory is downloads. If so, secure available | 653 // Check if the destination directory is downloads. If so, secure available |
653 // spece by freeing drive caches. | 654 // spece by freeing drive caches. |
654 if (destination_url_.filesystem_id() == | 655 if (destination_url_.filesystem_id() == |
655 file_manager::util::GetDownloadsMountPointName(GetProfile())) { | 656 file_manager::util::GetDownloadsMountPointName(GetProfile())) { |
656 return BrowserThread::PostTask( | 657 return BrowserThread::PostTask( |
657 BrowserThread::IO, FROM_HERE, | 658 BrowserThread::IO, FROM_HERE, |
658 base::Bind(&GetFileMetadataOnIOThread, file_system_context, source_url_, | 659 base::Bind(&GetFileMetadataOnIOThread, file_system_context, source_url_, |
| 660 storage::FileSystemOperation::GET_METADATA_FIELD_SIZE, |
659 base::Bind(&FileManagerPrivateInternalStartCopyFunction:: | 661 base::Bind(&FileManagerPrivateInternalStartCopyFunction:: |
660 RunAfterGetFileMetadata, | 662 RunAfterGetFileMetadata, |
661 this))); | 663 this))); |
662 } | 664 } |
663 | 665 |
664 return BrowserThread::PostTask( | 666 return BrowserThread::PostTask( |
665 BrowserThread::UI, FROM_HERE, | 667 BrowserThread::UI, FROM_HERE, |
666 base::Bind( | 668 base::Bind( |
667 &FileManagerPrivateInternalStartCopyFunction::RunAfterFreeDiskSpace, | 669 &FileManagerPrivateInternalStartCopyFunction::RunAfterFreeDiskSpace, |
668 this, true)); | 670 this, true)); |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
987 return RespondLater(); | 989 return RespondLater(); |
988 } | 990 } |
989 | 991 |
990 void FileManagerPrivateInternalSetEntryTagFunction::OnSetEntryPropertyCompleted( | 992 void FileManagerPrivateInternalSetEntryTagFunction::OnSetEntryPropertyCompleted( |
991 drive::FileError result) { | 993 drive::FileError result) { |
992 Respond(result == drive::FILE_ERROR_OK ? NoArguments() | 994 Respond(result == drive::FILE_ERROR_OK ? NoArguments() |
993 : Error("Failed to set a tag.")); | 995 : Error("Failed to set a tag.")); |
994 } | 996 } |
995 | 997 |
996 } // namespace extensions | 998 } // namespace extensions |
OLD | NEW |