Chromium Code Reviews| Index: chrome/browser/chromeos/extensions/file_manager/private_api_file_system.cc |
| diff --git a/chrome/browser/chromeos/extensions/file_manager/private_api_file_system.cc b/chrome/browser/chromeos/extensions/file_manager/private_api_file_system.cc |
| index 0cdc8c6702629349dec42dbf0bf85b62bb1a366d..188748c2b72285c443b87e9d2bd3846f32889f56 100644 |
| --- a/chrome/browser/chromeos/extensions/file_manager/private_api_file_system.cc |
| +++ b/chrome/browser/chromeos/extensions/file_manager/private_api_file_system.cc |
| @@ -11,6 +11,7 @@ |
| #include <utility> |
| #include <vector> |
| +#include "base/files/file_util.h" |
| #include "base/memory/ptr_util.h" |
| #include "base/memory/weak_ptr.h" |
| #include "base/posix/eintr_wrapper.h" |
| @@ -955,4 +956,29 @@ void FileManagerPrivateInternalSetEntryTagFunction::OnSetEntryPropertyCompleted( |
| : Error("Failed to set a tag.")); |
| } |
| +FileManagerPrivateInternalGetDirectorySizeFunction:: |
| + FileManagerPrivateInternalGetDirectorySizeFunction() |
| + : chrome_details_(this) {} |
| + |
| +bool FileManagerPrivateInternalGetDirectorySizeFunction::RunAsync() { |
| + using extensions::api::file_manager_private_internal::GetDirectorySize:: |
| + Params; |
| + const std::unique_ptr<Params> params(Params::Create(*args_)); |
| + EXTENSION_FUNCTION_VALIDATE(params); |
| + |
| + if (params->url.empty()) { |
| + SetError("File URL must be provided"); |
| + return false; |
| + } |
| + |
| + const base::FilePath root_path = file_manager::util::GetLocalPathFromURL( |
|
fukino
2016/08/30 05:17:06
Please check if the root_path is empty or not.
harukam
2016/08/30 06:33:41
Done.
|
| + render_frame_host(), chrome_details_.GetProfile(), GURL(params->url)); |
|
fukino
2016/08/30 05:17:06
chrome_details_ looks unnecessary. Simply GetProfi
harukam
2016/08/30 06:33:41
Acknowledged.
|
| + int64_t size = base::ComputeDirectorySize(root_path); |
|
fukino
2016/08/30 05:17:06
You should not access file system on this thread n
harukam
2016/08/30 06:33:42
Acknowledged.
|
| + |
| + SetResult( |
| + base::MakeUnique<base::FundamentalValue>(static_cast<double>(size))); |
| + SendResponse(true); |
| + return true; |
| +} |
| + |
| } // namespace extensions |