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..41f3b49ae4a80859301947abfa1d65a0771330db 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,37 @@ void FileManagerPrivateInternalSetEntryTagFunction::OnSetEntryPropertyCompleted( |
: Error("Failed to set a tag.")); |
} |
+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( |
+ render_frame_host(), GetProfile(), GURL(params->url)); |
+ |
+ if (root_path.empty()) |
+ return false; |
+ |
+ base::PostTaskAndReplyWithResult( |
+ BrowserThread::GetBlockingPool(), FROM_HERE, |
+ base::Bind(&base::ComputeDirectorySize, |
+ root_path), |
+ base::Bind(&FileManagerPrivateInternalGetDirectorySizeFunction:: |
+ OnDirectorySizeRetrieved, this)); |
fukino
2016/08/30 06:55:49
This line's indent level looks incorrect. Could yo
harukam
2016/08/30 07:35:38
Thanks! Done.
|
+ return true; |
+} |
+ |
+void FileManagerPrivateInternalGetDirectorySizeFunction:: |
+ OnDirectorySizeRetrieved(int64_t size) { |
+ SetResult( |
+ base::MakeUnique<base::FundamentalValue>(static_cast<double>(size))); |
+ SendResponse(true); |
+} |
+ |
} // namespace extensions |