| 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/browsing_data/site_data_size_collector.h" | 5 #include "chrome/browser/browsing_data/site_data_size_collector.h" |
| 6 | 6 |
| 7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
| 8 #include "base/task_scheduler/post_task.h" | 8 #include "base/task_scheduler/post_task.h" |
| 9 #include "chrome/common/chrome_constants.h" | 9 #include "chrome/common/chrome_constants.h" |
| 10 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 const net::CookieList& cookie_list) { | 140 const net::CookieList& cookie_list) { |
| 141 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 141 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 142 | 142 |
| 143 if (cookie_list.empty()) { | 143 if (cookie_list.empty()) { |
| 144 OnStorageSizeFetched(0); | 144 OnStorageSizeFetched(0); |
| 145 return; | 145 return; |
| 146 } | 146 } |
| 147 base::FilePath cookie_file_path = default_storage_partition_path_ | 147 base::FilePath cookie_file_path = default_storage_partition_path_ |
| 148 .Append(chrome::kCookieFilename); | 148 .Append(chrome::kCookieFilename); |
| 149 base::PostTaskWithTraitsAndReplyWithResult( | 149 base::PostTaskWithTraitsAndReplyWithResult( |
| 150 FROM_HERE, base::TaskTraits().MayBlock().WithPriority( | 150 FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND}, |
| 151 base::TaskPriority::BACKGROUND), | |
| 152 base::Bind(&GetFileSizeBlocking, cookie_file_path), | 151 base::Bind(&GetFileSizeBlocking, cookie_file_path), |
| 153 base::Bind(&SiteDataSizeCollector::OnStorageSizeFetched, | 152 base::Bind(&SiteDataSizeCollector::OnStorageSizeFetched, |
| 154 weak_ptr_factory_.GetWeakPtr())); | 153 weak_ptr_factory_.GetWeakPtr())); |
| 155 } | 154 } |
| 156 | 155 |
| 157 void SiteDataSizeCollector::OnDatabaseModelInfoLoaded( | 156 void SiteDataSizeCollector::OnDatabaseModelInfoLoaded( |
| 158 const DatabaseInfoList& database_info_list) { | 157 const DatabaseInfoList& database_info_list) { |
| 159 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 158 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 160 int64_t total_size = 0; | 159 int64_t total_size = 0; |
| 161 for (const auto& database_info : database_info_list) | 160 for (const auto& database_info : database_info_list) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 const ChannelIDList& channel_id_list) { | 195 const ChannelIDList& channel_id_list) { |
| 197 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 196 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 198 | 197 |
| 199 if (channel_id_list.empty()) { | 198 if (channel_id_list.empty()) { |
| 200 OnStorageSizeFetched(0); | 199 OnStorageSizeFetched(0); |
| 201 return; | 200 return; |
| 202 } | 201 } |
| 203 base::FilePath channel_id_file_path = default_storage_partition_path_ | 202 base::FilePath channel_id_file_path = default_storage_partition_path_ |
| 204 .Append(chrome::kChannelIDFilename); | 203 .Append(chrome::kChannelIDFilename); |
| 205 base::PostTaskWithTraitsAndReplyWithResult( | 204 base::PostTaskWithTraitsAndReplyWithResult( |
| 206 FROM_HERE, base::TaskTraits().MayBlock().WithPriority( | 205 FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND}, |
| 207 base::TaskPriority::BACKGROUND), | |
| 208 base::Bind(&GetFileSizeBlocking, channel_id_file_path), | 206 base::Bind(&GetFileSizeBlocking, channel_id_file_path), |
| 209 base::Bind(&SiteDataSizeCollector::OnStorageSizeFetched, | 207 base::Bind(&SiteDataSizeCollector::OnStorageSizeFetched, |
| 210 weak_ptr_factory_.GetWeakPtr())); | 208 weak_ptr_factory_.GetWeakPtr())); |
| 211 } | 209 } |
| 212 | 210 |
| 213 void SiteDataSizeCollector::OnServiceWorkerModelInfoLoaded( | 211 void SiteDataSizeCollector::OnServiceWorkerModelInfoLoaded( |
| 214 const ServiceWorkerUsageInfoList& service_worker_info_list) { | 212 const ServiceWorkerUsageInfoList& service_worker_info_list) { |
| 215 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 213 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 216 int64_t total_size = 0; | 214 int64_t total_size = 0; |
| 217 for (const auto& service_worker_info : service_worker_info_list) | 215 for (const auto& service_worker_info : service_worker_info_list) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 234 | 232 |
| 235 // TODO(fukino): Flash is not the only plugin. We should check all types of | 233 // TODO(fukino): Flash is not the only plugin. We should check all types of |
| 236 // plugin data. | 234 // plugin data. |
| 237 if (domains.empty()) { | 235 if (domains.empty()) { |
| 238 OnStorageSizeFetched(0); | 236 OnStorageSizeFetched(0); |
| 239 return; | 237 return; |
| 240 } | 238 } |
| 241 base::FilePath pepper_data_dir_path = default_storage_partition_path_ | 239 base::FilePath pepper_data_dir_path = default_storage_partition_path_ |
| 242 .Append(content::kPepperDataDirname); | 240 .Append(content::kPepperDataDirname); |
| 243 base::PostTaskWithTraitsAndReplyWithResult( | 241 base::PostTaskWithTraitsAndReplyWithResult( |
| 244 FROM_HERE, base::TaskTraits().MayBlock().WithPriority( | 242 FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND}, |
| 245 base::TaskPriority::BACKGROUND), | |
| 246 base::Bind(&base::ComputeDirectorySize, pepper_data_dir_path), | 243 base::Bind(&base::ComputeDirectorySize, pepper_data_dir_path), |
| 247 base::Bind(&SiteDataSizeCollector::OnStorageSizeFetched, | 244 base::Bind(&SiteDataSizeCollector::OnStorageSizeFetched, |
| 248 weak_ptr_factory_.GetWeakPtr())); | 245 weak_ptr_factory_.GetWeakPtr())); |
| 249 } | 246 } |
| 250 | 247 |
| 251 void SiteDataSizeCollector::OnStorageSizeFetched(int64_t size) { | 248 void SiteDataSizeCollector::OnStorageSizeFetched(int64_t size) { |
| 252 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 249 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 253 if (size > 0) | 250 if (size > 0) |
| 254 total_bytes_ += size; | 251 total_bytes_ += size; |
| 255 if (--in_flight_operations_ == 0) | 252 if (--in_flight_operations_ == 0) |
| 256 fetch_callback_.Run(total_bytes_); | 253 fetch_callback_.Run(total_bytes_); |
| 257 } | 254 } |
| OLD | NEW |