mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 879475 - Part 004. Fix IndexedDBObjectStore to not assume that PContent connects the same processes as PBrowser r=bent
Based on original patch by David Zbarsky <dzbarsky@gmail.com>
This commit is contained in:
parent
775d5e424b
commit
d08f2e8d45
@ -157,7 +157,7 @@ IDBFactory::Create(nsPIDOMWindow* aWindow,
|
||||
TabChild* tabChild = TabChild::GetFrom(aWindow);
|
||||
IDB_ENSURE_TRUE(tabChild, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
|
||||
IndexedDBChild* actor = new IndexedDBChild(origin);
|
||||
IndexedDBChild* actor = new IndexedDBChild(tabChild, origin);
|
||||
|
||||
bool allowed;
|
||||
tabChild->SendPIndexedDBConstructor(actor, group, origin, &allowed);
|
||||
@ -216,7 +216,7 @@ IDBFactory::Create(JSContext* aCx,
|
||||
ContentChild* contentChild = ContentChild::GetSingleton();
|
||||
IDB_ENSURE_TRUE(contentChild, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
|
||||
IndexedDBChild* actor = new IndexedDBChild(origin);
|
||||
IndexedDBChild* actor = new IndexedDBChild(contentChild, origin);
|
||||
|
||||
contentChild->SendPIndexedDBConstructor(actor);
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "mozilla/dom/nsIContentParent.h"
|
||||
#include "mozilla/dom/FileHandleBinding.h"
|
||||
#include "mozilla/dom/StructuredCloneTags.h"
|
||||
#include "mozilla/dom/TabChild.h"
|
||||
#include "mozilla/dom/ipc/Blob.h"
|
||||
#include "mozilla/dom/quota/FileStreams.h"
|
||||
#include "mozilla/Endian.h"
|
||||
@ -111,7 +112,8 @@ public:
|
||||
virtual nsresult Dispatch(nsIEventTarget* aDatabaseThread) MOZ_OVERRIDE;
|
||||
|
||||
virtual nsresult
|
||||
PackArgumentsForParentProcess(ObjectStoreRequestParams& aParams) = 0;
|
||||
PackArgumentsForParentProcess(ObjectStoreRequestParams& aParams,
|
||||
nsIContentChild* aBlobCreator) = 0;
|
||||
|
||||
virtual nsresult
|
||||
UnpackResponseFromParentProcess(const ResponseValue& aResponseValue) = 0;
|
||||
@ -184,7 +186,8 @@ public:
|
||||
virtual void ReleaseMainThreadObjects() MOZ_OVERRIDE;
|
||||
|
||||
virtual nsresult
|
||||
PackArgumentsForParentProcess(ObjectStoreRequestParams& aParams) MOZ_OVERRIDE;
|
||||
PackArgumentsForParentProcess(ObjectStoreRequestParams& aParams,
|
||||
nsIContentChild* aBlobCreator) MOZ_OVERRIDE;
|
||||
|
||||
virtual ChildProcessSendResult
|
||||
SendResponseToChildProcess(nsresult aResultCode) MOZ_OVERRIDE;
|
||||
@ -228,7 +231,8 @@ public:
|
||||
virtual void ReleaseMainThreadObjects() MOZ_OVERRIDE;
|
||||
|
||||
virtual nsresult
|
||||
PackArgumentsForParentProcess(ObjectStoreRequestParams& aParams) MOZ_OVERRIDE;
|
||||
PackArgumentsForParentProcess(ObjectStoreRequestParams& aParams,
|
||||
nsIContentChild* aBlobCreator) MOZ_OVERRIDE;
|
||||
|
||||
virtual ChildProcessSendResult
|
||||
SendResponseToChildProcess(nsresult aResultCode) MOZ_OVERRIDE;
|
||||
@ -263,7 +267,8 @@ public:
|
||||
JS::MutableHandle<JS::Value> aVal) MOZ_OVERRIDE;
|
||||
|
||||
virtual nsresult
|
||||
PackArgumentsForParentProcess(ObjectStoreRequestParams& aParams) MOZ_OVERRIDE;
|
||||
PackArgumentsForParentProcess(ObjectStoreRequestParams& aParams,
|
||||
nsIContentChild* aBlobCreator) MOZ_OVERRIDE;
|
||||
|
||||
virtual ChildProcessSendResult
|
||||
SendResponseToChildProcess(nsresult aResultCode) MOZ_OVERRIDE;
|
||||
@ -286,7 +291,8 @@ public:
|
||||
MOZ_OVERRIDE;
|
||||
|
||||
virtual nsresult
|
||||
PackArgumentsForParentProcess(ObjectStoreRequestParams& aParams) MOZ_OVERRIDE;
|
||||
PackArgumentsForParentProcess(ObjectStoreRequestParams& aParams,
|
||||
nsIContentChild* aBlobCreator) MOZ_OVERRIDE;
|
||||
|
||||
virtual ChildProcessSendResult
|
||||
SendResponseToChildProcess(nsresult aResultCode) MOZ_OVERRIDE;
|
||||
@ -322,7 +328,8 @@ public:
|
||||
virtual void ReleaseMainThreadObjects() MOZ_OVERRIDE;
|
||||
|
||||
virtual nsresult
|
||||
PackArgumentsForParentProcess(ObjectStoreRequestParams& aParams) MOZ_OVERRIDE;
|
||||
PackArgumentsForParentProcess(ObjectStoreRequestParams& aParams,
|
||||
nsIContentChild* aBlobCreator) MOZ_OVERRIDE;
|
||||
|
||||
virtual ChildProcessSendResult
|
||||
SendResponseToChildProcess(nsresult aResultCode) MOZ_OVERRIDE;
|
||||
@ -373,7 +380,8 @@ public:
|
||||
ReleaseMainThreadObjects() MOZ_OVERRIDE;
|
||||
|
||||
virtual nsresult
|
||||
PackArgumentsForParentProcess(ObjectStoreRequestParams& aParams) MOZ_OVERRIDE;
|
||||
PackArgumentsForParentProcess(ObjectStoreRequestParams& aParams,
|
||||
nsIContentChild* aBlobCreator) MOZ_OVERRIDE;
|
||||
|
||||
virtual ChildProcessSendResult
|
||||
SendResponseToChildProcess(nsresult aResultCode) MOZ_OVERRIDE;
|
||||
@ -480,7 +488,8 @@ public:
|
||||
virtual void ReleaseMainThreadObjects() MOZ_OVERRIDE;
|
||||
|
||||
virtual nsresult
|
||||
PackArgumentsForParentProcess(ObjectStoreRequestParams& aParams) MOZ_OVERRIDE;
|
||||
PackArgumentsForParentProcess(ObjectStoreRequestParams& aParams,
|
||||
nsIContentChild* aBlobCreator) MOZ_OVERRIDE;
|
||||
|
||||
virtual ChildProcessSendResult
|
||||
SendResponseToChildProcess(nsresult aResultCode) MOZ_OVERRIDE;
|
||||
@ -522,7 +531,8 @@ public:
|
||||
ReleaseMainThreadObjects() MOZ_OVERRIDE;
|
||||
|
||||
virtual nsresult
|
||||
PackArgumentsForParentProcess(ObjectStoreRequestParams& aParams) MOZ_OVERRIDE;
|
||||
PackArgumentsForParentProcess(ObjectStoreRequestParams& aParams,
|
||||
nsIContentChild* aBlobCreator) MOZ_OVERRIDE;
|
||||
|
||||
virtual ChildProcessSendResult
|
||||
SendResponseToChildProcess(nsresult aResultCode) MOZ_OVERRIDE;
|
||||
@ -560,7 +570,8 @@ public:
|
||||
virtual void ReleaseMainThreadObjects() MOZ_OVERRIDE;
|
||||
|
||||
virtual nsresult
|
||||
PackArgumentsForParentProcess(ObjectStoreRequestParams& aParams) MOZ_OVERRIDE;
|
||||
PackArgumentsForParentProcess(ObjectStoreRequestParams& aParams,
|
||||
nsIContentChild* aBlobCreator) MOZ_OVERRIDE;
|
||||
|
||||
virtual ChildProcessSendResult
|
||||
SendResponseToChildProcess(nsresult aResultCode) MOZ_OVERRIDE;
|
||||
@ -3040,7 +3051,22 @@ ObjectStoreHelper::Dispatch(nsIEventTarget* aDatabaseThread)
|
||||
NS_ASSERTION(objectStoreActor, "Must have an actor here!");
|
||||
|
||||
ObjectStoreRequestParams params;
|
||||
nsresult rv = PackArgumentsForParentProcess(params);
|
||||
|
||||
// Our "parent" process may be either the root process or another content
|
||||
// process if this indexedDB is managed by a PBrowser that is managed by a
|
||||
// PContentBridge. We need to find which one it is so that we can create
|
||||
// PBlobs that are managed by the right nsIContentChild.
|
||||
IndexedDBChild* rootActor =
|
||||
static_cast<IndexedDBChild*>(objectStoreActor->Manager()->
|
||||
Manager()->Manager());
|
||||
nsIContentChild* blobCreator;
|
||||
if (rootActor->GetManagerContent()) {
|
||||
blobCreator = rootActor->GetManagerContent();
|
||||
} else {
|
||||
blobCreator = rootActor->GetManagerTab()->Manager();
|
||||
}
|
||||
|
||||
nsresult rv = PackArgumentsForParentProcess(params, blobCreator);
|
||||
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
|
||||
NoDispatchEventTarget target;
|
||||
@ -3320,10 +3346,12 @@ AddHelper::ReleaseMainThreadObjects()
|
||||
}
|
||||
|
||||
nsresult
|
||||
AddHelper::PackArgumentsForParentProcess(ObjectStoreRequestParams& aParams)
|
||||
AddHelper::PackArgumentsForParentProcess(ObjectStoreRequestParams& aParams,
|
||||
nsIContentChild* aBlobCreator)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
NS_ASSERTION(!IndexedDatabaseManager::IsMainProcess(), "Wrong process!");
|
||||
NS_ASSERTION(aBlobCreator, "Must have a valid creator!");
|
||||
|
||||
PROFILER_MAIN_THREAD_LABEL("AddHelper", "PackArgumentsForParentProcess",
|
||||
js::ProfileEntry::Category::STORAGE);
|
||||
@ -3341,8 +3369,7 @@ AddHelper::PackArgumentsForParentProcess(ObjectStoreRequestParams& aParams)
|
||||
InfallibleTArray<PBlobChild*>& blobsChild = commonParams.blobsChild();
|
||||
blobsChild.SetCapacity(fileCount);
|
||||
|
||||
ContentChild* contentChild = ContentChild::GetSingleton();
|
||||
NS_ASSERTION(contentChild, "This should never be null!");
|
||||
NS_ASSERTION(aBlobCreator, "This should never be null!");
|
||||
|
||||
for (uint32_t index = 0; index < fileCount; index++) {
|
||||
const StructuredCloneFile& file = files[index];
|
||||
@ -3351,7 +3378,7 @@ AddHelper::PackArgumentsForParentProcess(ObjectStoreRequestParams& aParams)
|
||||
NS_ASSERTION(!file.mFileInfo, "This is not yet supported!");
|
||||
|
||||
BlobChild* actor =
|
||||
contentChild->GetOrCreateActorForBlob(file.mFile);
|
||||
aBlobCreator->GetOrCreateActorForBlob(file.mFile);
|
||||
if (!actor) {
|
||||
IDB_REPORT_INTERNAL_ERR();
|
||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||
@ -3487,11 +3514,13 @@ GetHelper::ReleaseMainThreadObjects()
|
||||
}
|
||||
|
||||
nsresult
|
||||
GetHelper::PackArgumentsForParentProcess(ObjectStoreRequestParams& aParams)
|
||||
GetHelper::PackArgumentsForParentProcess(ObjectStoreRequestParams& aParams,
|
||||
nsIContentChild* aBlobCreator)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
NS_ASSERTION(!IndexedDatabaseManager::IsMainProcess(), "Wrong process!");
|
||||
NS_ASSERTION(mKeyRange, "This should never be null!");
|
||||
NS_ASSERTION(aBlobCreator, "Must have a valid creator!");
|
||||
|
||||
PROFILER_MAIN_THREAD_LABEL("GetHelper", "PackArgumentsForParentProcess [IDBObjectStore.cpp]",
|
||||
js::ProfileEntry::Category::STORAGE);
|
||||
@ -3625,11 +3654,13 @@ DeleteHelper::GetSuccessResult(JSContext* aCx,
|
||||
}
|
||||
|
||||
nsresult
|
||||
DeleteHelper::PackArgumentsForParentProcess(ObjectStoreRequestParams& aParams)
|
||||
DeleteHelper::PackArgumentsForParentProcess(ObjectStoreRequestParams& aParams,
|
||||
nsIContentChild* aBlobCreator)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
NS_ASSERTION(!IndexedDatabaseManager::IsMainProcess(), "Wrong process!");
|
||||
NS_ASSERTION(mKeyRange, "This should never be null!");
|
||||
NS_ASSERTION(aBlobCreator, "Must have a valid creator!");
|
||||
|
||||
PROFILER_MAIN_THREAD_LABEL("DeleteHelper", "PackArgumentsForParentProcess",
|
||||
js::ProfileEntry::Category::STORAGE);
|
||||
@ -3708,10 +3739,12 @@ ClearHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
|
||||
}
|
||||
|
||||
nsresult
|
||||
ClearHelper::PackArgumentsForParentProcess(ObjectStoreRequestParams& aParams)
|
||||
ClearHelper::PackArgumentsForParentProcess(ObjectStoreRequestParams& aParams,
|
||||
nsIContentChild* aBlobCreator)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
NS_ASSERTION(!IndexedDatabaseManager::IsMainProcess(), "Wrong process!");
|
||||
NS_ASSERTION(aBlobCreator, "Must have a valid creator!");
|
||||
|
||||
PROFILER_MAIN_THREAD_LABEL("ClearHelper", "PackArgumentsForParentProcess",
|
||||
js::ProfileEntry::Category::STORAGE);
|
||||
@ -3942,11 +3975,12 @@ OpenCursorHelper::ReleaseMainThreadObjects()
|
||||
}
|
||||
|
||||
nsresult
|
||||
OpenCursorHelper::PackArgumentsForParentProcess(
|
||||
ObjectStoreRequestParams& aParams)
|
||||
OpenCursorHelper::PackArgumentsForParentProcess(ObjectStoreRequestParams& aParams,
|
||||
nsIContentChild* aBlobCreator)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
NS_ASSERTION(!IndexedDatabaseManager::IsMainProcess(), "Wrong process!");
|
||||
NS_ASSERTION(aBlobCreator, "Must have a valid creator!");
|
||||
|
||||
PROFILER_MAIN_THREAD_LABEL("OpenCursorHelper", "PackArgumentsForParentProcess [IDBObjectStore.cpp]",
|
||||
js::ProfileEntry::Category::STORAGE);
|
||||
@ -4265,11 +4299,12 @@ OpenKeyCursorHelper::ReleaseMainThreadObjects()
|
||||
}
|
||||
|
||||
nsresult
|
||||
OpenKeyCursorHelper::PackArgumentsForParentProcess(
|
||||
ObjectStoreRequestParams& aParams)
|
||||
OpenKeyCursorHelper::PackArgumentsForParentProcess(ObjectStoreRequestParams& aParams,
|
||||
nsIContentChild* aBlobCreator)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(!IndexedDatabaseManager::IsMainProcess());
|
||||
NS_ASSERTION(aBlobCreator, "Must have a valid creator!");
|
||||
|
||||
PROFILER_MAIN_THREAD_LABEL("OpenKeyCursorHelper", "PackArgumentsForParentProcess [IDBObjectStore.cpp]",
|
||||
js::ProfileEntry::Category::STORAGE);
|
||||
@ -4705,10 +4740,12 @@ GetAllHelper::ReleaseMainThreadObjects()
|
||||
}
|
||||
|
||||
nsresult
|
||||
GetAllHelper::PackArgumentsForParentProcess(ObjectStoreRequestParams& aParams)
|
||||
GetAllHelper::PackArgumentsForParentProcess(ObjectStoreRequestParams& aParams,
|
||||
nsIContentChild* aBlobCreator)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
NS_ASSERTION(!IndexedDatabaseManager::IsMainProcess(), "Wrong process!");
|
||||
NS_ASSERTION(aBlobCreator, "Must have a valid creator!");
|
||||
|
||||
PROFILER_MAIN_THREAD_LABEL("GetAllHelper", "PackArgumentsForParentProcess [IDBObjectStore.cpp]",
|
||||
js::ProfileEntry::Category::STORAGE);
|
||||
@ -4951,11 +4988,12 @@ GetAllKeysHelper::ReleaseMainThreadObjects()
|
||||
}
|
||||
|
||||
nsresult
|
||||
GetAllKeysHelper::PackArgumentsForParentProcess(
|
||||
ObjectStoreRequestParams& aParams)
|
||||
GetAllKeysHelper::PackArgumentsForParentProcess(ObjectStoreRequestParams& aParams,
|
||||
nsIContentChild* aBlobCreator)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(!IndexedDatabaseManager::IsMainProcess());
|
||||
NS_ASSERTION(aBlobCreator, "Must have a valid creator!");
|
||||
|
||||
PROFILER_MAIN_THREAD_LABEL("GetAllKeysHelper", "PackArgumentsForParentProcess [IDBObjectStore.cpp]",
|
||||
js::ProfileEntry::Category::STORAGE);
|
||||
@ -5103,10 +5141,12 @@ CountHelper::ReleaseMainThreadObjects()
|
||||
}
|
||||
|
||||
nsresult
|
||||
CountHelper::PackArgumentsForParentProcess(ObjectStoreRequestParams& aParams)
|
||||
CountHelper::PackArgumentsForParentProcess(ObjectStoreRequestParams& aParams,
|
||||
nsIContentChild* aBlobCreator)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
NS_ASSERTION(!IndexedDatabaseManager::IsMainProcess(), "Wrong process!");
|
||||
NS_ASSERTION(aBlobCreator, "Must have a valid creator!");
|
||||
|
||||
PROFILER_MAIN_THREAD_LABEL("CountHelper", "PackArgumentsForParentProcess [IDBObjectStore.cpp]",
|
||||
js::ProfileEntry::Category::STORAGE);
|
||||
|
@ -159,12 +159,31 @@ public:
|
||||
* IndexedDBChild
|
||||
******************************************************************************/
|
||||
|
||||
IndexedDBChild::IndexedDBChild(const nsCString& aASCIIOrigin)
|
||||
: mFactory(nullptr), mASCIIOrigin(aASCIIOrigin)
|
||||
IndexedDBChild::IndexedDBChild(ContentChild* aContentChild,
|
||||
const nsCString& aASCIIOrigin)
|
||||
: mFactory(nullptr)
|
||||
, mManagerContent(aContentChild)
|
||||
, mManagerTab(nullptr)
|
||||
, mASCIIOrigin(aASCIIOrigin)
|
||||
#ifdef DEBUG
|
||||
, mDisconnected(false)
|
||||
, mDisconnected(false)
|
||||
#endif
|
||||
{
|
||||
MOZ_ASSERT(aContentChild);
|
||||
MOZ_COUNT_CTOR(IndexedDBChild);
|
||||
}
|
||||
|
||||
IndexedDBChild::IndexedDBChild(TabChild* aTabChild,
|
||||
const nsCString& aASCIIOrigin)
|
||||
: mFactory(nullptr)
|
||||
, mManagerContent(nullptr)
|
||||
, mManagerTab(aTabChild)
|
||||
, mASCIIOrigin(aASCIIOrigin)
|
||||
#ifdef DEBUG
|
||||
, mDisconnected(false)
|
||||
#endif
|
||||
{
|
||||
MOZ_ASSERT(aTabChild);
|
||||
MOZ_COUNT_CTOR(IndexedDBChild);
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,13 @@
|
||||
#include "mozilla/dom/indexedDB/PIndexedDBRequestChild.h"
|
||||
#include "mozilla/dom/indexedDB/PIndexedDBTransactionChild.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class ContentChild;
|
||||
class TabChild;
|
||||
} // dom
|
||||
} // mozilla
|
||||
|
||||
BEGIN_INDEXEDDB_NAMESPACE
|
||||
|
||||
class AsyncConnectionHelper;
|
||||
@ -36,6 +43,9 @@ class IDBTransactionListener;
|
||||
class IndexedDBChild : public PIndexedDBChild
|
||||
{
|
||||
IDBFactory* mFactory;
|
||||
ContentChild* mManagerContent;
|
||||
TabChild* mManagerTab;
|
||||
|
||||
nsCString mASCIIOrigin;
|
||||
|
||||
#ifdef DEBUG
|
||||
@ -43,7 +53,8 @@ class IndexedDBChild : public PIndexedDBChild
|
||||
#endif
|
||||
|
||||
public:
|
||||
IndexedDBChild(const nsCString& aASCIIOrigin);
|
||||
IndexedDBChild(ContentChild* aContentChild, const nsCString& aASCIIOrigin);
|
||||
IndexedDBChild(TabChild* aTabChild, const nsCString& aASCIIOrigin);
|
||||
virtual ~IndexedDBChild();
|
||||
|
||||
const nsCString&
|
||||
@ -52,6 +63,18 @@ public:
|
||||
return mASCIIOrigin;
|
||||
}
|
||||
|
||||
ContentChild*
|
||||
GetManagerContent() const
|
||||
{
|
||||
return mManagerContent;
|
||||
}
|
||||
|
||||
TabChild*
|
||||
GetManagerTab() const
|
||||
{
|
||||
return mManagerTab;
|
||||
}
|
||||
|
||||
void
|
||||
SetFactory(IDBFactory* aFactory);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user