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 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <utility> | 10 #include <utility> |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 storage_monitor->media_transfer_protocol_manager(); | 490 storage_monitor->media_transfer_protocol_manager(); |
491 manager->GetStorageInfoFromDevice( | 491 manager->GetStorageInfoFromDevice( |
492 storage_name, | 492 storage_name, |
493 base::Bind( | 493 base::Bind( |
494 &FileManagerPrivateGetSizeStatsFunction::OnGetMtpAvailableSpace, | 494 &FileManagerPrivateGetSizeStatsFunction::OnGetMtpAvailableSpace, |
495 this)); | 495 this)); |
496 } else { | 496 } else { |
497 uint64_t* total_size = new uint64_t(0); | 497 uint64_t* total_size = new uint64_t(0); |
498 uint64_t* remaining_size = new uint64_t(0); | 498 uint64_t* remaining_size = new uint64_t(0); |
499 base::PostTaskWithTraitsAndReply( | 499 base::PostTaskWithTraitsAndReply( |
500 FROM_HERE, base::TaskTraits().MayBlock().WithPriority( | 500 FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE}, |
501 base::TaskPriority::USER_VISIBLE), | |
502 base::Bind(&GetSizeStatsAsync, volume->mount_path(), total_size, | 501 base::Bind(&GetSizeStatsAsync, volume->mount_path(), total_size, |
503 remaining_size), | 502 remaining_size), |
504 base::Bind(&FileManagerPrivateGetSizeStatsFunction::OnGetSizeStats, | 503 base::Bind(&FileManagerPrivateGetSizeStatsFunction::OnGetSizeStats, |
505 this, base::Owned(total_size), base::Owned(remaining_size))); | 504 this, base::Owned(total_size), base::Owned(remaining_size))); |
506 } | 505 } |
507 return true; | 506 return true; |
508 } | 507 } |
509 | 508 |
510 void FileManagerPrivateGetSizeStatsFunction::OnGetDriveAvailableSpace( | 509 void FileManagerPrivateGetSizeStatsFunction::OnGetDriveAvailableSpace( |
511 drive::FileError error, | 510 drive::FileError error, |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 return false; | 565 return false; |
567 | 566 |
568 // No explicit limit on the length of Drive file names. | 567 // No explicit limit on the length of Drive file names. |
569 if (file_system_url.type() == storage::kFileSystemTypeDrive) { | 568 if (file_system_url.type() == storage::kFileSystemTypeDrive) { |
570 SetResult(base::MakeUnique<base::Value>(true)); | 569 SetResult(base::MakeUnique<base::Value>(true)); |
571 SendResponse(true); | 570 SendResponse(true); |
572 return true; | 571 return true; |
573 } | 572 } |
574 | 573 |
575 base::PostTaskWithTraitsAndReplyWithResult( | 574 base::PostTaskWithTraitsAndReplyWithResult( |
576 FROM_HERE, base::TaskTraits().MayBlock().WithPriority( | 575 FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_BLOCKING}, |
577 base::TaskPriority::USER_BLOCKING), | |
578 base::Bind(&GetFileNameMaxLengthAsync, | 576 base::Bind(&GetFileNameMaxLengthAsync, |
579 file_system_url.path().AsUTF8Unsafe()), | 577 file_system_url.path().AsUTF8Unsafe()), |
580 base::Bind(&FileManagerPrivateInternalValidatePathNameLengthFunction:: | 578 base::Bind(&FileManagerPrivateInternalValidatePathNameLengthFunction:: |
581 OnFilePathLimitRetrieved, | 579 OnFilePathLimitRetrieved, |
582 this, params->name.size())); | 580 this, params->name.size())); |
583 return true; | 581 return true; |
584 } | 582 } |
585 | 583 |
586 void FileManagerPrivateInternalValidatePathNameLengthFunction:: | 584 void FileManagerPrivateInternalValidatePathNameLengthFunction:: |
587 OnFilePathLimitRetrieved(size_t current_length, size_t max_length) { | 585 OnFilePathLimitRetrieved(size_t current_length, size_t max_length) { |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1033 } | 1031 } |
1034 | 1032 |
1035 const base::FilePath root_path = file_manager::util::GetLocalPathFromURL( | 1033 const base::FilePath root_path = file_manager::util::GetLocalPathFromURL( |
1036 render_frame_host(), GetProfile(), GURL(params->url)); | 1034 render_frame_host(), GetProfile(), GURL(params->url)); |
1037 if (root_path.empty()) { | 1035 if (root_path.empty()) { |
1038 SetError("Failed to get a local path from the entry's url."); | 1036 SetError("Failed to get a local path from the entry's url."); |
1039 return false; | 1037 return false; |
1040 } | 1038 } |
1041 | 1039 |
1042 base::PostTaskWithTraitsAndReplyWithResult( | 1040 base::PostTaskWithTraitsAndReplyWithResult( |
1043 FROM_HERE, base::TaskTraits().MayBlock().WithPriority( | 1041 FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE}, |
1044 base::TaskPriority::USER_VISIBLE), | |
1045 base::Bind(&base::ComputeDirectorySize, root_path), | 1042 base::Bind(&base::ComputeDirectorySize, root_path), |
1046 base::Bind(&FileManagerPrivateInternalGetDirectorySizeFunction:: | 1043 base::Bind(&FileManagerPrivateInternalGetDirectorySizeFunction:: |
1047 OnDirectorySizeRetrieved, | 1044 OnDirectorySizeRetrieved, |
1048 this)); | 1045 this)); |
1049 return true; | 1046 return true; |
1050 } | 1047 } |
1051 | 1048 |
1052 void FileManagerPrivateInternalGetDirectorySizeFunction:: | 1049 void FileManagerPrivateInternalGetDirectorySizeFunction:: |
1053 OnDirectorySizeRetrieved(int64_t size) { | 1050 OnDirectorySizeRetrieved(int64_t size) { |
1054 SetResult(base::MakeUnique<base::Value>(static_cast<double>(size))); | 1051 SetResult(base::MakeUnique<base::Value>(static_cast<double>(size))); |
1055 SendResponse(true); | 1052 SendResponse(true); |
1056 } | 1053 } |
1057 | 1054 |
1058 } // namespace extensions | 1055 } // namespace extensions |
OLD | NEW |