Chromium Code Reviews| 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_database_callbacks.h" | 5 #include "content/browser/indexed_db/indexed_db_database_callbacks.h" |
| 6 | 6 |
| 7 #include "content/browser/indexed_db/indexed_db_context_impl.h" | 7 #include "content/browser/indexed_db/indexed_db_context_impl.h" |
| 8 #include "content/browser/indexed_db/indexed_db_database_error.h" | 8 #include "content/browser/indexed_db/indexed_db_database_error.h" |
| 9 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h" | 9 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h" |
| 10 #include "content/browser/indexed_db/indexed_db_transaction.h" | |
| 10 | 11 |
| 11 using ::indexed_db::mojom::DatabaseCallbacksAssociatedPtrInfo; | 12 using ::indexed_db::mojom::DatabaseCallbacksAssociatedPtrInfo; |
| 12 | 13 |
| 13 namespace content { | 14 namespace content { |
| 14 | 15 |
| 15 class IndexedDBDatabaseCallbacks::IOThreadHelper { | 16 class IndexedDBDatabaseCallbacks::IOThreadHelper { |
| 16 public: | 17 public: |
| 17 explicit IOThreadHelper(DatabaseCallbacksAssociatedPtrInfo callbacks_info); | 18 explicit IOThreadHelper(DatabaseCallbacksAssociatedPtrInfo callbacks_info); |
| 18 ~IOThreadHelper(); | 19 ~IOThreadHelper(); |
| 19 | 20 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 60 if (!dispatcher_host_) | 61 if (!dispatcher_host_) |
| 61 return; | 62 return; |
| 62 | 63 |
| 63 DCHECK(io_helper_); | 64 DCHECK(io_helper_); |
| 64 BrowserThread::PostTask( | 65 BrowserThread::PostTask( |
| 65 BrowserThread::IO, FROM_HERE, | 66 BrowserThread::IO, FROM_HERE, |
| 66 base::Bind(&IOThreadHelper::SendVersionChange, | 67 base::Bind(&IOThreadHelper::SendVersionChange, |
| 67 base::Unretained(io_helper_.get()), old_version, new_version)); | 68 base::Unretained(io_helper_.get()), old_version, new_version)); |
| 68 } | 69 } |
| 69 | 70 |
| 70 void IndexedDBDatabaseCallbacks::OnAbort(int64_t host_transaction_id, | 71 void IndexedDBDatabaseCallbacks::OnAbort( |
| 71 const IndexedDBDatabaseError& error) { | 72 const IndexedDBTransaction& transaction, |
| 73 const IndexedDBDatabaseError& error) { | |
| 72 DCHECK(thread_checker_.CalledOnValidThread()); | 74 DCHECK(thread_checker_.CalledOnValidThread()); |
| 73 if (!dispatcher_host_) | 75 if (!dispatcher_host_) |
| 74 return; | 76 return; |
| 75 | 77 |
| 76 dispatcher_host_->FinishTransaction(host_transaction_id, false); | |
| 77 DCHECK(io_helper_); | 78 DCHECK(io_helper_); |
| 78 BrowserThread::PostTask( | 79 BrowserThread::PostTask( |
| 79 BrowserThread::IO, FROM_HERE, | 80 BrowserThread::IO, FROM_HERE, |
| 80 base::Bind(&IOThreadHelper::SendAbort, base::Unretained(io_helper_.get()), | 81 base::Bind(&IOThreadHelper::SendAbort, base::Unretained(io_helper_.get()), |
| 81 dispatcher_host_->RendererTransactionId(host_transaction_id), | 82 transaction.id(), error)); |
| 82 error)); | |
| 83 } | 83 } |
| 84 | 84 |
| 85 void IndexedDBDatabaseCallbacks::OnComplete(int64_t host_transaction_id) { | 85 void IndexedDBDatabaseCallbacks::OnComplete( |
| 86 const IndexedDBTransaction& transaction) { | |
| 86 DCHECK(thread_checker_.CalledOnValidThread()); | 87 DCHECK(thread_checker_.CalledOnValidThread()); |
| 87 if (!dispatcher_host_) | 88 if (!dispatcher_host_) |
| 88 return; | 89 return; |
| 89 | 90 |
| 90 dispatcher_host_->FinishTransaction(host_transaction_id, true); | 91 dispatcher_host_->NotifyTransactionCommitted( |
|
jsbell
2016/11/30 21:30:14
How about just calling dispatcher_host_->context()
dmurph
2016/11/30 23:13:07
Done.
| |
| 92 transaction.database()->origin()); | |
| 91 DCHECK(io_helper_); | 93 DCHECK(io_helper_); |
| 92 BrowserThread::PostTask( | 94 BrowserThread::PostTask( |
| 93 BrowserThread::IO, FROM_HERE, | 95 BrowserThread::IO, FROM_HERE, |
| 94 base::Bind(&IOThreadHelper::SendComplete, | 96 base::Bind(&IOThreadHelper::SendComplete, |
| 95 base::Unretained(io_helper_.get()), | 97 base::Unretained(io_helper_.get()), transaction.id())); |
| 96 dispatcher_host_->RendererTransactionId(host_transaction_id))); | |
| 97 } | 98 } |
| 98 | 99 |
| 99 void IndexedDBDatabaseCallbacks::OnDatabaseChange( | 100 void IndexedDBDatabaseCallbacks::OnDatabaseChange( |
| 100 ::indexed_db::mojom::ObserverChangesPtr changes) { | 101 ::indexed_db::mojom::ObserverChangesPtr changes) { |
| 101 DCHECK(thread_checker_.CalledOnValidThread()); | 102 DCHECK(thread_checker_.CalledOnValidThread()); |
| 102 DCHECK(io_helper_); | 103 DCHECK(io_helper_); |
| 103 BrowserThread::PostTask( | 104 BrowserThread::PostTask( |
| 104 BrowserThread::IO, FROM_HERE, | 105 BrowserThread::IO, FROM_HERE, |
| 105 base::Bind(&IOThreadHelper::SendChanges, | 106 base::Bind(&IOThreadHelper::SendChanges, |
| 106 base::Unretained(io_helper_.get()), base::Passed(&changes))); | 107 base::Unretained(io_helper_.get()), base::Passed(&changes))); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 133 int64_t transaction_id) { | 134 int64_t transaction_id) { |
| 134 callbacks_->Complete(transaction_id); | 135 callbacks_->Complete(transaction_id); |
| 135 } | 136 } |
| 136 | 137 |
| 137 void IndexedDBDatabaseCallbacks::IOThreadHelper::SendChanges( | 138 void IndexedDBDatabaseCallbacks::IOThreadHelper::SendChanges( |
| 138 ::indexed_db::mojom::ObserverChangesPtr changes) { | 139 ::indexed_db::mojom::ObserverChangesPtr changes) { |
| 139 callbacks_->Changes(std::move(changes)); | 140 callbacks_->Changes(std::move(changes)); |
| 140 } | 141 } |
| 141 | 142 |
| 142 } // namespace content | 143 } // namespace content |
| OLD | NEW |