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..bd0b17f2e4bc7a75b2739ae7db42bba3be8a05f1 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"); |
mtomasz
2016/09/01 07:49:49
nit: period missing.
harukam
2016/09/02 01:33:32
You can also find line 804 missing period.
Should
mtomasz
2016/09/02 01:36:37
Up to you. It's a minor thing, but if possible we
harukam
2016/09/02 03:45:38
Thanks, I've added a period 804 line.
|
+ return false; |
+ } |
+ |
+ const base::FilePath root_path = file_manager::util::GetLocalPathFromURL( |
+ render_frame_host(), GetProfile(), GURL(params->url)); |
+ |
+ if (root_path.empty()) |
mtomasz
2016/09/01 07:49:48
nit: Maybe we should set an error message?
harukam
2016/09/02 01:33:32
Acknowledged.
|
+ return false; |
+ |
+ base::PostTaskAndReplyWithResult( |
+ BrowserThread::GetBlockingPool(), FROM_HERE, |
+ base::Bind(&base::ComputeDirectorySize, root_path), |
mtomasz
2016/09/01 07:49:49
Does it work on non native mount points, eg. on Dr
harukam
2016/09/02 01:33:32
It works only on local directories, not on Drive.
|
+ base::Bind(&FileManagerPrivateInternalGetDirectorySizeFunction:: |
+ OnDirectorySizeRetrieved, |
+ this)); |
+ return true; |
+} |
+ |
+void FileManagerPrivateInternalGetDirectorySizeFunction:: |
+ OnDirectorySizeRetrieved(int64_t size) { |
+ SetResult( |
+ base::MakeUnique<base::FundamentalValue>(static_cast<double>(size))); |
+ SendResponse(true); |
+} |
+ |
} // namespace extensions |