| 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 "content/browser/indexed_db/indexed_db_dispatcher_host.h" | 5 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/guid.h" | 9 #include "base/guid.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 indexed_db_context_->TaskRunner()->PostTask( | 135 indexed_db_context_->TaskRunner()->PostTask( |
| 136 FROM_HERE, | 136 FROM_HERE, |
| 137 base::Bind(&IndexedDBDispatcherHost::OpenOnIDBThread, this, | 137 base::Bind(&IndexedDBDispatcherHost::OpenOnIDBThread, this, |
| 138 base::Passed(&callbacks), base::Passed(&database_callbacks), | 138 base::Passed(&callbacks), base::Passed(&database_callbacks), |
| 139 origin, name, version, transaction_id)); | 139 origin, name, version, transaction_id)); |
| 140 } | 140 } |
| 141 | 141 |
| 142 void IndexedDBDispatcherHost::DeleteDatabase( | 142 void IndexedDBDispatcherHost::DeleteDatabase( |
| 143 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info, | 143 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info, |
| 144 const url::Origin& origin, | 144 const url::Origin& origin, |
| 145 const base::string16& name) { | 145 const base::string16& name, |
| 146 bool force_close) { |
| 146 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 147 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 147 | 148 |
| 148 if (!IsValidOrigin(origin)) { | 149 if (!IsValidOrigin(origin)) { |
| 149 mojo::ReportBadMessage(kInvalidOrigin); | 150 mojo::ReportBadMessage(kInvalidOrigin); |
| 150 return; | 151 return; |
| 151 } | 152 } |
| 152 | 153 |
| 153 scoped_refptr<IndexedDBCallbacks> callbacks( | 154 scoped_refptr<IndexedDBCallbacks> callbacks( |
| 154 new IndexedDBCallbacks(this, origin, std::move(callbacks_info))); | 155 new IndexedDBCallbacks(this, origin, std::move(callbacks_info))); |
| 155 indexed_db_context_->TaskRunner()->PostTask( | 156 indexed_db_context_->TaskRunner()->PostTask( |
| 156 FROM_HERE, base::Bind(&IndexedDBDispatcherHost::DeleteDatabaseOnIDBThread, | 157 FROM_HERE, base::Bind(&IndexedDBDispatcherHost::DeleteDatabaseOnIDBThread, |
| 157 this, base::Passed(&callbacks), origin, name)); | 158 this, base::Passed(&callbacks), origin, name, |
| 159 force_close)); |
| 158 } | 160 } |
| 159 | 161 |
| 160 void IndexedDBDispatcherHost::GetDatabaseNamesOnIDBThread( | 162 void IndexedDBDispatcherHost::GetDatabaseNamesOnIDBThread( |
| 161 scoped_refptr<IndexedDBCallbacks> callbacks, | 163 scoped_refptr<IndexedDBCallbacks> callbacks, |
| 162 const url::Origin& origin) { | 164 const url::Origin& origin) { |
| 163 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 165 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
| 164 | 166 |
| 165 base::FilePath indexed_db_path = indexed_db_context_->data_path(); | 167 base::FilePath indexed_db_path = indexed_db_context_->data_path(); |
| 166 context()->GetIDBFactory()->GetDatabaseNames( | 168 context()->GetIDBFactory()->GetDatabaseNames( |
| 167 callbacks, origin, indexed_db_path, request_context_getter_); | 169 callbacks, origin, indexed_db_path, request_context_getter_); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 188 version); | 190 version); |
| 189 DCHECK(request_context_getter_); | 191 DCHECK(request_context_getter_); |
| 190 context()->GetIDBFactory()->Open(name, std::move(connection), | 192 context()->GetIDBFactory()->Open(name, std::move(connection), |
| 191 request_context_getter_, origin, | 193 request_context_getter_, origin, |
| 192 indexed_db_path); | 194 indexed_db_path); |
| 193 } | 195 } |
| 194 | 196 |
| 195 void IndexedDBDispatcherHost::DeleteDatabaseOnIDBThread( | 197 void IndexedDBDispatcherHost::DeleteDatabaseOnIDBThread( |
| 196 scoped_refptr<IndexedDBCallbacks> callbacks, | 198 scoped_refptr<IndexedDBCallbacks> callbacks, |
| 197 const url::Origin& origin, | 199 const url::Origin& origin, |
| 198 const base::string16& name) { | 200 const base::string16& name, |
| 201 bool force_close) { |
| 199 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 202 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
| 200 | 203 |
| 201 base::FilePath indexed_db_path = indexed_db_context_->data_path(); | 204 base::FilePath indexed_db_path = indexed_db_context_->data_path(); |
| 202 DCHECK(request_context_getter_); | 205 DCHECK(request_context_getter_); |
| 203 context()->GetIDBFactory()->DeleteDatabase( | 206 context()->GetIDBFactory()->DeleteDatabase( |
| 204 name, request_context_getter_, callbacks, origin, indexed_db_path); | 207 name, request_context_getter_, callbacks, origin, indexed_db_path, |
| 208 force_close); |
| 205 } | 209 } |
| 206 | 210 |
| 207 } // namespace content | 211 } // namespace content |
| OLD | NEW |