| Index: content/child/indexed_db/indexed_db_dispatcher.cc
|
| diff --git a/content/child/indexed_db/indexed_db_dispatcher.cc b/content/child/indexed_db/indexed_db_dispatcher.cc
|
| index 8715a8d477688a372a93e72a43d91dfaa1da7b11..8729fd396d0447fd3d4e6234d8a786a75a4c8d4e 100644
|
| --- a/content/child/indexed_db/indexed_db_dispatcher.cc
|
| +++ b/content/child/indexed_db/indexed_db_dispatcher.cc
|
| @@ -10,13 +10,15 @@
|
| #include "base/lazy_instance.h"
|
| #include "base/strings/stringprintf.h"
|
| #include "base/threading/thread_local.h"
|
| +#include "content/child/child_thread_impl.h"
|
| #include "content/child/indexed_db/indexed_db_key_builders.h"
|
| #include "content/child/indexed_db/webidbcursor_impl.h"
|
| #include "content/child/indexed_db/webidbdatabase_impl.h"
|
| #include "content/child/thread_safe_sender.h"
|
| #include "content/common/indexed_db/indexed_db_messages.h"
|
| #include "ipc/ipc_channel.h"
|
| -#include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseCallbacks.h"
|
| +#include "ipc/ipc_sync_channel.h"
|
| +#include "services/shell/public/cpp/interface_provider.h"
|
| #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseError.h"
|
| #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseException.h"
|
| #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBObservation.h"
|
| @@ -27,7 +29,6 @@ using blink::WebData;
|
| using blink::WebIDBCallbacks;
|
| using blink::WebIDBCursor;
|
| using blink::WebIDBDatabase;
|
| -using blink::WebIDBDatabaseCallbacks;
|
| using blink::WebIDBDatabaseError;
|
| using blink::WebIDBKey;
|
| using blink::WebIDBMetadata;
|
| @@ -51,6 +52,9 @@ IndexedDBDispatcher* const kHasBeenDeleted =
|
|
|
| IndexedDBDispatcher::IndexedDBDispatcher(ThreadSafeSender* thread_safe_sender)
|
| : thread_safe_sender_(thread_safe_sender) {
|
| + ChildThreadImpl* child_thread = ChildThreadImpl::current();
|
| + if (child_thread)
|
| + child_thread->channel()->GetRemoteAssociatedInterface(&database_factory_);
|
| g_idb_dispatcher_tls.Pointer()->Set(this);
|
| }
|
|
|
| @@ -58,10 +62,8 @@ IndexedDBDispatcher::~IndexedDBDispatcher() {
|
| // Clear any pending callbacks - which may result in dispatch requests -
|
| // before marking the dispatcher as deleted.
|
| pending_callbacks_.Clear();
|
| - pending_database_callbacks_.Clear();
|
|
|
| DCHECK(pending_callbacks_.IsEmpty());
|
| - DCHECK(pending_database_callbacks_.IsEmpty());
|
|
|
| g_idb_dispatcher_tls.Pointer()->Set(kHasBeenDeleted);
|
| }
|
| @@ -167,12 +169,6 @@ void IndexedDBDispatcher::OnMessageReceived(const IPC::Message& msg) {
|
| IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksError, OnError)
|
| IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksIntBlocked, OnIntBlocked)
|
| IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksUpgradeNeeded, OnUpgradeNeeded)
|
| - IPC_MESSAGE_HANDLER(IndexedDBMsg_DatabaseCallbacksForcedClose,
|
| - OnForcedClose)
|
| - IPC_MESSAGE_HANDLER(IndexedDBMsg_DatabaseCallbacksVersionChange,
|
| - OnVersionChange)
|
| - IPC_MESSAGE_HANDLER(IndexedDBMsg_DatabaseCallbacksAbort, OnAbort)
|
| - IPC_MESSAGE_HANDLER(IndexedDBMsg_DatabaseCallbacksComplete, OnComplete)
|
| IPC_MESSAGE_HANDLER(IndexedDBMsg_DatabaseCallbacksChanges,
|
| OnDatabaseChanges)
|
| IPC_MESSAGE_UNHANDLED(handled = false)
|
| @@ -273,26 +269,21 @@ void IndexedDBDispatcher::RequestIDBCursorPrefetchReset(int used_prefetches,
|
| }
|
|
|
| void IndexedDBDispatcher::RequestIDBFactoryOpen(
|
| - const base::string16& name,
|
| + const std::string& name,
|
| int64_t version,
|
| int64_t transaction_id,
|
| - WebIDBCallbacks* callbacks_ptr,
|
| - WebIDBDatabaseCallbacks* database_callbacks_ptr,
|
| + WebIDBCallbacks* callbacks,
|
| + mojo::ScopedInterfaceEndpointHandle* client_interface_endpoint,
|
| const url::Origin& origin) {
|
| - std::unique_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
|
| - std::unique_ptr<WebIDBDatabaseCallbacks> database_callbacks(
|
| - database_callbacks_ptr);
|
| + indexed_db::mojom::DatabaseClientAssociatedPtrInfo clientInfo;
|
| + indexed_db::mojom::DatabaseClientAssociatedRequest clientRequest;
|
| + database_factory_.associated_group()->CreateAssociatedInterface(
|
| + mojo::AssociatedGroup::WILL_PASS_PTR, &clientInfo, &clientRequest);
|
| + *client_interface_endpoint = clientRequest.PassHandle();
|
|
|
| - IndexedDBHostMsg_FactoryOpen_Params params;
|
| - params.ipc_thread_id = CurrentWorkerId();
|
| - params.ipc_callbacks_id = pending_callbacks_.Add(callbacks.release());
|
| - params.ipc_database_callbacks_id =
|
| - pending_database_callbacks_.Add(database_callbacks.release());
|
| - params.origin = origin;
|
| - params.name = name;
|
| - params.transaction_id = transaction_id;
|
| - params.version = version;
|
| - Send(new IndexedDBHostMsg_FactoryOpen(params));
|
| + database_factory_->Open(name, version, transaction_id, origin,
|
| + std::move(clientInfo), CurrentWorkerId(),
|
| + pending_callbacks_.Add(callbacks));
|
| }
|
|
|
| void IndexedDBDispatcher::RequestIDBFactoryGetDatabaseNames(
|
| @@ -321,14 +312,8 @@ void IndexedDBDispatcher::RequestIDBFactoryDeleteDatabase(
|
| Send(new IndexedDBHostMsg_FactoryDeleteDatabase(params));
|
| }
|
|
|
| -void IndexedDBDispatcher::RequestIDBDatabaseClose(
|
| - int32_t ipc_database_id,
|
| - int32_t ipc_database_callbacks_id) {
|
| +void IndexedDBDispatcher::RequestIDBDatabaseClose(int32_t ipc_database_id) {
|
| Send(new IndexedDBHostMsg_DatabaseClose(ipc_database_id));
|
| - // There won't be pending database callbacks if the transaction was aborted in
|
| - // the initial upgradeneeded event handler.
|
| - if (pending_database_callbacks_.Lookup(ipc_database_callbacks_id))
|
| - pending_database_callbacks_.Remove(ipc_database_callbacks_id);
|
| }
|
|
|
| void IndexedDBDispatcher::NotifyIDBDatabaseVersionChangeIgnored(
|
| @@ -339,17 +324,12 @@ void IndexedDBDispatcher::NotifyIDBDatabaseVersionChangeIgnored(
|
| void IndexedDBDispatcher::RequestIDBDatabaseCreateTransaction(
|
| int32_t ipc_database_id,
|
| int64_t transaction_id,
|
| - WebIDBDatabaseCallbacks* database_callbacks_ptr,
|
| WebVector<long long> object_store_ids,
|
| blink::WebIDBTransactionMode mode) {
|
| - std::unique_ptr<WebIDBDatabaseCallbacks> database_callbacks(
|
| - database_callbacks_ptr);
|
| IndexedDBHostMsg_DatabaseCreateTransaction_Params params;
|
| params.ipc_thread_id = CurrentWorkerId();
|
| params.ipc_database_id = ipc_database_id;
|
| params.transaction_id = transaction_id;
|
| - params.ipc_database_callbacks_id =
|
| - pending_database_callbacks_.Add(database_callbacks.release());
|
| params.object_store_ids
|
| .assign(object_store_ids.data(),
|
| object_store_ids.data() + object_store_ids.size());
|
| @@ -553,7 +533,6 @@ void IndexedDBDispatcher::DatabaseDestroyed(int32_t ipc_database_id) {
|
| void IndexedDBDispatcher::OnSuccessIDBDatabase(
|
| int32_t ipc_thread_id,
|
| int32_t ipc_callbacks_id,
|
| - int32_t ipc_database_callbacks_id,
|
| int32_t ipc_object_id,
|
| const IndexedDBDatabaseMetadata& idb_metadata) {
|
| DCHECK_EQ(ipc_thread_id, CurrentWorkerId());
|
| @@ -568,8 +547,8 @@ void IndexedDBDispatcher::OnSuccessIDBDatabase(
|
| // May already be deleted and removed from the table, but do not recreate..
|
| if (ipc_object_id != kNoDatabase) {
|
| DCHECK(!databases_.count(ipc_object_id));
|
| - database = databases_[ipc_object_id] = new WebIDBDatabaseImpl(
|
| - ipc_object_id, ipc_database_callbacks_id, thread_safe_sender_.get());
|
| + database = databases_[ipc_object_id] =
|
| + new WebIDBDatabaseImpl(ipc_object_id, thread_safe_sender_.get());
|
| }
|
|
|
| callbacks->onSuccess(database, metadata);
|
| @@ -773,7 +752,6 @@ void IndexedDBDispatcher::OnUpgradeNeeded(
|
| DCHECK(!databases_.count(p.ipc_database_id));
|
| databases_[p.ipc_database_id] =
|
| new WebIDBDatabaseImpl(p.ipc_database_id,
|
| - p.ipc_database_callbacks_id,
|
| thread_safe_sender_.get());
|
| callbacks->onUpgradeNeeded(
|
| p.old_version,
|
| @@ -799,33 +777,6 @@ void IndexedDBDispatcher::OnError(int32_t ipc_thread_id,
|
| cursor_transaction_ids_.erase(ipc_callbacks_id);
|
| }
|
|
|
| -void IndexedDBDispatcher::OnAbort(int32_t ipc_thread_id,
|
| - int32_t ipc_database_callbacks_id,
|
| - int64_t transaction_id,
|
| - int code,
|
| - const base::string16& message) {
|
| - DCHECK_EQ(ipc_thread_id, CurrentWorkerId());
|
| - WebIDBDatabaseCallbacks* callbacks =
|
| - pending_database_callbacks_.Lookup(ipc_database_callbacks_id);
|
| - if (!callbacks)
|
| - return;
|
| - if (message.empty())
|
| - callbacks->onAbort(transaction_id, WebIDBDatabaseError(code));
|
| - else
|
| - callbacks->onAbort(transaction_id, WebIDBDatabaseError(code, message));
|
| -}
|
| -
|
| -void IndexedDBDispatcher::OnComplete(int32_t ipc_thread_id,
|
| - int32_t ipc_database_callbacks_id,
|
| - int64_t transaction_id) {
|
| - DCHECK_EQ(ipc_thread_id, CurrentWorkerId());
|
| - WebIDBDatabaseCallbacks* callbacks =
|
| - pending_database_callbacks_.Lookup(ipc_database_callbacks_id);
|
| - if (!callbacks)
|
| - return;
|
| - callbacks->onComplete(transaction_id);
|
| -}
|
| -
|
| void IndexedDBDispatcher::OnDatabaseChanges(
|
| int32_t ipc_thread_id,
|
| int32_t ipc_database_id,
|
| @@ -844,30 +795,6 @@ void IndexedDBDispatcher::OnDatabaseChanges(
|
| }
|
| }
|
|
|
| -void IndexedDBDispatcher::OnForcedClose(int32_t ipc_thread_id,
|
| - int32_t ipc_database_callbacks_id) {
|
| - DCHECK_EQ(ipc_thread_id, CurrentWorkerId());
|
| - WebIDBDatabaseCallbacks* callbacks =
|
| - pending_database_callbacks_.Lookup(ipc_database_callbacks_id);
|
| - if (!callbacks)
|
| - return;
|
| - callbacks->onForcedClose();
|
| -}
|
| -
|
| -void IndexedDBDispatcher::OnVersionChange(int32_t ipc_thread_id,
|
| - int32_t ipc_database_callbacks_id,
|
| - int64_t old_version,
|
| - int64_t new_version) {
|
| - DCHECK_EQ(ipc_thread_id, CurrentWorkerId());
|
| - WebIDBDatabaseCallbacks* callbacks =
|
| - pending_database_callbacks_.Lookup(ipc_database_callbacks_id);
|
| - // callbacks would be NULL if a versionchange event is received after close
|
| - // has been called.
|
| - if (!callbacks)
|
| - return;
|
| - callbacks->onVersionChange(old_version, new_version);
|
| -}
|
| -
|
| void IndexedDBDispatcher::ResetCursorPrefetchCaches(
|
| int64_t transaction_id,
|
| int32_t ipc_exception_cursor_id) {
|
|
|