| 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 else | 150 else |
| 151 --iter->second.second; | 151 --iter->second.second; |
| 152 } | 152 } |
| 153 | 153 |
| 154 void IndexedDBDispatcherHost::RenderProcessExited( | 154 void IndexedDBDispatcherHost::RenderProcessExited( |
| 155 RenderProcessHost* host, | 155 RenderProcessHost* host, |
| 156 base::TerminationStatus status, | 156 base::TerminationStatus status, |
| 157 int exit_code) { | 157 int exit_code) { |
| 158 BrowserThread::PostTask( | 158 BrowserThread::PostTask( |
| 159 BrowserThread::IO, FROM_HERE, | 159 BrowserThread::IO, FROM_HERE, |
| 160 base::Bind(&IndexedDBDispatcherHost::InvalidateWeakPtrsAndClearBindings, | 160 base::BindOnce( |
| 161 base::Unretained(this))); | 161 &IndexedDBDispatcherHost::InvalidateWeakPtrsAndClearBindings, |
| 162 base::Unretained(this))); |
| 162 } | 163 } |
| 163 | 164 |
| 164 void IndexedDBDispatcherHost::GetDatabaseNames( | 165 void IndexedDBDispatcherHost::GetDatabaseNames( |
| 165 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info, | 166 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info, |
| 166 const url::Origin& origin) { | 167 const url::Origin& origin) { |
| 167 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 168 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 168 | 169 |
| 169 if (!IsValidOrigin(origin)) { | 170 if (!IsValidOrigin(origin)) { |
| 170 mojo::ReportBadMessage(kInvalidOrigin); | 171 mojo::ReportBadMessage(kInvalidOrigin); |
| 171 return; | 172 return; |
| 172 } | 173 } |
| 173 | 174 |
| 174 scoped_refptr<IndexedDBCallbacks> callbacks(new IndexedDBCallbacks( | 175 scoped_refptr<IndexedDBCallbacks> callbacks(new IndexedDBCallbacks( |
| 175 this->AsWeakPtr(), origin, std::move(callbacks_info), idb_runner_)); | 176 this->AsWeakPtr(), origin, std::move(callbacks_info), idb_runner_)); |
| 176 idb_runner_->PostTask( | 177 idb_runner_->PostTask( |
| 177 FROM_HERE, base::Bind(&IDBSequenceHelper::GetDatabaseNamesOnIDBThread, | 178 FROM_HERE, base::BindOnce(&IDBSequenceHelper::GetDatabaseNamesOnIDBThread, |
| 178 base::Unretained(idb_helper_), | 179 base::Unretained(idb_helper_), |
| 179 base::Passed(&callbacks), origin)); | 180 base::Passed(&callbacks), origin)); |
| 180 } | 181 } |
| 181 | 182 |
| 182 void IndexedDBDispatcherHost::Open( | 183 void IndexedDBDispatcherHost::Open( |
| 183 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info, | 184 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info, |
| 184 ::indexed_db::mojom::DatabaseCallbacksAssociatedPtrInfo | 185 ::indexed_db::mojom::DatabaseCallbacksAssociatedPtrInfo |
| 185 database_callbacks_info, | 186 database_callbacks_info, |
| 186 const url::Origin& origin, | 187 const url::Origin& origin, |
| 187 const base::string16& name, | 188 const base::string16& name, |
| 188 int64_t version, | 189 int64_t version, |
| 189 int64_t transaction_id) { | 190 int64_t transaction_id) { |
| 190 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 191 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 191 | 192 |
| 192 if (!IsValidOrigin(origin)) { | 193 if (!IsValidOrigin(origin)) { |
| 193 mojo::ReportBadMessage(kInvalidOrigin); | 194 mojo::ReportBadMessage(kInvalidOrigin); |
| 194 return; | 195 return; |
| 195 } | 196 } |
| 196 | 197 |
| 197 scoped_refptr<IndexedDBCallbacks> callbacks(new IndexedDBCallbacks( | 198 scoped_refptr<IndexedDBCallbacks> callbacks(new IndexedDBCallbacks( |
| 198 this->AsWeakPtr(), origin, std::move(callbacks_info), idb_runner_)); | 199 this->AsWeakPtr(), origin, std::move(callbacks_info), idb_runner_)); |
| 199 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks( | 200 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks( |
| 200 new IndexedDBDatabaseCallbacks(indexed_db_context_, | 201 new IndexedDBDatabaseCallbacks(indexed_db_context_, |
| 201 std::move(database_callbacks_info))); | 202 std::move(database_callbacks_info))); |
| 202 idb_runner_->PostTask( | 203 idb_runner_->PostTask( |
| 203 FROM_HERE, | 204 FROM_HERE, |
| 204 base::Bind(&IDBSequenceHelper::OpenOnIDBThread, | 205 base::BindOnce(&IDBSequenceHelper::OpenOnIDBThread, |
| 205 base::Unretained(idb_helper_), base::Passed(&callbacks), | 206 base::Unretained(idb_helper_), base::Passed(&callbacks), |
| 206 base::Passed(&database_callbacks), origin, name, version, | 207 base::Passed(&database_callbacks), origin, name, version, |
| 207 transaction_id)); | 208 transaction_id)); |
| 208 } | 209 } |
| 209 | 210 |
| 210 void IndexedDBDispatcherHost::DeleteDatabase( | 211 void IndexedDBDispatcherHost::DeleteDatabase( |
| 211 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info, | 212 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info, |
| 212 const url::Origin& origin, | 213 const url::Origin& origin, |
| 213 const base::string16& name, | 214 const base::string16& name, |
| 214 bool force_close) { | 215 bool force_close) { |
| 215 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 216 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 216 | 217 |
| 217 if (!IsValidOrigin(origin)) { | 218 if (!IsValidOrigin(origin)) { |
| 218 mojo::ReportBadMessage(kInvalidOrigin); | 219 mojo::ReportBadMessage(kInvalidOrigin); |
| 219 return; | 220 return; |
| 220 } | 221 } |
| 221 | 222 |
| 222 scoped_refptr<IndexedDBCallbacks> callbacks(new IndexedDBCallbacks( | 223 scoped_refptr<IndexedDBCallbacks> callbacks(new IndexedDBCallbacks( |
| 223 this->AsWeakPtr(), origin, std::move(callbacks_info), idb_runner_)); | 224 this->AsWeakPtr(), origin, std::move(callbacks_info), idb_runner_)); |
| 224 idb_runner_->PostTask( | 225 idb_runner_->PostTask( |
| 225 FROM_HERE, | 226 FROM_HERE, |
| 226 base::Bind(&IDBSequenceHelper::DeleteDatabaseOnIDBThread, | 227 base::BindOnce(&IDBSequenceHelper::DeleteDatabaseOnIDBThread, |
| 227 base::Unretained(idb_helper_), base::Passed(&callbacks), | 228 base::Unretained(idb_helper_), base::Passed(&callbacks), |
| 228 origin, name, force_close)); | 229 origin, name, force_close)); |
| 229 } | 230 } |
| 230 | 231 |
| 231 void IndexedDBDispatcherHost::InvalidateWeakPtrsAndClearBindings() { | 232 void IndexedDBDispatcherHost::InvalidateWeakPtrsAndClearBindings() { |
| 232 weak_factory_.InvalidateWeakPtrs(); | 233 weak_factory_.InvalidateWeakPtrs(); |
| 233 cursor_bindings_.CloseAllBindings(); | 234 cursor_bindings_.CloseAllBindings(); |
| 234 database_bindings_.CloseAllBindings(); | 235 database_bindings_.CloseAllBindings(); |
| 235 } | 236 } |
| 236 | 237 |
| 237 void IndexedDBDispatcherHost::IDBSequenceHelper::GetDatabaseNamesOnIDBThread( | 238 void IndexedDBDispatcherHost::IDBSequenceHelper::GetDatabaseNamesOnIDBThread( |
| 238 scoped_refptr<IndexedDBCallbacks> callbacks, | 239 scoped_refptr<IndexedDBCallbacks> callbacks, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksInCurrentSequence()); | 278 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksInCurrentSequence()); |
| 278 | 279 |
| 279 base::FilePath indexed_db_path = indexed_db_context_->data_path(); | 280 base::FilePath indexed_db_path = indexed_db_context_->data_path(); |
| 280 DCHECK(request_context_getter_); | 281 DCHECK(request_context_getter_); |
| 281 indexed_db_context_->GetIDBFactory()->DeleteDatabase( | 282 indexed_db_context_->GetIDBFactory()->DeleteDatabase( |
| 282 name, request_context_getter_, callbacks, origin, indexed_db_path, | 283 name, request_context_getter_, callbacks, origin, indexed_db_path, |
| 283 force_close); | 284 force_close); |
| 284 } | 285 } |
| 285 | 286 |
| 286 } // namespace content | 287 } // namespace content |
| OLD | NEW |