| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/ui/webui/options/chromeos/storage_manager_handler.h" | 5 #include "chrome/browser/ui/webui/options/chromeos/storage_manager_handler.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <numeric> | 8 #include <numeric> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 void StorageManagerHandler::OnGetDownloadsSize(int64_t size) { | 262 void StorageManagerHandler::OnGetDownloadsSize(int64_t size) { |
| 263 updating_downloads_size_ = false; | 263 updating_downloads_size_ = false; |
| 264 web_ui()->CallJavascriptFunctionUnsafe( | 264 web_ui()->CallJavascriptFunctionUnsafe( |
| 265 "options.StorageManager.setDownloadsSize", | 265 "options.StorageManager.setDownloadsSize", |
| 266 base::StringValue(ui::FormatBytes(size))); | 266 base::StringValue(ui::FormatBytes(size))); |
| 267 } | 267 } |
| 268 | 268 |
| 269 void StorageManagerHandler::UpdateDriveCacheSize() { | 269 void StorageManagerHandler::UpdateDriveCacheSize() { |
| 270 if (updating_drive_cache_size_) | 270 if (updating_drive_cache_size_) |
| 271 return; | 271 return; |
| 272 updating_drive_cache_size_ = true; | |
| 273 | 272 |
| 274 drive::FileSystemInterface* const file_system = | 273 drive::FileSystemInterface* const file_system = |
| 275 drive::util::GetFileSystemByProfile(Profile::FromWebUI(web_ui())); | 274 drive::util::GetFileSystemByProfile(Profile::FromWebUI(web_ui())); |
| 275 if (!file_system) |
| 276 return; |
| 277 |
| 278 // Shows the item "Offline cache" and start calculating size. |
| 279 web_ui()->CallJavascriptFunctionUnsafe( |
| 280 "options.StorageManager.showDriveCacheItem"); |
| 281 updating_drive_cache_size_ = true; |
| 276 file_system->CalculateCacheSize( | 282 file_system->CalculateCacheSize( |
| 277 base::Bind(&StorageManagerHandler::OnGetDriveCacheSize, | 283 base::Bind(&StorageManagerHandler::OnGetDriveCacheSize, |
| 278 weak_ptr_factory_.GetWeakPtr())); | 284 weak_ptr_factory_.GetWeakPtr())); |
| 279 } | 285 } |
| 280 | 286 |
| 281 void StorageManagerHandler::OnGetDriveCacheSize(int64_t size) { | 287 void StorageManagerHandler::OnGetDriveCacheSize(int64_t size) { |
| 282 updating_drive_cache_size_ = false; | 288 updating_drive_cache_size_ = false; |
| 283 web_ui()->CallJavascriptFunctionUnsafe( | 289 web_ui()->CallJavascriptFunctionUnsafe( |
| 284 "options.StorageManager.setDriveCacheSize", | 290 "options.StorageManager.setDriveCacheSize", |
| 285 base::StringValue(ui::FormatBytes(size))); | 291 base::StringValue(ui::FormatBytes(size))); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 web_ui()->CallJavascriptFunctionUnsafe("options.StorageManager.setArcSize", | 443 web_ui()->CallJavascriptFunctionUnsafe("options.StorageManager.setArcSize", |
| 438 base::StringValue(size_string)); | 444 base::StringValue(size_string)); |
| 439 } | 445 } |
| 440 | 446 |
| 441 void StorageManagerHandler::OnClearDriveCacheDone(bool success) { | 447 void StorageManagerHandler::OnClearDriveCacheDone(bool success) { |
| 442 UpdateDriveCacheSize(); | 448 UpdateDriveCacheSize(); |
| 443 } | 449 } |
| 444 | 450 |
| 445 } // namespace options | 451 } // namespace options |
| 446 } // namespace chromeos | 452 } // namespace chromeos |
| OLD | NEW |