OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_browser_private_api.h" | 5 #include "chrome/browser/chromeos/extensions/file_browser_private_api.h" |
6 | 6 |
7 #include <sys/stat.h> | 7 #include <sys/stat.h> |
8 #include <sys/statvfs.h> | 8 #include <sys/statvfs.h> |
9 #include <sys/types.h> | 9 #include <sys/types.h> |
10 #include <utime.h> | 10 #include <utime.h> |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
284 return result; | 284 return result; |
285 } | 285 } |
286 | 286 |
287 // Retrieves total and remaining available size on |mount_path|. | 287 // Retrieves total and remaining available size on |mount_path|. |
288 void GetSizeStatsOnBlockingPool(const std::string& mount_path, | 288 void GetSizeStatsOnBlockingPool(const std::string& mount_path, |
289 size_t* total_size_kb, | 289 size_t* total_size_kb, |
290 size_t* remaining_size_kb) { | 290 size_t* remaining_size_kb) { |
291 uint64_t total_size_in_bytes = 0; | 291 uint64_t total_size_in_bytes = 0; |
292 uint64_t remaining_size_in_bytes = 0; | 292 uint64_t remaining_size_in_bytes = 0; |
293 | 293 |
294 struct statvfs stat = {}; // Zero-clear | 294 struct statvfs stat = {}; // Zero-clear |
Mark Mentovai
2013/03/22 22:17:40
You can get rid of the initialization here too, it
| |
295 if (statvfs(mount_path.c_str(), &stat) == 0) { | 295 if (HANDLE_EINTR(statvfs(mount_path.c_str(), &stat)) == 0) { |
296 total_size_in_bytes = | 296 total_size_in_bytes = |
297 static_cast<uint64_t>(stat.f_blocks) * stat.f_frsize; | 297 static_cast<uint64_t>(stat.f_blocks) * stat.f_frsize; |
298 remaining_size_in_bytes = | 298 remaining_size_in_bytes = |
299 static_cast<uint64_t>(stat.f_bfree) * stat.f_frsize; | 299 static_cast<uint64_t>(stat.f_bfree) * stat.f_frsize; |
300 } | 300 } |
301 *total_size_kb = static_cast<size_t>(total_size_in_bytes / 1024); | 301 *total_size_kb = static_cast<size_t>(total_size_in_bytes / 1024); |
302 *remaining_size_kb = static_cast<size_t>(remaining_size_in_bytes / 1024); | 302 *remaining_size_kb = static_cast<size_t>(remaining_size_in_bytes / 1024); |
303 } | 303 } |
304 | 304 |
305 // Given a |url|, return the virtual FilePath associated with it. If the file | 305 // Given a |url|, return the virtual FilePath associated with it. If the file |
(...skipping 3047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3353 OpenNewWindowFunction::OpenNewWindowFunction() {} | 3353 OpenNewWindowFunction::OpenNewWindowFunction() {} |
3354 | 3354 |
3355 OpenNewWindowFunction::~OpenNewWindowFunction() {} | 3355 OpenNewWindowFunction::~OpenNewWindowFunction() {} |
3356 | 3356 |
3357 bool OpenNewWindowFunction::RunImpl() { | 3357 bool OpenNewWindowFunction::RunImpl() { |
3358 std::string url; | 3358 std::string url; |
3359 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &url)); | 3359 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &url)); |
3360 file_manager_util::OpenNewWindow(profile_, GURL(url)); | 3360 file_manager_util::OpenNewWindow(profile_, GURL(url)); |
3361 return true; | 3361 return true; |
3362 } | 3362 } |
OLD | NEW |