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..6f122dfb85abdf4ab3d4f033ed5d48e3edeef4bd 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,67 +145,28 @@ 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, |
| - const url::Origin& origin) { |
| +int32_t IndexedDBDispatcherHost::Add( |
| + std::unique_ptr<IndexedDBConnection> connection, |
| + const url::Origin& origin) { |
| if (!database_dispatcher_host_) { |
| connection->Close(); |
| - delete connection; |
| return -1; |
| } |
| - int32_t ipc_database_id = database_dispatcher_host_->map_.Add(connection); |
| - context()->ConnectionOpened(origin, connection); |
| + IndexedDBConnection* connection_ptr = connection.get(); |
| + int32_t ipc_database_id = |
| + database_dispatcher_host_->map_.Add(std::move(connection)); |
| + context()->ConnectionOpened(origin, connection_ptr); |
| database_dispatcher_host_->database_origin_map_[ipc_database_id] = origin; |
| 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,16 +325,14 @@ 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, |
| - version); |
| + callbacks, database_callbacks, ipc_process_id_, origin, |
| + transaction_id, version); |
| DCHECK(request_context_getter_); |
| context()->GetIDBFactory()->Open(name, std::move(connection), |
| request_context_getter_, origin, |
| @@ -406,22 +366,14 @@ void IndexedDBDispatcherHost::OnAckReceivedBlobs( |
| DropBlobData(uuid); |
| } |
| -void IndexedDBDispatcherHost::FinishTransaction(int64_t host_transaction_id, |
| - bool committed) { |
| +void IndexedDBDispatcherHost::FinishTransaction( |
|
jsbell
2016/11/08 00:42:52
The only purpose of this method now is to poke the
dmurph
2016/11/09 00:27:32
Done.
|
| + const 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); |
| } |
| ////////////////////////////////////////////////////////////////////// |
| @@ -442,20 +394,6 @@ ObjectType* IndexedDBDispatcherHost::GetOrTerminateProcess( |
| return return_object; |
| } |
| -template <typename ObjectType> |
| -ObjectType* IndexedDBDispatcherHost::GetOrTerminateProcess( |
| - RefIDMap<ObjectType>* map, |
| - int32_t ipc_return_object_id) { |
| - DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
| - ObjectType* return_object = map->Lookup(ipc_return_object_id); |
| - if (!return_object) { |
| - NOTREACHED() << "Uh oh, couldn't find object with id " |
| - << ipc_return_object_id; |
| - bad_message::ReceivedBadMessage(this, bad_message::IDBDH_GET_OR_TERMINATE); |
| - } |
| - return return_object; |
| -} |
| - |
| template <typename MapType> |
| void IndexedDBDispatcherHost::DestroyObject(MapType* map, |
| int32_t ipc_object_id) { |
| @@ -484,20 +422,17 @@ 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()) { |
| + IndexedDBConnection* connection = iterator.GetCurrentValue(); |
| if (connection && connection->IsConnected()) { |
| - connection->database()->Abort( |
| - transaction_id, |
| + // TODO(dmurph): Perhaps mark these transactions as DOOMED instead, so we |
| + // can prevent side effects in the rest of the system. |
| + connection->AbortAllTransactions( |
| 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 +494,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 +513,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 +531,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 +548,13 @@ 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]); |
| + params.transaction_id, connection, params.object_store_ids, params.mode); |
| } |
| void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnClose( |
| @@ -663,12 +599,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 +629,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 +649,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 +687,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 +729,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 +745,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 +765,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 +781,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 +801,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 +820,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 +843,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 +862,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->AbortTransaction(transaction); |
| } |
| void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCommit( |
| @@ -906,22 +878,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(connection->origin().Serialize()), |
|
jsbell
2016/11/08 00:42:52
This can be replaced by connection->origin().GetUR
|
| storage::kStorageTypeTemporary, |
| base::Bind(&IndexedDBDispatcherHost::DatabaseDispatcherHost:: |
| OnGotUsageAndQuotaForCommit, |
| @@ -939,18 +910,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, |
| + connection->AbortTransaction( |
| + transaction, |
| IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionQuotaError)); |
| } |
| } |
| @@ -962,16 +934,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 +954,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 +973,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 +1086,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 |