Chromium Code Reviews| Index: content/browser/indexed_db/indexed_db_dispatcher_host.cc |
| diff --git a/content/browser/indexed_db/indexed_db_dispatcher_host.cc b/content/browser/indexed_db/indexed_db_dispatcher_host.cc |
| index 54b0be0b6114fa386602ac1eb1251e308d26864a..0cef1467b2e94c1713099fdc4430ad5bc41c55ef 100644 |
| --- a/content/browser/indexed_db/indexed_db_dispatcher_host.cc |
| +++ b/content/browser/indexed_db/indexed_db_dispatcher_host.cc |
| @@ -24,6 +24,7 @@ |
| #include "content/browser/indexed_db/indexed_db_observation.h" |
| #include "content/browser/indexed_db/indexed_db_observer_changes.h" |
| #include "content/browser/indexed_db/indexed_db_pending_connection.h" |
| +#include "content/browser/indexed_db/indexed_db_transaction.h" |
| #include "content/browser/indexed_db/indexed_db_value.h" |
| #include "content/browser/renderer_host/render_message_filter.h" |
| #include "content/common/indexed_db/indexed_db_messages.h" |
| @@ -144,11 +145,11 @@ bool IndexedDBDispatcherHost::OnMessageReceived(const IPC::Message& message) { |
| return handled; |
| } |
| -int32_t IndexedDBDispatcherHost::Add(IndexedDBCursor* cursor) { |
| +int32_t IndexedDBDispatcherHost::Add(std::unique_ptr<IndexedDBCursor> cursor) { |
| if (!cursor_dispatcher_host_) { |
| return 0; |
| } |
| - return cursor_dispatcher_host_->map_.Add(cursor); |
| + return cursor_dispatcher_host_->map_.Add(std::move(cursor)); |
| } |
| int32_t IndexedDBDispatcherHost::Add(IndexedDBConnection* connection, |
| @@ -164,47 +165,6 @@ int32_t IndexedDBDispatcherHost::Add(IndexedDBConnection* connection, |
| return ipc_database_id; |
| } |
| -void IndexedDBDispatcherHost::RegisterTransactionId(int64_t host_transaction_id, |
| - const url::Origin& origin) { |
| - if (!database_dispatcher_host_) |
| - return; |
| - database_dispatcher_host_->transaction_size_map_[host_transaction_id] = 0; |
| - database_dispatcher_host_->transaction_origin_map_[host_transaction_id] = |
| - origin; |
| -} |
| - |
| -int64_t IndexedDBDispatcherHost::HostTransactionId(int64_t transaction_id) { |
| - // Inject the renderer process id into the transaction id, to |
| - // uniquely identify this transaction, and effectively bind it to |
| - // the renderer that initiated it. The lower 32 bits of |
| - // transaction_id are guaranteed to be unique within that renderer. |
| - base::ProcessId pid = peer_pid(); |
| - DCHECK(!(transaction_id >> 32)) << "Transaction ids can only be 32 bits"; |
| - static_assert(sizeof(base::ProcessId) <= sizeof(int32_t), |
| - "Process ID must fit in 32 bits"); |
| - |
| - return transaction_id | (static_cast<uint64_t>(pid) << 32); |
| -} |
| - |
| -int64_t IndexedDBDispatcherHost::RendererTransactionId( |
| - int64_t host_transaction_id) { |
| - DCHECK(host_transaction_id >> 32 == peer_pid()) |
| - << "Invalid renderer target for transaction id"; |
| - return host_transaction_id & 0xffffffff; |
| -} |
| - |
| -// static |
| -uint32_t IndexedDBDispatcherHost::TransactionIdToRendererTransactionId( |
| - int64_t host_transaction_id) { |
| - return host_transaction_id & 0xffffffff; |
| -} |
| - |
| -// static |
| -uint32_t IndexedDBDispatcherHost::TransactionIdToProcessId( |
| - int64_t host_transaction_id) { |
| - return (host_transaction_id >> 32) & 0xffffffff; |
| -} |
| - |
| std::string IndexedDBDispatcherHost::HoldBlobData( |
| const IndexedDBBlobInfo& blob_info) { |
| DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| @@ -363,15 +323,13 @@ void IndexedDBDispatcherHost::OpenOnIDBThread( |
| base::TimeTicks begin_time = base::TimeTicks::Now(); |
| base::FilePath indexed_db_path = indexed_db_context_->data_path(); |
| - int64_t host_transaction_id = HostTransactionId(transaction_id); |
| - |
| // TODO(dgrogan): Don't let a non-existing database be opened (and therefore |
| // created) if this origin is already over quota. |
| callbacks->SetConnectionOpenStartTime(begin_time); |
| - callbacks->set_host_transaction_id(host_transaction_id); |
| + callbacks->set_host_transaction_id(transaction_id); |
| std::unique_ptr<IndexedDBPendingConnection> connection = |
| base::MakeUnique<IndexedDBPendingConnection>( |
| - callbacks, database_callbacks, ipc_process_id_, host_transaction_id, |
| + callbacks, database_callbacks, ipc_process_id_, transaction_id, |
| version); |
| DCHECK(request_context_getter_); |
| context()->GetIDBFactory()->Open(name, std::move(connection), |
| @@ -406,22 +364,13 @@ void IndexedDBDispatcherHost::OnAckReceivedBlobs( |
| DropBlobData(uuid); |
| } |
| -void IndexedDBDispatcherHost::FinishTransaction(int64_t host_transaction_id, |
| +void IndexedDBDispatcherHost::FinishTransaction(url::Origin transaction_origin, |
| bool committed) { |
| DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
| if (!database_dispatcher_host_) |
| return; |
| - TransactionIDToOriginMap& transaction_origin_map = |
| - database_dispatcher_host_->transaction_origin_map_; |
| - TransactionIDToSizeMap& transaction_size_map = |
| - database_dispatcher_host_->transaction_size_map_; |
| - TransactionIDToDatabaseIDMap& transaction_database_map = |
| - database_dispatcher_host_->transaction_database_map_; |
| if (committed) |
| - context()->TransactionComplete(transaction_origin_map[host_transaction_id]); |
| - transaction_origin_map.erase(host_transaction_id); |
| - transaction_size_map.erase(host_transaction_id); |
| - transaction_database_map.erase(host_transaction_id); |
| + context()->TransactionComplete(transaction_origin); |
| } |
| ////////////////////////////////////////////////////////////////////// |
| @@ -484,20 +433,18 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::CloseAll() { |
| // Abort outstanding transactions started by connections in the associated |
| // front-end to unblock later transactions. This should only occur on unclean |
| // (crash) or abrupt (process-kill) shutdowns. |
| - for (TransactionIDToDatabaseIDMap::iterator iter = |
| - transaction_database_map_.begin(); |
| - iter != transaction_database_map_.end();) { |
| - int64_t transaction_id = iter->first; |
| - int32_t ipc_database_id = iter->second; |
| - ++iter; |
| - IndexedDBConnection* connection = map_.Lookup(ipc_database_id); |
| + IDMap<IndexedDBConnection, IDMapOwnPointer>::iterator iterator(&map_); |
| + while (!iterator.IsAtEnd()) { |
|
jsbell
2016/11/04 17:48:19
We can't use range-based for here? :(
dmurph
2016/11/04 22:52:24
We got rid of the extra map, and this map doesn't
|
| + IndexedDBConnection* connection = iterator.GetCurrentValue(); |
| if (connection && connection->IsConnected()) { |
| - connection->database()->Abort( |
| - transaction_id, |
| - IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionUnknownError)); |
| + for (const auto& transaction_pair : connection->transactions()) { |
| + connection->database()->Abort( |
|
jsbell
2016/11/04 17:48:19
As an aside (maybe a TODO?) - maybe we want to cop
dmurph
2016/11/04 22:52:24
Acknowledged.
|
| + transaction_pair.second.get(), |
| + IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionUnknownError)); |
| + } |
| } |
| + iterator.Advance(); |
| } |
| - DCHECK(transaction_database_map_.empty()); |
| for (const auto& iter : database_origin_map_) { |
| IndexedDBConnection* connection = map_.Lookup(iter.first); |
| @@ -559,13 +506,13 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateObjectStore( |
| parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); |
| if (!connection || !connection->IsConnected()) |
| return; |
| + IndexedDBTransaction* transaction = |
| + connection->GetTransaction(params.transaction_id); |
| + if (!transaction) |
| + return; |
| - int64_t host_transaction_id = |
| - parent_->HostTransactionId(params.transaction_id); |
| - connection->database()->CreateObjectStore(host_transaction_id, |
| - params.object_store_id, |
| - params.name, |
| - params.key_path, |
| + connection->database()->CreateObjectStore(transaction, params.object_store_id, |
| + params.name, params.key_path, |
| params.auto_increment); |
| } |
| @@ -578,9 +525,12 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteObjectStore( |
| parent_->GetOrTerminateProcess(&map_, ipc_database_id); |
| if (!connection || !connection->IsConnected()) |
| return; |
| + IndexedDBTransaction* transaction = |
| + connection->GetTransaction(transaction_id); |
| + if (!transaction) |
| + return; |
| - connection->database()->DeleteObjectStore( |
| - parent_->HostTransactionId(transaction_id), object_store_id); |
| + connection->database()->DeleteObjectStore(transaction, object_store_id); |
| } |
| void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnRenameObjectStore( |
| @@ -593,9 +543,13 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnRenameObjectStore( |
| parent_->GetOrTerminateProcess(&map_, ipc_database_id); |
| if (!connection || !connection->IsConnected()) |
| return; |
| + IndexedDBTransaction* transaction = |
| + connection->GetTransaction(transaction_id); |
| + if (!transaction) |
| + return; |
| - connection->database()->RenameObjectStore( |
| - parent_->HostTransactionId(transaction_id), object_store_id, new_name); |
| + connection->database()->RenameObjectStore(transaction, object_store_id, |
| + new_name); |
| } |
| void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateTransaction( |
| @@ -606,19 +560,14 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateTransaction( |
| if (!connection || !connection->IsConnected()) |
| return; |
| - int64_t host_transaction_id = |
| - parent_->HostTransactionId(params.transaction_id); |
| - |
| - if (base::ContainsKey(transaction_database_map_, host_transaction_id)) { |
| + if (connection->GetTransaction(params.transaction_id)) { |
| DLOG(ERROR) << "Duplicate host_transaction_id."; |
| return; |
| } |
| - connection->database()->CreateTransaction( |
| - host_transaction_id, connection, params.object_store_ids, params.mode); |
| - transaction_database_map_[host_transaction_id] = params.ipc_database_id; |
| - parent_->RegisterTransactionId(host_transaction_id, |
| - database_origin_map_[params.ipc_database_id]); |
| + IndexedDBTransaction* transaction = connection->database()->CreateTransaction( |
| + params.transaction_id, connection, params.object_store_ids, params.mode); |
| + transaction->set_origin(database_origin_map_[params.ipc_database_id]); |
|
cmumford
2016/11/04 23:33:12
Why aren't we passing in the origin to CreateTrans
dmurph
2016/11/07 20:05:23
No longer needed now that we store it on the conne
|
| } |
| void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnClose( |
| @@ -663,12 +612,15 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnObserve( |
| parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); |
| if (!connection || !connection->IsConnected()) |
| return; |
| + IndexedDBTransaction* transaction = |
| + connection->GetTransaction(params.transaction_id); |
| + if (!transaction) |
| + return; |
| IndexedDBObserver::Options options(params.include_transaction, |
| params.no_records, params.values, |
| params.operation_types); |
| - connection->database()->AddPendingObserver( |
| - parent_->HostTransactionId(params.transaction_id), params.observer_id, |
| - options); |
| + connection->database()->AddPendingObserver(transaction, params.observer_id, |
| + options); |
| } |
| void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnUnobserve( |
| @@ -690,13 +642,17 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnGet( |
| parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); |
| if (!connection || !connection->IsConnected()) |
| return; |
| + IndexedDBTransaction* transaction = |
| + connection->GetTransaction(params.transaction_id); |
| + if (!transaction) |
| + return; |
| scoped_refptr<IndexedDBCallbacks> callbacks(new IndexedDBCallbacks( |
| parent_, params.ipc_thread_id, params.ipc_callbacks_id)); |
| connection->database()->Get( |
| - parent_->HostTransactionId(params.transaction_id), params.object_store_id, |
| - params.index_id, base::MakeUnique<IndexedDBKeyRange>(params.key_range), |
| - params.key_only, callbacks); |
| + transaction, params.object_store_id, params.index_id, |
| + base::MakeUnique<IndexedDBKeyRange>(params.key_range), params.key_only, |
| + callbacks); |
| } |
| void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnGetAll( |
| @@ -706,13 +662,17 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnGetAll( |
| parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); |
| if (!connection || !connection->IsConnected()) |
| return; |
| + IndexedDBTransaction* transaction = |
| + connection->GetTransaction(params.transaction_id); |
| + if (!transaction) |
| + return; |
| scoped_refptr<IndexedDBCallbacks> callbacks(new IndexedDBCallbacks( |
| parent_, params.ipc_thread_id, params.ipc_callbacks_id)); |
| connection->database()->GetAll( |
| - parent_->HostTransactionId(params.transaction_id), params.object_store_id, |
| - params.index_id, base::MakeUnique<IndexedDBKeyRange>(params.key_range), |
| - params.key_only, params.max_count, callbacks); |
| + transaction, params.object_store_id, params.index_id, |
| + base::MakeUnique<IndexedDBKeyRange>(params.key_range), params.key_only, |
| + params.max_count, callbacks); |
| } |
| void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnPutWrapper( |
| @@ -740,12 +700,13 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnPut( |
| parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); |
| if (!connection || !connection->IsConnected()) |
| return; |
| + IndexedDBTransaction* transaction = |
| + connection->GetTransaction(params.transaction_id); |
| + if (!transaction) |
| + return; |
| scoped_refptr<IndexedDBCallbacks> callbacks(new IndexedDBCallbacks( |
| parent_, params.ipc_thread_id, params.ipc_callbacks_id)); |
| - int64_t host_transaction_id = |
| - parent_->HostTransactionId(params.transaction_id); |
| - |
| std::vector<IndexedDBBlobInfo> blob_info( |
| params.value.blob_or_file_info.size()); |
| @@ -781,13 +742,13 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnPut( |
| IndexedDBValue value; |
| value.bits = params.value.bits; |
| value.blob_info.swap(blob_info); |
| - connection->database()->Put(host_transaction_id, params.object_store_id, |
| - &value, &scoped_handles, |
| + connection->database()->Put(transaction, params.object_store_id, &value, |
| + &scoped_handles, |
| base::MakeUnique<IndexedDBKey>(params.key), |
| params.put_mode, callbacks, params.index_keys); |
| // Size can't be big enough to overflow because it represents the |
| // actual bytes passed through IPC. |
| - transaction_size_map_[host_transaction_id] += params.value.bits.size(); |
| + transaction->set_size(transaction->size() + params.value.bits.size()); |
| } |
| void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnSetIndexKeys( |
| @@ -797,11 +758,13 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnSetIndexKeys( |
| parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); |
| if (!connection || !connection->IsConnected()) |
| return; |
| + IndexedDBTransaction* transaction = |
| + connection->GetTransaction(params.transaction_id); |
| + if (!transaction) |
| + return; |
| - int64_t host_transaction_id = |
| - parent_->HostTransactionId(params.transaction_id); |
| connection->database()->SetIndexKeys( |
| - host_transaction_id, params.object_store_id, |
| + transaction, params.object_store_id, |
| base::MakeUnique<IndexedDBKey>(params.primary_key), params.index_keys); |
| } |
| @@ -815,9 +778,13 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnSetIndexesReady( |
| parent_->GetOrTerminateProcess(&map_, ipc_database_id); |
| if (!connection || !connection->IsConnected()) |
| return; |
| + IndexedDBTransaction* transaction = |
| + connection->GetTransaction(transaction_id); |
| + if (!transaction) |
| + return; |
| - connection->database()->SetIndexesReady( |
| - parent_->HostTransactionId(transaction_id), object_store_id, index_ids); |
| + connection->database()->SetIndexesReady(transaction, object_store_id, |
| + index_ids); |
| } |
| void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnOpenCursor( |
| @@ -827,13 +794,17 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnOpenCursor( |
| parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); |
| if (!connection || !connection->IsConnected()) |
| return; |
| + IndexedDBTransaction* transaction = |
| + connection->GetTransaction(params.transaction_id); |
| + if (!transaction) |
| + return; |
| scoped_refptr<IndexedDBCallbacks> callbacks(new IndexedDBCallbacks( |
| parent_, params.ipc_thread_id, params.ipc_callbacks_id, -1)); |
| connection->database()->OpenCursor( |
| - parent_->HostTransactionId(params.transaction_id), params.object_store_id, |
| - params.index_id, base::MakeUnique<IndexedDBKeyRange>(params.key_range), |
| - params.direction, params.key_only, params.task_type, callbacks); |
| + transaction, params.object_store_id, params.index_id, |
| + base::MakeUnique<IndexedDBKeyRange>(params.key_range), params.direction, |
| + params.key_only, params.task_type, callbacks); |
| } |
| void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCount( |
| @@ -843,13 +814,16 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCount( |
| parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); |
| if (!connection || !connection->IsConnected()) |
| return; |
| + IndexedDBTransaction* transaction = |
| + connection->GetTransaction(params.transaction_id); |
| + if (!transaction) |
| + return; |
| scoped_refptr<IndexedDBCallbacks> callbacks(new IndexedDBCallbacks( |
| parent_, params.ipc_thread_id, params.ipc_callbacks_id)); |
| connection->database()->Count( |
| - parent_->HostTransactionId(params.transaction_id), params.object_store_id, |
| - params.index_id, base::MakeUnique<IndexedDBKeyRange>(params.key_range), |
| - callbacks); |
| + transaction, params.object_store_id, params.index_id, |
| + base::MakeUnique<IndexedDBKeyRange>(params.key_range), callbacks); |
| } |
| void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteRange( |
| @@ -859,11 +833,15 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteRange( |
| parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); |
| if (!connection || !connection->IsConnected()) |
| return; |
| + IndexedDBTransaction* transaction = |
| + connection->GetTransaction(params.transaction_id); |
| + if (!transaction) |
| + return; |
| scoped_refptr<IndexedDBCallbacks> callbacks(new IndexedDBCallbacks( |
| parent_, params.ipc_thread_id, params.ipc_callbacks_id)); |
| connection->database()->DeleteRange( |
| - parent_->HostTransactionId(params.transaction_id), params.object_store_id, |
| + transaction, params.object_store_id, |
| base::MakeUnique<IndexedDBKeyRange>(params.key_range), callbacks); |
| } |
| @@ -878,12 +856,15 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnClear( |
| parent_->GetOrTerminateProcess(&map_, ipc_database_id); |
| if (!connection || !connection->IsConnected()) |
| return; |
| + IndexedDBTransaction* transaction = |
| + connection->GetTransaction(transaction_id); |
| + if (!transaction) |
| + return; |
| scoped_refptr<IndexedDBCallbacks> callbacks( |
| new IndexedDBCallbacks(parent_, ipc_thread_id, ipc_callbacks_id)); |
| - connection->database()->Clear( |
| - parent_->HostTransactionId(transaction_id), object_store_id, callbacks); |
| + connection->database()->Clear(transaction, object_store_id, callbacks); |
| } |
| void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnAbort( |
| @@ -894,8 +875,12 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnAbort( |
| parent_->GetOrTerminateProcess(&map_, ipc_database_id); |
| if (!connection || !connection->IsConnected()) |
| return; |
| + IndexedDBTransaction* transaction = |
| + connection->GetTransaction(transaction_id); |
| + if (!transaction) |
| + return; |
| - connection->database()->Abort(parent_->HostTransactionId(transaction_id)); |
| + connection->database()->Abort(transaction); |
| } |
| void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCommit( |
| @@ -906,22 +891,21 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCommit( |
| parent_->GetOrTerminateProcess(&map_, ipc_database_id); |
| if (!connection || !connection->IsConnected()) |
| return; |
| - |
| - int64_t host_transaction_id = parent_->HostTransactionId(transaction_id); |
| - // May have been aborted by back end before front-end could request commit. |
| - if (!base::ContainsKey(transaction_size_map_, host_transaction_id)) |
| + IndexedDBTransaction* transaction = |
| + connection->GetTransaction(transaction_id); |
| + if (!transaction) |
| return; |
| - int64_t transaction_size = transaction_size_map_[host_transaction_id]; |
| + |
| + int64_t transaction_size = transaction->size(); |
| // Always allow empty or delete-only transactions. |
| if (!transaction_size) { |
| - connection->database()->Commit(host_transaction_id); |
| + connection->database()->Commit(transaction); |
| return; |
| } |
| parent_->context()->quota_manager_proxy()->GetUsageAndQuota( |
| - parent_->context()->TaskRunner(), |
| - GURL(transaction_origin_map_[host_transaction_id].Serialize()), |
| + parent_->context()->TaskRunner(), GURL(transaction->origin().Serialize()), |
| storage::kStorageTypeTemporary, |
| base::Bind(&IndexedDBDispatcherHost::DatabaseDispatcherHost:: |
| OnGotUsageAndQuotaForCommit, |
| @@ -939,18 +923,19 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost:: |
| // May have disconnected while quota check was pending. |
| if (!connection || !connection->IsConnected()) |
| return; |
| - int64_t host_transaction_id = parent_->HostTransactionId(transaction_id); |
| - // May have aborted while quota check was pending. |
| - if (!base::ContainsKey(transaction_size_map_, host_transaction_id)) |
| + IndexedDBTransaction* transaction = |
| + connection->GetTransaction(transaction_id); |
| + if (!transaction) |
| return; |
| - int64_t transaction_size = transaction_size_map_[host_transaction_id]; |
| + |
| + int64_t transaction_size = transaction->size(); |
| if (status == storage::kQuotaStatusOk && |
| usage + transaction_size <= quota) { |
| - connection->database()->Commit(host_transaction_id); |
| + connection->database()->Commit(transaction); |
| } else { |
| connection->database()->Abort( |
| - host_transaction_id, |
| + transaction, |
| IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionQuotaError)); |
| } |
| } |
| @@ -962,16 +947,14 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateIndex( |
| parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); |
| if (!connection || !connection->IsConnected()) |
| return; |
| + IndexedDBTransaction* transaction = |
| + connection->GetTransaction(params.transaction_id); |
| + if (!transaction) |
| + return; |
| - int64_t host_transaction_id = |
| - parent_->HostTransactionId(params.transaction_id); |
| - connection->database()->CreateIndex(host_transaction_id, |
| - params.object_store_id, |
| - params.index_id, |
| - params.name, |
| - params.key_path, |
| - params.unique, |
| - params.multi_entry); |
| + connection->database()->CreateIndex( |
| + transaction, params.object_store_id, params.index_id, params.name, |
| + params.key_path, params.unique, params.multi_entry); |
| } |
| void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteIndex( |
| @@ -984,9 +967,12 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteIndex( |
| parent_->GetOrTerminateProcess(&map_, ipc_database_id); |
| if (!connection || !connection->IsConnected()) |
| return; |
| + IndexedDBTransaction* transaction = |
| + connection->GetTransaction(transaction_id); |
| + if (!transaction) |
| + return; |
| - connection->database()->DeleteIndex( |
| - parent_->HostTransactionId(transaction_id), object_store_id, index_id); |
| + connection->database()->DeleteIndex(transaction, object_store_id, index_id); |
| } |
| void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnRenameIndex( |
| @@ -1000,10 +986,13 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnRenameIndex( |
| parent_->GetOrTerminateProcess(&map_, ipc_database_id); |
| if (!connection || !connection->IsConnected()) |
| return; |
| + IndexedDBTransaction* transaction = |
| + connection->GetTransaction(transaction_id); |
| + if (!transaction) |
| + return; |
| - connection->database()->RenameIndex( |
| - parent_->HostTransactionId(transaction_id), object_store_id, index_id, |
| - new_name); |
| + connection->database()->RenameIndex(transaction, object_store_id, index_id, |
| + new_name); |
| } |
| ////////////////////////////////////////////////////////////////////// |
| @@ -1110,9 +1099,12 @@ void IndexedDBDispatcherHost::CursorDispatcherHost::OnPrefetchReset( |
| } |
| void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( |
| - int32_t ipc_object_id) { |
| + int32_t ipc_cursor_id) { |
| DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread()); |
| - parent_->DestroyObject(&map_, ipc_object_id); |
| + IndexedDBCursor* idb_cursor = |
| + parent_->GetOrTerminateProcess(&map_, ipc_cursor_id); |
| + idb_cursor->RemoveCursorFromTransaction(); |
| + parent_->DestroyObject(&map_, ipc_cursor_id); |
| } |
| } // namespace content |