| 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_observer_changes.h" | 10 #include "content/browser/indexed_db/indexed_db_observer_changes.h" |
| 11 #include "content/browser/indexed_db/indexed_db_transaction.h" |
| 11 #include "content/common/indexed_db/indexed_db_messages.h" | 12 #include "content/common/indexed_db/indexed_db_messages.h" |
| 12 | 13 |
| 13 using ::indexed_db::mojom::DatabaseCallbacksAssociatedPtrInfo; | 14 using ::indexed_db::mojom::DatabaseCallbacksAssociatedPtrInfo; |
| 14 | 15 |
| 15 namespace content { | 16 namespace content { |
| 16 | 17 |
| 17 class IndexedDBDatabaseCallbacks::IOThreadHelper { | 18 class IndexedDBDatabaseCallbacks::IOThreadHelper { |
| 18 public: | 19 public: |
| 19 explicit IOThreadHelper(DatabaseCallbacksAssociatedPtrInfo callbacks_info); | 20 explicit IOThreadHelper(DatabaseCallbacksAssociatedPtrInfo callbacks_info); |
| 20 ~IOThreadHelper(); | 21 ~IOThreadHelper(); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 if (!dispatcher_host_) | 64 if (!dispatcher_host_) |
| 64 return; | 65 return; |
| 65 | 66 |
| 66 DCHECK(io_helper_); | 67 DCHECK(io_helper_); |
| 67 BrowserThread::PostTask( | 68 BrowserThread::PostTask( |
| 68 BrowserThread::IO, FROM_HERE, | 69 BrowserThread::IO, FROM_HERE, |
| 69 base::Bind(&IOThreadHelper::SendVersionChange, | 70 base::Bind(&IOThreadHelper::SendVersionChange, |
| 70 base::Unretained(io_helper_.get()), old_version, new_version)); | 71 base::Unretained(io_helper_.get()), old_version, new_version)); |
| 71 } | 72 } |
| 72 | 73 |
| 73 void IndexedDBDatabaseCallbacks::OnAbort(int64_t host_transaction_id, | 74 void IndexedDBDatabaseCallbacks::OnAbort( |
| 74 const IndexedDBDatabaseError& error) { | 75 const IndexedDBTransaction& transaction, |
| 76 const IndexedDBDatabaseError& error) { |
| 75 DCHECK(thread_checker_.CalledOnValidThread()); | 77 DCHECK(thread_checker_.CalledOnValidThread()); |
| 76 if (!dispatcher_host_) | 78 if (!dispatcher_host_) |
| 77 return; | 79 return; |
| 78 | 80 |
| 79 dispatcher_host_->FinishTransaction(host_transaction_id, false); | 81 dispatcher_host_->FinishTransaction(transaction.connection()->origin(), |
| 82 false); |
| 80 DCHECK(io_helper_); | 83 DCHECK(io_helper_); |
| 81 BrowserThread::PostTask( | 84 BrowserThread::PostTask( |
| 82 BrowserThread::IO, FROM_HERE, | 85 BrowserThread::IO, FROM_HERE, |
| 83 base::Bind(&IOThreadHelper::SendAbort, base::Unretained(io_helper_.get()), | 86 base::Bind(&IOThreadHelper::SendAbort, base::Unretained(io_helper_.get()), |
| 84 dispatcher_host_->RendererTransactionId(host_transaction_id), | 87 transaction.id(), error)); |
| 85 error)); | |
| 86 } | 88 } |
| 87 | 89 |
| 88 void IndexedDBDatabaseCallbacks::OnComplete(int64_t host_transaction_id) { | 90 void IndexedDBDatabaseCallbacks::OnComplete( |
| 91 const IndexedDBTransaction& transaction) { |
| 89 DCHECK(thread_checker_.CalledOnValidThread()); | 92 DCHECK(thread_checker_.CalledOnValidThread()); |
| 90 if (!dispatcher_host_) | 93 if (!dispatcher_host_) |
| 91 return; | 94 return; |
| 92 | 95 |
| 93 dispatcher_host_->FinishTransaction(host_transaction_id, true); | 96 dispatcher_host_->FinishTransaction(transaction.connection()->origin(), true); |
| 94 DCHECK(io_helper_); | 97 DCHECK(io_helper_); |
| 95 BrowserThread::PostTask( | 98 BrowserThread::PostTask( |
| 96 BrowserThread::IO, FROM_HERE, | 99 BrowserThread::IO, FROM_HERE, |
| 97 base::Bind(&IOThreadHelper::SendComplete, | 100 base::Bind(&IOThreadHelper::SendComplete, |
| 98 base::Unretained(io_helper_.get()), | 101 base::Unretained(io_helper_.get()), transaction.id())); |
| 99 dispatcher_host_->RendererTransactionId(host_transaction_id))); | |
| 100 } | 102 } |
| 101 | 103 |
| 102 void IndexedDBDatabaseCallbacks::OnDatabaseChange( | 104 void IndexedDBDatabaseCallbacks::OnDatabaseChange( |
| 103 std::unique_ptr<IndexedDBObserverChanges> changes) { | 105 std::unique_ptr<IndexedDBObserverChanges> changes) { |
| 104 DCHECK(thread_checker_.CalledOnValidThread()); | 106 DCHECK(thread_checker_.CalledOnValidThread()); |
| 105 DCHECK(io_helper_); | 107 DCHECK(io_helper_); |
| 106 dispatcher_host_->Send(new IndexedDBMsg_DatabaseCallbacksChanges( | 108 dispatcher_host_->Send(new IndexedDBMsg_DatabaseCallbacksChanges( |
| 107 ipc_thread_id_, | 109 ipc_thread_id_, |
| 108 IndexedDBDispatcherHost::ConvertObserverChanges(std::move(changes)))); | 110 IndexedDBDispatcherHost::ConvertObserverChanges(std::move(changes)))); |
| 109 } | 111 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 130 const IndexedDBDatabaseError& error) { | 132 const IndexedDBDatabaseError& error) { |
| 131 callbacks_->Abort(transaction_id, error.code(), error.message()); | 133 callbacks_->Abort(transaction_id, error.code(), error.message()); |
| 132 } | 134 } |
| 133 | 135 |
| 134 void IndexedDBDatabaseCallbacks::IOThreadHelper::SendComplete( | 136 void IndexedDBDatabaseCallbacks::IOThreadHelper::SendComplete( |
| 135 int64_t transaction_id) { | 137 int64_t transaction_id) { |
| 136 callbacks_->Complete(transaction_id); | 138 callbacks_->Complete(transaction_id); |
| 137 } | 139 } |
| 138 | 140 |
| 139 } // namespace content | 141 } // namespace content |
| OLD | NEW |