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 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 } | 423 } |
424 return true; | 424 return true; |
425 } | 425 } |
426 | 426 |
427 void FileManagerPrivateGetSizeStatsFunction::GetDriveAvailableSpaceCallback( | 427 void FileManagerPrivateGetSizeStatsFunction::GetDriveAvailableSpaceCallback( |
428 drive::FileError error, | 428 drive::FileError error, |
429 int64 bytes_total, | 429 int64 bytes_total, |
430 int64 bytes_used) { | 430 int64 bytes_used) { |
431 if (error == drive::FILE_ERROR_OK) { | 431 if (error == drive::FILE_ERROR_OK) { |
432 const uint64 bytes_total_unsigned = bytes_total; | 432 const uint64 bytes_total_unsigned = bytes_total; |
433 const uint64 bytes_remaining_unsigned = bytes_total - bytes_used; | 433 // bytes_used can be larger than bytes_total (over quota). |
| 434 const uint64 bytes_remaining_unsigned = |
| 435 std::max(bytes_total - bytes_used, int64(0)); |
434 GetSizeStatsCallback(&bytes_total_unsigned, | 436 GetSizeStatsCallback(&bytes_total_unsigned, |
435 &bytes_remaining_unsigned); | 437 &bytes_remaining_unsigned); |
436 } else { | 438 } else { |
437 // If stats couldn't be gotten for drive, result should be left undefined. | 439 // If stats couldn't be gotten for drive, result should be left undefined. |
438 SendResponse(true); | 440 SendResponse(true); |
439 } | 441 } |
440 } | 442 } |
441 | 443 |
442 void FileManagerPrivateGetSizeStatsFunction::GetSizeStatsCallback( | 444 void FileManagerPrivateGetSizeStatsFunction::GetSizeStatsCallback( |
443 const uint64* total_size, | 445 const uint64* total_size, |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
896 return RespondLater(); | 898 return RespondLater(); |
897 } | 899 } |
898 | 900 |
899 void FileManagerPrivateSetEntryTagFunction::OnSetEntryPropertyCompleted( | 901 void FileManagerPrivateSetEntryTagFunction::OnSetEntryPropertyCompleted( |
900 drive::FileError result) { | 902 drive::FileError result) { |
901 Respond(result == drive::FILE_ERROR_OK ? NoArguments() | 903 Respond(result == drive::FILE_ERROR_OK ? NoArguments() |
902 : Error("Failed to set a tag.")); | 904 : Error("Failed to set a tag.")); |
903 } | 905 } |
904 | 906 |
905 } // namespace extensions | 907 } // namespace extensions |
OLD | NEW |