| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_file_system_helper.h" | 5 #include "chrome/browser/browsing_data_file_system_helper.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 BrowserContext::GetFileSystemContext(profile_); | 120 BrowserContext::GetFileSystemContext(profile_); |
| 121 | 121 |
| 122 // We don't own this pointer; it's a magic singleton generated by the | 122 // We don't own this pointer; it's a magic singleton generated by the |
| 123 // profile's FileSystemContext. Deleting it would be a bad idea. | 123 // profile's FileSystemContext. Deleting it would be a bad idea. |
| 124 fileapi::FileSystemQuotaUtil* quota_util = | 124 fileapi::FileSystemQuotaUtil* quota_util = |
| 125 context->GetQuotaUtil(fileapi::kFileSystemTypeTemporary); | 125 context->GetQuotaUtil(fileapi::kFileSystemTypeTemporary); |
| 126 | 126 |
| 127 GURL current; | 127 GURL current; |
| 128 | 128 |
| 129 while (!(current = origin_enumerator->Next()).is_empty()) { | 129 while (!(current = origin_enumerator->Next()).is_empty()) { |
| 130 if (!BrowsingDataHelper::HasValidScheme(current)) | 130 if (!BrowsingDataHelper::HasWebScheme(current)) |
| 131 continue; // Non-websafe state is not considered browsing data. | 131 continue; // Non-websafe state is not considered browsing data. |
| 132 | 132 |
| 133 // We can call these synchronous methods as we've already verified that | 133 // We can call these synchronous methods as we've already verified that |
| 134 // we're running on the FILE thread. | 134 // we're running on the FILE thread. |
| 135 int64 persistent_usage = quota_util->GetOriginUsageOnFileThread( | 135 int64 persistent_usage = quota_util->GetOriginUsageOnFileThread( |
| 136 context, current, | 136 context, current, |
| 137 fileapi::kFileSystemTypePersistent); | 137 fileapi::kFileSystemTypePersistent); |
| 138 int64 temporary_usage = quota_util->GetOriginUsageOnFileThread( | 138 int64 temporary_usage = quota_util->GetOriginUsageOnFileThread( |
| 139 context, current, | 139 context, current, |
| 140 fileapi::kFileSystemTypeTemporary); | 140 fileapi::kFileSystemTypeTemporary); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 file_system->has_temporary = true; | 234 file_system->has_temporary = true; |
| 235 file_system->usage_temporary = size; | 235 file_system->usage_temporary = size; |
| 236 } | 236 } |
| 237 duplicate_origin = true; | 237 duplicate_origin = true; |
| 238 break; | 238 break; |
| 239 } | 239 } |
| 240 } | 240 } |
| 241 if (duplicate_origin) | 241 if (duplicate_origin) |
| 242 return; | 242 return; |
| 243 | 243 |
| 244 if (!BrowsingDataHelper::HasValidScheme(origin)) | 244 if (!BrowsingDataHelper::HasWebScheme(origin)) |
| 245 return; // Non-websafe state is not considered browsing data. | 245 return; // Non-websafe state is not considered browsing data. |
| 246 | 246 |
| 247 file_system_info_.push_back(FileSystemInfo( | 247 file_system_info_.push_back(FileSystemInfo( |
| 248 origin, | 248 origin, |
| 249 (type == fileapi::kFileSystemTypePersistent), | 249 (type == fileapi::kFileSystemTypePersistent), |
| 250 (type == fileapi::kFileSystemTypeTemporary), | 250 (type == fileapi::kFileSystemTypeTemporary), |
| 251 (type == fileapi::kFileSystemTypePersistent) ? size : 0, | 251 (type == fileapi::kFileSystemTypePersistent) ? size : 0, |
| 252 (type == fileapi::kFileSystemTypeTemporary) ? size : 0)); | 252 (type == fileapi::kFileSystemTypeTemporary) ? size : 0)); |
| 253 } | 253 } |
| 254 | 254 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 278 base::Bind(&CannedBrowsingDataFileSystemHelper::NotifyOnUIThread, this)); | 278 base::Bind(&CannedBrowsingDataFileSystemHelper::NotifyOnUIThread, this)); |
| 279 } | 279 } |
| 280 | 280 |
| 281 void CannedBrowsingDataFileSystemHelper::NotifyOnUIThread() { | 281 void CannedBrowsingDataFileSystemHelper::NotifyOnUIThread() { |
| 282 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 282 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 283 DCHECK(is_fetching_); | 283 DCHECK(is_fetching_); |
| 284 completion_callback_.Run(file_system_info_); | 284 completion_callback_.Run(file_system_info_); |
| 285 completion_callback_.Reset(); | 285 completion_callback_.Reset(); |
| 286 is_fetching_ = false; | 286 is_fetching_ = false; |
| 287 } | 287 } |
| OLD | NEW |