| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_indexed_db_helper.h" | 5 #include "chrome/browser/browsing_data_indexed_db_helper.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 | 72 |
| 73 void BrowsingDataIndexedDBHelperImpl::StartFetching( | 73 void BrowsingDataIndexedDBHelperImpl::StartFetching( |
| 74 const base::Callback<void(const std::list<IndexedDBInfo>&)>& callback) { | 74 const base::Callback<void(const std::list<IndexedDBInfo>&)>& callback) { |
| 75 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 75 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 76 DCHECK(!is_fetching_); | 76 DCHECK(!is_fetching_); |
| 77 DCHECK_EQ(false, callback.is_null()); | 77 DCHECK_EQ(false, callback.is_null()); |
| 78 | 78 |
| 79 is_fetching_ = true; | 79 is_fetching_ = true; |
| 80 completion_callback_ = callback; | 80 completion_callback_ = callback; |
| 81 BrowserThread::PostTask( | 81 BrowserThread::PostTask( |
| 82 BrowserThread::WEBKIT, FROM_HERE, | 82 BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, |
| 83 base::Bind( | 83 base::Bind( |
| 84 &BrowsingDataIndexedDBHelperImpl::FetchIndexedDBInfoInWebKitThread, | 84 &BrowsingDataIndexedDBHelperImpl::FetchIndexedDBInfoInWebKitThread, |
| 85 this)); | 85 this)); |
| 86 } | 86 } |
| 87 | 87 |
| 88 void BrowsingDataIndexedDBHelperImpl::CancelNotification() { | 88 void BrowsingDataIndexedDBHelperImpl::CancelNotification() { |
| 89 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 89 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 90 completion_callback_.Reset(); | 90 completion_callback_.Reset(); |
| 91 } | 91 } |
| 92 | 92 |
| 93 void BrowsingDataIndexedDBHelperImpl::DeleteIndexedDB( | 93 void BrowsingDataIndexedDBHelperImpl::DeleteIndexedDB( |
| 94 const GURL& origin) { | 94 const GURL& origin) { |
| 95 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 95 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 96 BrowserThread::PostTask( | 96 BrowserThread::PostTask( |
| 97 BrowserThread::WEBKIT, FROM_HERE, | 97 BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, |
| 98 base::Bind( | 98 base::Bind( |
| 99 &BrowsingDataIndexedDBHelperImpl::DeleteIndexedDBInWebKitThread, this, | 99 &BrowsingDataIndexedDBHelperImpl::DeleteIndexedDBInWebKitThread, this, |
| 100 origin)); | 100 origin)); |
| 101 } | 101 } |
| 102 | 102 |
| 103 void BrowsingDataIndexedDBHelperImpl::FetchIndexedDBInfoInWebKitThread() { | 103 void BrowsingDataIndexedDBHelperImpl::FetchIndexedDBInfoInWebKitThread() { |
| 104 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 104 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 105 std::vector<GURL> origins; | 105 std::vector<GURL> origins; |
| 106 indexed_db_context_->GetAllOrigins(&origins); | 106 indexed_db_context_->GetAllOrigins(&origins); |
| 107 for (std::vector<GURL>::const_iterator iter = origins.begin(); | 107 for (std::vector<GURL>::const_iterator iter = origins.begin(); |
| 108 iter != origins.end(); ++iter) { | 108 iter != origins.end(); ++iter) { |
| 109 const GURL& origin = *iter; | 109 const GURL& origin = *iter; |
| 110 if (origin.SchemeIs(chrome::kExtensionScheme)) | 110 if (origin.SchemeIs(chrome::kExtensionScheme)) |
| 111 continue; // Extension state is not considered browsing data. | 111 continue; // Extension state is not considered browsing data. |
| 112 indexed_db_info_.push_back(IndexedDBInfo( | 112 indexed_db_info_.push_back(IndexedDBInfo( |
| 113 origin, | 113 origin, |
| 114 indexed_db_context_->GetOriginDiskUsage(origin), | 114 indexed_db_context_->GetOriginDiskUsage(origin), |
| (...skipping 12 matching lines...) Expand all Loading... |
| 127 // test it here. | 127 // test it here. |
| 128 if (!completion_callback_.is_null()) { | 128 if (!completion_callback_.is_null()) { |
| 129 completion_callback_.Run(indexed_db_info_); | 129 completion_callback_.Run(indexed_db_info_); |
| 130 completion_callback_.Reset(); | 130 completion_callback_.Reset(); |
| 131 } | 131 } |
| 132 is_fetching_ = false; | 132 is_fetching_ = false; |
| 133 } | 133 } |
| 134 | 134 |
| 135 void BrowsingDataIndexedDBHelperImpl::DeleteIndexedDBInWebKitThread( | 135 void BrowsingDataIndexedDBHelperImpl::DeleteIndexedDBInWebKitThread( |
| 136 const GURL& origin) { | 136 const GURL& origin) { |
| 137 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 137 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 138 indexed_db_context_->DeleteIndexedDBForOrigin(origin); | 138 indexed_db_context_->DeleteIndexedDBForOrigin(origin); |
| 139 } | 139 } |
| 140 | 140 |
| 141 } // namespace | 141 } // namespace |
| 142 | 142 |
| 143 BrowsingDataIndexedDBHelper::IndexedDBInfo::IndexedDBInfo( | 143 BrowsingDataIndexedDBHelper::IndexedDBInfo::IndexedDBInfo( |
| 144 const GURL& origin, | 144 const GURL& origin, |
| 145 int64 size, | 145 int64 size, |
| 146 base::Time last_modified) | 146 base::Time last_modified) |
| 147 : origin(origin), | 147 : origin(origin), |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 | 206 |
| 207 void CannedBrowsingDataIndexedDBHelper::StartFetching( | 207 void CannedBrowsingDataIndexedDBHelper::StartFetching( |
| 208 const base::Callback<void(const std::list<IndexedDBInfo>&)>& callback) { | 208 const base::Callback<void(const std::list<IndexedDBInfo>&)>& callback) { |
| 209 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 209 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 210 DCHECK(!is_fetching_); | 210 DCHECK(!is_fetching_); |
| 211 DCHECK_EQ(false, callback.is_null()); | 211 DCHECK_EQ(false, callback.is_null()); |
| 212 | 212 |
| 213 is_fetching_ = true; | 213 is_fetching_ = true; |
| 214 completion_callback_ = callback; | 214 completion_callback_ = callback; |
| 215 BrowserThread::PostTask( | 215 BrowserThread::PostTask( |
| 216 BrowserThread::WEBKIT, FROM_HERE, | 216 BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, |
| 217 base::Bind( | 217 base::Bind( |
| 218 &CannedBrowsingDataIndexedDBHelper::ConvertPendingInfoInWebKitThread, | 218 &CannedBrowsingDataIndexedDBHelper::ConvertPendingInfoInWebKitThread, |
| 219 this)); | 219 this)); |
| 220 } | 220 } |
| 221 | 221 |
| 222 CannedBrowsingDataIndexedDBHelper::~CannedBrowsingDataIndexedDBHelper() {} | 222 CannedBrowsingDataIndexedDBHelper::~CannedBrowsingDataIndexedDBHelper() {} |
| 223 | 223 |
| 224 void CannedBrowsingDataIndexedDBHelper::ConvertPendingInfoInWebKitThread() { | 224 void CannedBrowsingDataIndexedDBHelper::ConvertPendingInfoInWebKitThread() { |
| 225 base::AutoLock auto_lock(lock_); | 225 base::AutoLock auto_lock(lock_); |
| 226 for (std::list<PendingIndexedDBInfo>::const_iterator | 226 for (std::list<PendingIndexedDBInfo>::const_iterator |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 completion_callback_.Run(indexed_db_info_); | 260 completion_callback_.Run(indexed_db_info_); |
| 261 completion_callback_.Reset(); | 261 completion_callback_.Reset(); |
| 262 } | 262 } |
| 263 is_fetching_ = false; | 263 is_fetching_ = false; |
| 264 } | 264 } |
| 265 | 265 |
| 266 void CannedBrowsingDataIndexedDBHelper::CancelNotification() { | 266 void CannedBrowsingDataIndexedDBHelper::CancelNotification() { |
| 267 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 267 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 268 completion_callback_.Reset(); | 268 completion_callback_.Reset(); |
| 269 } | 269 } |
| OLD | NEW |