| OLD | NEW |
| 1 // Copyright (c) 2011 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_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" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "chrome/browser/browsing_data_helper.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 16 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
| 17 #include "content/public/browser/indexed_db_context.h" | 18 #include "content/public/browser/indexed_db_context.h" |
| 18 #include "webkit/database/database_util.h" | 19 #include "webkit/database/database_util.h" |
| 19 #include "webkit/glue/webkit_glue.h" | 20 #include "webkit/glue/webkit_glue.h" |
| 20 | 21 |
| 21 using content::BrowserContext; | 22 using content::BrowserContext; |
| 22 using content::BrowserThread; | 23 using content::BrowserThread; |
| 23 using content::IndexedDBContext; | 24 using content::IndexedDBContext; |
| 24 using webkit_database::DatabaseUtil; | 25 using webkit_database::DatabaseUtil; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 &BrowsingDataIndexedDBHelperImpl::DeleteIndexedDBInWebKitThread, this, | 102 &BrowsingDataIndexedDBHelperImpl::DeleteIndexedDBInWebKitThread, this, |
| 102 origin)); | 103 origin)); |
| 103 } | 104 } |
| 104 | 105 |
| 105 void BrowsingDataIndexedDBHelperImpl::FetchIndexedDBInfoInWebKitThread() { | 106 void BrowsingDataIndexedDBHelperImpl::FetchIndexedDBInfoInWebKitThread() { |
| 106 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 107 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 107 std::vector<GURL> origins = indexed_db_context_->GetAllOrigins(); | 108 std::vector<GURL> origins = indexed_db_context_->GetAllOrigins(); |
| 108 for (std::vector<GURL>::const_iterator iter = origins.begin(); | 109 for (std::vector<GURL>::const_iterator iter = origins.begin(); |
| 109 iter != origins.end(); ++iter) { | 110 iter != origins.end(); ++iter) { |
| 110 const GURL& origin = *iter; | 111 const GURL& origin = *iter; |
| 111 if (origin.SchemeIs(chrome::kExtensionScheme)) | 112 if (!BrowsingDataHelper::HasValidScheme(origin)) |
| 112 continue; // Extension state is not considered browsing data. | 113 continue; // Non-websafe state is not considered browsing data. |
| 114 |
| 113 indexed_db_info_.push_back(IndexedDBInfo( | 115 indexed_db_info_.push_back(IndexedDBInfo( |
| 114 origin, | 116 origin, |
| 115 indexed_db_context_->GetOriginDiskUsage(origin), | 117 indexed_db_context_->GetOriginDiskUsage(origin), |
| 116 indexed_db_context_->GetOriginLastModified(origin))); | 118 indexed_db_context_->GetOriginLastModified(origin))); |
| 117 } | 119 } |
| 118 | 120 |
| 119 BrowserThread::PostTask( | 121 BrowserThread::PostTask( |
| 120 BrowserThread::UI, FROM_HERE, | 122 BrowserThread::UI, FROM_HERE, |
| 121 base::Bind(&BrowsingDataIndexedDBHelperImpl::NotifyInUIThread, this)); | 123 base::Bind(&BrowsingDataIndexedDBHelperImpl::NotifyInUIThread, this)); |
| 122 } | 124 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 new CannedBrowsingDataIndexedDBHelper(); | 185 new CannedBrowsingDataIndexedDBHelper(); |
| 184 | 186 |
| 185 base::AutoLock auto_lock(lock_); | 187 base::AutoLock auto_lock(lock_); |
| 186 clone->pending_indexed_db_info_ = pending_indexed_db_info_; | 188 clone->pending_indexed_db_info_ = pending_indexed_db_info_; |
| 187 clone->indexed_db_info_ = indexed_db_info_; | 189 clone->indexed_db_info_ = indexed_db_info_; |
| 188 return clone; | 190 return clone; |
| 189 } | 191 } |
| 190 | 192 |
| 191 void CannedBrowsingDataIndexedDBHelper::AddIndexedDB( | 193 void CannedBrowsingDataIndexedDBHelper::AddIndexedDB( |
| 192 const GURL& origin, const string16& description) { | 194 const GURL& origin, const string16& description) { |
| 195 if (!BrowsingDataHelper::HasValidScheme(origin)) |
| 196 return; // Non-websafe state is not considered browsing data. |
| 197 |
| 193 base::AutoLock auto_lock(lock_); | 198 base::AutoLock auto_lock(lock_); |
| 194 pending_indexed_db_info_.push_back(PendingIndexedDBInfo(origin, description)); | 199 pending_indexed_db_info_.push_back(PendingIndexedDBInfo(origin, description)); |
| 195 } | 200 } |
| 196 | 201 |
| 197 void CannedBrowsingDataIndexedDBHelper::Reset() { | 202 void CannedBrowsingDataIndexedDBHelper::Reset() { |
| 198 base::AutoLock auto_lock(lock_); | 203 base::AutoLock auto_lock(lock_); |
| 199 indexed_db_info_.clear(); | 204 indexed_db_info_.clear(); |
| 200 pending_indexed_db_info_.clear(); | 205 pending_indexed_db_info_.clear(); |
| 201 } | 206 } |
| 202 | 207 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 completion_callback_.Run(indexed_db_info_); | 266 completion_callback_.Run(indexed_db_info_); |
| 262 completion_callback_.Reset(); | 267 completion_callback_.Reset(); |
| 263 } | 268 } |
| 264 is_fetching_ = false; | 269 is_fetching_ = false; |
| 265 } | 270 } |
| 266 | 271 |
| 267 void CannedBrowsingDataIndexedDBHelper::CancelNotification() { | 272 void CannedBrowsingDataIndexedDBHelper::CancelNotification() { |
| 268 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 273 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 269 completion_callback_.Reset(); | 274 completion_callback_.Reset(); |
| 270 } | 275 } |
| OLD | NEW |