| 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.origin(), false); |
| 80 DCHECK(io_helper_); | 82 DCHECK(io_helper_); |
| 81 BrowserThread::PostTask( | 83 BrowserThread::PostTask( |
| 82 BrowserThread::IO, FROM_HERE, | 84 BrowserThread::IO, FROM_HERE, |
| 83 base::Bind(&IOThreadHelper::SendAbort, base::Unretained(io_helper_.get()), | 85 base::Bind(&IOThreadHelper::SendAbort, base::Unretained(io_helper_.get()), |
| 84 dispatcher_host_->RendererTransactionId(host_transaction_id), | 86 transaction.id(), error)); |
| 85 error)); | |
| 86 } | 87 } |
| 87 | 88 |
| 88 void IndexedDBDatabaseCallbacks::OnComplete(int64_t host_transaction_id) { | 89 void IndexedDBDatabaseCallbacks::OnComplete( |
| 90 const IndexedDBTransaction& transaction) { |
| 89 DCHECK(thread_checker_.CalledOnValidThread()); | 91 DCHECK(thread_checker_.CalledOnValidThread()); |
| 90 if (!dispatcher_host_) | 92 if (!dispatcher_host_) |
| 91 return; | 93 return; |
| 92 | 94 |
| 93 dispatcher_host_->FinishTransaction(host_transaction_id, true); | 95 dispatcher_host_->FinishTransaction(transaction.origin(), true); |
| 94 DCHECK(io_helper_); | 96 DCHECK(io_helper_); |
| 95 BrowserThread::PostTask( | 97 BrowserThread::PostTask( |
| 96 BrowserThread::IO, FROM_HERE, | 98 BrowserThread::IO, FROM_HERE, |
| 97 base::Bind(&IOThreadHelper::SendComplete, | 99 base::Bind(&IOThreadHelper::SendComplete, |
| 98 base::Unretained(io_helper_.get()), | 100 base::Unretained(io_helper_.get()), transaction.id())); |
| 99 dispatcher_host_->RendererTransactionId(host_transaction_id))); | |
| 100 } | 101 } |
| 101 | 102 |
| 102 void IndexedDBDatabaseCallbacks::OnDatabaseChange( | 103 void IndexedDBDatabaseCallbacks::OnDatabaseChange( |
| 103 std::unique_ptr<IndexedDBObserverChanges> changes) { | 104 std::unique_ptr<IndexedDBObserverChanges> changes) { |
| 104 DCHECK(thread_checker_.CalledOnValidThread()); | 105 DCHECK(thread_checker_.CalledOnValidThread()); |
| 105 DCHECK(io_helper_); | 106 DCHECK(io_helper_); |
| 106 dispatcher_host_->Send(new IndexedDBMsg_DatabaseCallbacksChanges( | 107 dispatcher_host_->Send(new IndexedDBMsg_DatabaseCallbacksChanges( |
| 107 ipc_thread_id_, | 108 ipc_thread_id_, |
| 108 IndexedDBDispatcherHost::ConvertObserverChanges(std::move(changes)))); | 109 IndexedDBDispatcherHost::ConvertObserverChanges(std::move(changes)))); |
| 109 } | 110 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 130 const IndexedDBDatabaseError& error) { | 131 const IndexedDBDatabaseError& error) { |
| 131 callbacks_->Abort(transaction_id, error.code(), error.message()); | 132 callbacks_->Abort(transaction_id, error.code(), error.message()); |
| 132 } | 133 } |
| 133 | 134 |
| 134 void IndexedDBDatabaseCallbacks::IOThreadHelper::SendComplete( | 135 void IndexedDBDatabaseCallbacks::IOThreadHelper::SendComplete( |
| 135 int64_t transaction_id) { | 136 int64_t transaction_id) { |
| 136 callbacks_->Complete(transaction_id); | 137 callbacks_->Complete(transaction_id); |
| 137 } | 138 } |
| 138 | 139 |
| 139 } // namespace content | 140 } // namespace content |
| OLD | NEW |