| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/browsing_data_cache_storage_helper.h" | 5 #include "chrome/browser/browsing_data/browsing_data_cache_storage_helper.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 DCHECK(!callback.is_null()); | 25 DCHECK(!callback.is_null()); |
| 26 | 26 |
| 27 std::list<content::CacheStorageUsageInfo> result; | 27 std::list<content::CacheStorageUsageInfo> result; |
| 28 for (const CacheStorageUsageInfo& origin : origins) { | 28 for (const CacheStorageUsageInfo& origin : origins) { |
| 29 if (!BrowsingDataHelper::HasWebScheme(origin.origin)) | 29 if (!BrowsingDataHelper::HasWebScheme(origin.origin)) |
| 30 continue; // Non-websafe state is not considered browsing data. | 30 continue; // Non-websafe state is not considered browsing data. |
| 31 result.push_back(origin); | 31 result.push_back(origin); |
| 32 } | 32 } |
| 33 | 33 |
| 34 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 34 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 35 base::Bind(callback, result)); | 35 base::BindOnce(callback, result)); |
| 36 } | 36 } |
| 37 | 37 |
| 38 } // namespace | 38 } // namespace |
| 39 | 39 |
| 40 BrowsingDataCacheStorageHelper::BrowsingDataCacheStorageHelper( | 40 BrowsingDataCacheStorageHelper::BrowsingDataCacheStorageHelper( |
| 41 CacheStorageContext* cache_storage_context) | 41 CacheStorageContext* cache_storage_context) |
| 42 : cache_storage_context_(cache_storage_context) { | 42 : cache_storage_context_(cache_storage_context) { |
| 43 DCHECK(cache_storage_context_); | 43 DCHECK(cache_storage_context_); |
| 44 } | 44 } |
| 45 | 45 |
| 46 BrowsingDataCacheStorageHelper::~BrowsingDataCacheStorageHelper() {} | 46 BrowsingDataCacheStorageHelper::~BrowsingDataCacheStorageHelper() {} |
| 47 | 47 |
| 48 void BrowsingDataCacheStorageHelper::StartFetching( | 48 void BrowsingDataCacheStorageHelper::StartFetching( |
| 49 const FetchCallback& callback) { | 49 const FetchCallback& callback) { |
| 50 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 50 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 51 DCHECK(!callback.is_null()); | 51 DCHECK(!callback.is_null()); |
| 52 BrowserThread::PostTask( | 52 BrowserThread::PostTask( |
| 53 BrowserThread::IO, FROM_HERE, | 53 BrowserThread::IO, FROM_HERE, |
| 54 base::Bind( | 54 base::BindOnce( |
| 55 &BrowsingDataCacheStorageHelper::FetchCacheStorageUsageInfoOnIOThread, | 55 &BrowsingDataCacheStorageHelper::FetchCacheStorageUsageInfoOnIOThread, |
| 56 this, callback)); | 56 this, callback)); |
| 57 } | 57 } |
| 58 | 58 |
| 59 void BrowsingDataCacheStorageHelper::DeleteCacheStorage(const GURL& origin) { | 59 void BrowsingDataCacheStorageHelper::DeleteCacheStorage(const GURL& origin) { |
| 60 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 60 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 61 BrowserThread::PostTask( | 61 BrowserThread::PostTask( |
| 62 BrowserThread::IO, FROM_HERE, | 62 BrowserThread::IO, FROM_HERE, |
| 63 base::Bind(&BrowsingDataCacheStorageHelper::DeleteCacheStorageOnIOThread, | 63 base::BindOnce( |
| 64 this, origin)); | 64 &BrowsingDataCacheStorageHelper::DeleteCacheStorageOnIOThread, this, |
| 65 origin)); |
| 65 } | 66 } |
| 66 | 67 |
| 67 void BrowsingDataCacheStorageHelper::FetchCacheStorageUsageInfoOnIOThread( | 68 void BrowsingDataCacheStorageHelper::FetchCacheStorageUsageInfoOnIOThread( |
| 68 const FetchCallback& callback) { | 69 const FetchCallback& callback) { |
| 69 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 70 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 70 DCHECK(!callback.is_null()); | 71 DCHECK(!callback.is_null()); |
| 71 cache_storage_context_->GetAllOriginsInfo( | 72 cache_storage_context_->GetAllOriginsInfo( |
| 72 base::Bind(&GetAllOriginsInfoCallback, callback)); | 73 base::Bind(&GetAllOriginsInfoCallback, callback)); |
| 73 } | 74 } |
| 74 | 75 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 std::list<CacheStorageUsageInfo> result; | 135 std::list<CacheStorageUsageInfo> result; |
| 135 for (const PendingCacheStorageUsageInfo& pending_info : | 136 for (const PendingCacheStorageUsageInfo& pending_info : |
| 136 pending_cache_storage_info_) { | 137 pending_cache_storage_info_) { |
| 137 CacheStorageUsageInfo info(pending_info.origin, | 138 CacheStorageUsageInfo info(pending_info.origin, |
| 138 pending_info.total_size_bytes, | 139 pending_info.total_size_bytes, |
| 139 pending_info.last_modified); | 140 pending_info.last_modified); |
| 140 result.push_back(info); | 141 result.push_back(info); |
| 141 } | 142 } |
| 142 | 143 |
| 143 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 144 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 144 base::Bind(callback, result)); | 145 base::BindOnce(callback, result)); |
| 145 } | 146 } |
| 146 | 147 |
| 147 void CannedBrowsingDataCacheStorageHelper::DeleteCacheStorage( | 148 void CannedBrowsingDataCacheStorageHelper::DeleteCacheStorage( |
| 148 const GURL& origin) { | 149 const GURL& origin) { |
| 149 for (std::set<PendingCacheStorageUsageInfo>::iterator it = | 150 for (std::set<PendingCacheStorageUsageInfo>::iterator it = |
| 150 pending_cache_storage_info_.begin(); | 151 pending_cache_storage_info_.begin(); |
| 151 it != pending_cache_storage_info_.end();) { | 152 it != pending_cache_storage_info_.end();) { |
| 152 if (it->origin == origin) | 153 if (it->origin == origin) |
| 153 pending_cache_storage_info_.erase(it++); | 154 pending_cache_storage_info_.erase(it++); |
| 154 else | 155 else |
| 155 ++it; | 156 ++it; |
| 156 } | 157 } |
| 157 BrowsingDataCacheStorageHelper::DeleteCacheStorage(origin); | 158 BrowsingDataCacheStorageHelper::DeleteCacheStorage(origin); |
| 158 } | 159 } |
| OLD | NEW |