| 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/browsing_data_indexed_db_helper.h" | 5 #include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h" |
| 6 | 6 |
| 7 #include <tuple> | 7 #include <tuple> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 } | 25 } |
| 26 | 26 |
| 27 BrowsingDataIndexedDBHelper::~BrowsingDataIndexedDBHelper() { | 27 BrowsingDataIndexedDBHelper::~BrowsingDataIndexedDBHelper() { |
| 28 } | 28 } |
| 29 | 29 |
| 30 void BrowsingDataIndexedDBHelper::StartFetching(const FetchCallback& callback) { | 30 void BrowsingDataIndexedDBHelper::StartFetching(const FetchCallback& callback) { |
| 31 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 31 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 32 DCHECK(!callback.is_null()); | 32 DCHECK(!callback.is_null()); |
| 33 indexed_db_context_->TaskRunner()->PostTask( | 33 indexed_db_context_->TaskRunner()->PostTask( |
| 34 FROM_HERE, | 34 FROM_HERE, |
| 35 base::Bind( | 35 base::BindOnce( |
| 36 &BrowsingDataIndexedDBHelper::FetchIndexedDBInfoInIndexedDBThread, | 36 &BrowsingDataIndexedDBHelper::FetchIndexedDBInfoInIndexedDBThread, |
| 37 this, callback)); | 37 this, callback)); |
| 38 } | 38 } |
| 39 | 39 |
| 40 void BrowsingDataIndexedDBHelper::DeleteIndexedDB(const GURL& origin) { | 40 void BrowsingDataIndexedDBHelper::DeleteIndexedDB(const GURL& origin) { |
| 41 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 41 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 42 indexed_db_context_->TaskRunner()->PostTask( | 42 indexed_db_context_->TaskRunner()->PostTask( |
| 43 FROM_HERE, | 43 FROM_HERE, |
| 44 base::Bind( | 44 base::BindOnce( |
| 45 &BrowsingDataIndexedDBHelper::DeleteIndexedDBInIndexedDBThread, | 45 &BrowsingDataIndexedDBHelper::DeleteIndexedDBInIndexedDBThread, this, |
| 46 this, | |
| 47 origin)); | 46 origin)); |
| 48 } | 47 } |
| 49 | 48 |
| 50 void BrowsingDataIndexedDBHelper::FetchIndexedDBInfoInIndexedDBThread( | 49 void BrowsingDataIndexedDBHelper::FetchIndexedDBInfoInIndexedDBThread( |
| 51 const FetchCallback& callback) { | 50 const FetchCallback& callback) { |
| 52 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 51 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
| 53 DCHECK(!callback.is_null()); | 52 DCHECK(!callback.is_null()); |
| 54 std::vector<IndexedDBInfo> origins = indexed_db_context_->GetAllOriginsInfo(); | 53 std::vector<IndexedDBInfo> origins = indexed_db_context_->GetAllOriginsInfo(); |
| 55 std::list<content::IndexedDBInfo> result; | 54 std::list<content::IndexedDBInfo> result; |
| 56 for (const IndexedDBInfo& origin : origins) { | 55 for (const IndexedDBInfo& origin : origins) { |
| 57 if (!BrowsingDataHelper::HasWebScheme(origin.origin)) | 56 if (!BrowsingDataHelper::HasWebScheme(origin.origin)) |
| 58 continue; // Non-websafe state is not considered browsing data. | 57 continue; // Non-websafe state is not considered browsing data. |
| 59 result.push_back(origin); | 58 result.push_back(origin); |
| 60 } | 59 } |
| 61 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 60 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 62 base::Bind(callback, result)); | 61 base::BindOnce(callback, result)); |
| 63 } | 62 } |
| 64 | 63 |
| 65 void BrowsingDataIndexedDBHelper::DeleteIndexedDBInIndexedDBThread( | 64 void BrowsingDataIndexedDBHelper::DeleteIndexedDBInIndexedDBThread( |
| 66 const GURL& origin) { | 65 const GURL& origin) { |
| 67 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 66 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
| 68 indexed_db_context_->DeleteForOrigin(origin); | 67 indexed_db_context_->DeleteForOrigin(origin); |
| 69 } | 68 } |
| 70 | 69 |
| 71 CannedBrowsingDataIndexedDBHelper:: | 70 CannedBrowsingDataIndexedDBHelper:: |
| 72 PendingIndexedDBInfo::PendingIndexedDBInfo(const GURL& origin, | 71 PendingIndexedDBInfo::PendingIndexedDBInfo(const GURL& origin, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 const FetchCallback& callback) { | 119 const FetchCallback& callback) { |
| 121 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 120 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 122 DCHECK(!callback.is_null()); | 121 DCHECK(!callback.is_null()); |
| 123 | 122 |
| 124 std::list<IndexedDBInfo> result; | 123 std::list<IndexedDBInfo> result; |
| 125 for (const PendingIndexedDBInfo& pending_info : pending_indexed_db_info_) { | 124 for (const PendingIndexedDBInfo& pending_info : pending_indexed_db_info_) { |
| 126 IndexedDBInfo info(pending_info.origin, 0, base::Time(), 0); | 125 IndexedDBInfo info(pending_info.origin, 0, base::Time(), 0); |
| 127 result.push_back(info); | 126 result.push_back(info); |
| 128 } | 127 } |
| 129 | 128 |
| 130 BrowserThread::PostTask( | 129 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 131 BrowserThread::UI, FROM_HERE, base::Bind(callback, result)); | 130 base::BindOnce(callback, result)); |
| 132 } | 131 } |
| 133 | 132 |
| 134 void CannedBrowsingDataIndexedDBHelper::DeleteIndexedDB( | 133 void CannedBrowsingDataIndexedDBHelper::DeleteIndexedDB( |
| 135 const GURL& origin) { | 134 const GURL& origin) { |
| 136 for (std::set<PendingIndexedDBInfo>::iterator it = | 135 for (std::set<PendingIndexedDBInfo>::iterator it = |
| 137 pending_indexed_db_info_.begin(); | 136 pending_indexed_db_info_.begin(); |
| 138 it != pending_indexed_db_info_.end(); ) { | 137 it != pending_indexed_db_info_.end(); ) { |
| 139 if (it->origin == origin) | 138 if (it->origin == origin) |
| 140 pending_indexed_db_info_.erase(it++); | 139 pending_indexed_db_info_.erase(it++); |
| 141 else | 140 else |
| 142 ++it; | 141 ++it; |
| 143 } | 142 } |
| 144 BrowsingDataIndexedDBHelper::DeleteIndexedDB(origin); | 143 BrowsingDataIndexedDBHelper::DeleteIndexedDB(origin); |
| 145 } | 144 } |
| OLD | NEW |