Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(220)

Side by Side Diff: chrome/browser/chromeos/extensions/file_manager/private_api_file_system.cc

Issue 2285393003: Add API to get a folder's size. (Closed)
Patch Set: Add API to get a folder's size. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 bool FileManagerPrivateInternalGetDirectorySizeFunction::RunAsync() {
960 using extensions::api::file_manager_private_internal::GetDirectorySize::
961 Params;
962 const std::unique_ptr<Params> params(Params::Create(*args_));
963 EXTENSION_FUNCTION_VALIDATE(params);
964
965 if (params->url.empty()) {
966 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.
967 return false;
968 }
969
970 const base::FilePath root_path = file_manager::util::GetLocalPathFromURL(
971 render_frame_host(), GetProfile(), GURL(params->url));
972
973 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.
974 return false;
975
976 base::PostTaskAndReplyWithResult(
977 BrowserThread::GetBlockingPool(), FROM_HERE,
978 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.
979 base::Bind(&FileManagerPrivateInternalGetDirectorySizeFunction::
980 OnDirectorySizeRetrieved,
981 this));
982 return true;
983 }
984
985 void FileManagerPrivateInternalGetDirectorySizeFunction::
986 OnDirectorySizeRetrieved(int64_t size) {
987 SetResult(
988 base::MakeUnique<base::FundamentalValue>(static_cast<double>(size)));
989 SendResponse(true);
990 }
991
958 } // namespace extensions 992 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698