зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1516240 - Part 2: Allow serializing BrowsingContext over IPC, r=farre
This patch takes the approach of taking a reference, so that we can land it into the tree more quickly & fix issues we have. This isn't a final solution by any means, we should also do something along the lines of the StableState approach, but it should be sufficient for now. Depends on D19177 Differential Revision: https://phabricator.services.mozilla.com/D19178 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
4dc7fc3d64
Коммит
34cef5cb0d
|
@ -515,4 +515,46 @@ already_AddRefed<BrowsingContext> BrowsingContext::FindChildWithName(
|
|||
}
|
||||
|
||||
} // namespace dom
|
||||
|
||||
namespace ipc {
|
||||
|
||||
void IPDLParamTraits<dom::BrowsingContext>::Write(
|
||||
IPC::Message* aMsg, IProtocol* aActor, dom::BrowsingContext* aParam) {
|
||||
uint64_t id = aParam ? aParam->Id() : 0;
|
||||
WriteIPDLParam(aMsg, aActor, id);
|
||||
|
||||
// If his is an in-process send. We want to make sure that our BrowsingContext
|
||||
// object lives long enough to make it to the other side, so we take an extra
|
||||
// reference. This reference is freed in ::Read().
|
||||
if (!aActor->GetIPCChannel()->IsCrossProcess()) {
|
||||
NS_IF_ADDREF(aParam);
|
||||
}
|
||||
}
|
||||
|
||||
bool IPDLParamTraits<dom::BrowsingContext>::Read(
|
||||
const IPC::Message* aMsg, PickleIterator* aIter, IProtocol* aActor,
|
||||
RefPtr<dom::BrowsingContext>* aResult) {
|
||||
uint64_t id = 0;
|
||||
if (!ReadIPDLParam(aMsg, aIter, aActor, &id)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (id == 0) {
|
||||
aResult = nullptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
*aResult = dom::BrowsingContext::Get(id);
|
||||
MOZ_ASSERT(aResult, "Deserialized absent BrowsingContext!");
|
||||
|
||||
// If this is an in-process actor, free the reference taken in ::Write().
|
||||
if (!aActor->GetIPCChannel()->IsCrossProcess()) {
|
||||
dom::BrowsingContext* bc = *aResult;
|
||||
NS_IF_RELEASE(bc);
|
||||
}
|
||||
|
||||
return aResult != nullptr;
|
||||
}
|
||||
|
||||
} // namespace ipc
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -20,6 +20,11 @@
|
|||
|
||||
class nsGlobalWindowOuter;
|
||||
class nsOuterWindowProxy;
|
||||
class PickleIterator;
|
||||
|
||||
namespace IPC {
|
||||
class Message;
|
||||
} // namespace IPC
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -27,6 +32,13 @@ class ErrorResult;
|
|||
class LogModule;
|
||||
class OOMReporter;
|
||||
|
||||
namespace ipc {
|
||||
class IProtocol;
|
||||
|
||||
template <typename T>
|
||||
struct IPDLParamTraits;
|
||||
} // namespace ipc
|
||||
|
||||
namespace dom {
|
||||
|
||||
class BrowsingContextGroup;
|
||||
|
@ -254,6 +266,17 @@ extern bool GetRemoteOuterWindowProxy(JSContext* aCx, BrowsingContext* aContext,
|
|||
JS::MutableHandle<JSObject*> aRetVal);
|
||||
|
||||
} // namespace dom
|
||||
|
||||
// Allow sending BrowsingContext objects over IPC.
|
||||
namespace ipc {
|
||||
template <>
|
||||
struct IPDLParamTraits<dom::BrowsingContext> {
|
||||
static void Write(IPC::Message* aMsg, IProtocol* aActor,
|
||||
dom::BrowsingContext* aParam);
|
||||
static bool Read(const IPC::Message* aMsg, PickleIterator* aIter,
|
||||
IProtocol* aActor, RefPtr<dom::BrowsingContext>* aResult);
|
||||
};
|
||||
} // namespace ipc
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // !defined(mozilla_dom_BrowsingContext_h)
|
||||
|
|
|
@ -22,6 +22,7 @@ namespace dom {
|
|||
class CanonicalBrowsingContext;
|
||||
class WindowGlobalChild;
|
||||
class JSWindowActorParent;
|
||||
class TabParent;
|
||||
|
||||
/**
|
||||
* A handle in the parent process to a specific nsGlobalWindowInner object.
|
||||
|
|
Загрузка…
Ссылка в новой задаче