Chromium Code Reviews| 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 <set> | 10 #include <set> |
| 11 #include <utility> | 11 #include <utility> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/files/file_util.h" | |
| 14 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
| 15 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 16 #include "base/posix/eintr_wrapper.h" | 17 #include "base/posix/eintr_wrapper.h" |
| 17 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
| 18 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
| 19 #include "base/strings/stringprintf.h" | 20 #include "base/strings/stringprintf.h" |
| 20 #include "base/sys_info.h" | 21 #include "base/sys_info.h" |
| 21 #include "base/task_runner_util.h" | 22 #include "base/task_runner_util.h" |
| 22 #include "base/threading/sequenced_worker_pool.h" | 23 #include "base/threading/sequenced_worker_pool.h" |
| 23 #include "chrome/browser/browser_process.h" | 24 #include "chrome/browser/browser_process.h" |
| (...skipping 924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 948 this)); | 949 this)); |
| 949 return RespondLater(); | 950 return RespondLater(); |
| 950 } | 951 } |
| 951 | 952 |
| 952 void FileManagerPrivateInternalSetEntryTagFunction::OnSetEntryPropertyCompleted( | 953 void FileManagerPrivateInternalSetEntryTagFunction::OnSetEntryPropertyCompleted( |
| 953 drive::FileError result) { | 954 drive::FileError result) { |
| 954 Respond(result == drive::FILE_ERROR_OK ? NoArguments() | 955 Respond(result == drive::FILE_ERROR_OK ? NoArguments() |
| 955 : Error("Failed to set a tag.")); | 956 : Error("Failed to set a tag.")); |
| 956 } | 957 } |
| 957 | 958 |
| 959 FileManagerPrivateInternalGetDirectorySizeFunction:: | |
| 960 FileManagerPrivateInternalGetDirectorySizeFunction() | |
| 961 : chrome_details_(this) {} | |
| 962 | |
| 963 bool FileManagerPrivateInternalGetDirectorySizeFunction::RunAsync() { | |
| 964 using extensions::api::file_manager_private_internal::GetDirectorySize:: | |
| 965 Params; | |
| 966 const std::unique_ptr<Params> params(Params::Create(*args_)); | |
| 967 EXTENSION_FUNCTION_VALIDATE(params); | |
| 968 | |
| 969 if (params->url.empty()) { | |
| 970 SetError("File URL must be provided"); | |
| 971 return false; | |
| 972 } | |
| 973 | |
| 974 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.
| |
| 975 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.
| |
| 976 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.
| |
| 977 | |
| 978 SetResult( | |
| 979 base::MakeUnique<base::FundamentalValue>(static_cast<double>(size))); | |
| 980 SendResponse(true); | |
| 981 return true; | |
| 982 } | |
| 983 | |
| 958 } // namespace extensions | 984 } // namespace extensions |
| OLD | NEW |