diff options
author | fukino <fukino@chromium.org> | 2015-05-11 19:46:12 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-12 02:46:19 +0000 |
commit | fa39c6524a482ae3dc75773dbc4e88f4ed9e8fbf (patch) | |
tree | 7d3690180fe51573ce8c9508586aed5c73f5bef6 /google_apis/drive | |
parent | 02d9aea8003449c921c5c4b41ab67b0f554b1a72 (diff) | |
download | chromium_src-fa39c6524a482ae3dc75773dbc4e88f4ed9e8fbf.zip chromium_src-fa39c6524a482ae3dc75773dbc4e88f4ed9e8fbf.tar.gz chromium_src-fa39c6524a482ae3dc75773dbc4e88f4ed9e8fbf.tar.bz2 |
Files.app: Use quotaBytesUsedAggregate to know the actual available space.
We need to use quotaBytesUsedAggregate to know the actual available space, because the current quotaBytesUsed returns usage in only Google Drive (doesn't include Gmail, G+ Photos, etc...).
https://developers.google.com/drive/v2/reference/about#resource
BUG=483058
TEST=run unit_tests
Review URL: https://codereview.chromium.org/1125123008
Cr-Commit-Position: refs/heads/master@{#329330}
Diffstat (limited to 'google_apis/drive')
-rw-r--r-- | google_apis/drive/drive_api_parser.cc | 11 | ||||
-rw-r--r-- | google_apis/drive/drive_api_parser.h | 10 | ||||
-rw-r--r-- | google_apis/drive/drive_api_parser_unittest.cc | 2 | ||||
-rw-r--r-- | google_apis/drive/drive_api_requests_unittest.cc | 12 |
4 files changed, 20 insertions, 15 deletions
diff --git a/google_apis/drive/drive_api_parser.cc b/google_apis/drive/drive_api_parser.cc index 9a586c3..9eb00d2 100644 --- a/google_apis/drive/drive_api_parser.cc +++ b/google_apis/drive/drive_api_parser.cc @@ -99,7 +99,7 @@ const char kLargestChangeId[] = "largestChangeId"; // https://developers.google.com/drive/v2/reference/about const char kAboutKind[] = "drive#about"; const char kQuotaBytesTotal[] = "quotaBytesTotal"; -const char kQuotaBytesUsed[] = "quotaBytesUsed"; +const char kQuotaBytesUsedAggregate[] = "quotaBytesUsedAggregate"; const char kRootFolderId[] = "rootFolderId"; // App Icon @@ -209,7 +209,7 @@ bool IsResourceKindExpected(const base::Value& value, AboutResource::AboutResource() : largest_change_id_(0), quota_bytes_total_(0), - quota_bytes_used_(0) {} + quota_bytes_used_aggregate_(0) {} AboutResource::~AboutResource() {} @@ -232,9 +232,10 @@ void AboutResource::RegisterJSONConverter( converter->RegisterCustomField<int64>(kQuotaBytesTotal, &AboutResource::quota_bytes_total_, &base::StringToInt64); - converter->RegisterCustomField<int64>(kQuotaBytesUsed, - &AboutResource::quota_bytes_used_, - &base::StringToInt64); + converter->RegisterCustomField<int64>( + kQuotaBytesUsedAggregate, + &AboutResource::quota_bytes_used_aggregate_, + &base::StringToInt64); converter->RegisterStringField(kRootFolderId, &AboutResource::root_folder_id_); } diff --git a/google_apis/drive/drive_api_parser.h b/google_apis/drive/drive_api_parser.h index 482d749..acbb93f 100644 --- a/google_apis/drive/drive_api_parser.h +++ b/google_apis/drive/drive_api_parser.h @@ -48,7 +48,9 @@ class AboutResource { // Returns total number of quota bytes. int64 quota_bytes_total() const { return quota_bytes_total_; } // Returns the number of quota bytes used. - int64 quota_bytes_used() const { return quota_bytes_used_; } + int64 quota_bytes_used_aggregate() const { + return quota_bytes_used_aggregate_; + } // Returns root folder ID. const std::string& root_folder_id() const { return root_folder_id_; } @@ -58,8 +60,8 @@ class AboutResource { void set_quota_bytes_total(int64 quota_bytes_total) { quota_bytes_total_ = quota_bytes_total; } - void set_quota_bytes_used(int64 quota_bytes_used) { - quota_bytes_used_ = quota_bytes_used; + void set_quota_bytes_used_aggregate(int64 quota_bytes_used_aggregate) { + quota_bytes_used_aggregate_ = quota_bytes_used_aggregate; } void set_root_folder_id(const std::string& root_folder_id) { root_folder_id_ = root_folder_id; @@ -75,7 +77,7 @@ class AboutResource { int64 largest_change_id_; int64 quota_bytes_total_; - int64 quota_bytes_used_; + int64 quota_bytes_used_aggregate_; std::string root_folder_id_; // This class is copyable on purpose. diff --git a/google_apis/drive/drive_api_parser_unittest.cc b/google_apis/drive/drive_api_parser_unittest.cc index c2c4e21..e27425dc 100644 --- a/google_apis/drive/drive_api_parser_unittest.cc +++ b/google_apis/drive/drive_api_parser_unittest.cc @@ -25,7 +25,7 @@ TEST(DriveAPIParserTest, AboutResourceParser) { EXPECT_EQ("0AIv7G8yEYAWHUk9123", resource->root_folder_id()); EXPECT_EQ(5368709120LL, resource->quota_bytes_total()); - EXPECT_EQ(1073741824LL, resource->quota_bytes_used()); + EXPECT_EQ(1073741824LL, resource->quota_bytes_used_aggregate()); EXPECT_EQ(8177LL, resource->largest_change_id()); } diff --git a/google_apis/drive/drive_api_requests_unittest.cc b/google_apis/drive/drive_api_requests_unittest.cc index 030f960..c60c1b3 100644 --- a/google_apis/drive/drive_api_requests_unittest.cc +++ b/google_apis/drive/drive_api_requests_unittest.cc @@ -496,8 +496,8 @@ TEST_F(DriveApiRequestsTest, DriveApiDataRequest_Fields) { test_util::CreateQuitCallback( &run_loop, test_util::CreateCopyResultCallback(&error, &about_resource))); - request->set_fields( - "kind,quotaBytesTotal,quotaBytesUsed,largestChangeId,rootFolderId"); + request->set_fields("kind,quotaBytesTotal,quotaBytesUsedAggregate," + "largestChangeId,rootFolderId"); request_sender_->StartRequestWithRetry(request); run_loop.Run(); } @@ -505,7 +505,7 @@ TEST_F(DriveApiRequestsTest, DriveApiDataRequest_Fields) { EXPECT_EQ(HTTP_SUCCESS, error); EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); EXPECT_EQ("/drive/v2/about?" - "fields=kind%2CquotaBytesTotal%2CquotaBytesUsed%2C" + "fields=kind%2CquotaBytesTotal%2CquotaBytesUsedAggregate%2C" "largestChangeId%2CrootFolderId", http_request_.relative_url); @@ -515,7 +515,8 @@ TEST_F(DriveApiRequestsTest, DriveApiDataRequest_Fields) { ASSERT_TRUE(about_resource.get()); EXPECT_EQ(expected->largest_change_id(), about_resource->largest_change_id()); EXPECT_EQ(expected->quota_bytes_total(), about_resource->quota_bytes_total()); - EXPECT_EQ(expected->quota_bytes_used(), about_resource->quota_bytes_used()); + EXPECT_EQ(expected->quota_bytes_used_aggregate(), + about_resource->quota_bytes_used_aggregate()); EXPECT_EQ(expected->root_folder_id(), about_resource->root_folder_id()); } @@ -666,7 +667,8 @@ TEST_F(DriveApiRequestsTest, AboutGetRequest_ValidJson) { ASSERT_TRUE(about_resource.get()); EXPECT_EQ(expected->largest_change_id(), about_resource->largest_change_id()); EXPECT_EQ(expected->quota_bytes_total(), about_resource->quota_bytes_total()); - EXPECT_EQ(expected->quota_bytes_used(), about_resource->quota_bytes_used()); + EXPECT_EQ(expected->quota_bytes_used_aggregate(), + about_resource->quota_bytes_used_aggregate()); EXPECT_EQ(expected->root_folder_id(), about_resource->root_folder_id()); } |