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/settings/chromeos/device_storage_handler.h" | 5 #include "chrome/browser/ui/webui/settings/chromeos/device_storage_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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 } | 136 } |
137 | 137 |
138 void StorageHandler::UpdateSizeStat() { | 138 void StorageHandler::UpdateSizeStat() { |
139 Profile* const profile = Profile::FromWebUI(web_ui()); | 139 Profile* const profile = Profile::FromWebUI(web_ui()); |
140 const base::FilePath downloads_path = | 140 const base::FilePath downloads_path = |
141 file_manager::util::GetDownloadsFolderForProfile(profile); | 141 file_manager::util::GetDownloadsFolderForProfile(profile); |
142 | 142 |
143 int64_t* total_size = new int64_t(0); | 143 int64_t* total_size = new int64_t(0); |
144 int64_t* available_size = new int64_t(0); | 144 int64_t* available_size = new int64_t(0); |
145 base::PostTaskWithTraitsAndReply( | 145 base::PostTaskWithTraitsAndReply( |
146 FROM_HERE, | 146 FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE}, |
147 base::TaskTraits() | |
148 .WithPriority(base::TaskPriority::USER_VISIBLE) | |
149 .MayBlock(), | |
150 base::Bind(&GetSizeStatBlocking, downloads_path, total_size, | 147 base::Bind(&GetSizeStatBlocking, downloads_path, total_size, |
151 available_size), | 148 available_size), |
152 base::Bind(&StorageHandler::OnGetSizeStat, base::Unretained(this), | 149 base::Bind(&StorageHandler::OnGetSizeStat, base::Unretained(this), |
153 base::Owned(total_size), base::Owned(available_size))); | 150 base::Owned(total_size), base::Owned(available_size))); |
154 } | 151 } |
155 | 152 |
156 void StorageHandler::OnGetSizeStat(int64_t* total_size, | 153 void StorageHandler::OnGetSizeStat(int64_t* total_size, |
157 int64_t* available_size) { | 154 int64_t* available_size) { |
158 int64_t used_size = *total_size - *available_size; | 155 int64_t used_size = *total_size - *available_size; |
159 base::DictionaryValue size_stat; | 156 base::DictionaryValue size_stat; |
(...skipping 16 matching lines...) Expand all Loading... |
176 void StorageHandler::UpdateDownloadsSize() { | 173 void StorageHandler::UpdateDownloadsSize() { |
177 if (updating_downloads_size_) | 174 if (updating_downloads_size_) |
178 return; | 175 return; |
179 updating_downloads_size_ = true; | 176 updating_downloads_size_ = true; |
180 | 177 |
181 Profile* const profile = Profile::FromWebUI(web_ui()); | 178 Profile* const profile = Profile::FromWebUI(web_ui()); |
182 const base::FilePath downloads_path = | 179 const base::FilePath downloads_path = |
183 file_manager::util::GetDownloadsFolderForProfile(profile); | 180 file_manager::util::GetDownloadsFolderForProfile(profile); |
184 | 181 |
185 base::PostTaskWithTraitsAndReplyWithResult( | 182 base::PostTaskWithTraitsAndReplyWithResult( |
186 FROM_HERE, base::TaskTraits().MayBlock().WithPriority( | 183 FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND}, |
187 base::TaskPriority::BACKGROUND), | |
188 base::Bind(&base::ComputeDirectorySize, downloads_path), | 184 base::Bind(&base::ComputeDirectorySize, downloads_path), |
189 base::Bind(&StorageHandler::OnGetDownloadsSize, base::Unretained(this))); | 185 base::Bind(&StorageHandler::OnGetDownloadsSize, base::Unretained(this))); |
190 } | 186 } |
191 | 187 |
192 void StorageHandler::OnGetDownloadsSize(int64_t size) { | 188 void StorageHandler::OnGetDownloadsSize(int64_t size) { |
193 updating_downloads_size_ = false; | 189 updating_downloads_size_ = false; |
194 CallJavascriptFunction("cr.webUIListenerCallback", | 190 CallJavascriptFunction("cr.webUIListenerCallback", |
195 base::Value("storage-downloads-size-changed"), | 191 base::Value("storage-downloads-size-changed"), |
196 base::Value(ui::FormatBytes(size))); | 192 base::Value(ui::FormatBytes(size))); |
197 } | 193 } |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 base::Value("storage-android-size-changed"), | 374 base::Value("storage-android-size-changed"), |
379 base::Value(size_string)); | 375 base::Value(size_string)); |
380 } | 376 } |
381 | 377 |
382 void StorageHandler::OnClearDriveCacheDone(bool success) { | 378 void StorageHandler::OnClearDriveCacheDone(bool success) { |
383 UpdateDriveCacheSize(); | 379 UpdateDriveCacheSize(); |
384 } | 380 } |
385 | 381 |
386 } // namespace settings | 382 } // namespace settings |
387 } // namespace chromeos | 383 } // namespace chromeos |
OLD | NEW |