Bug 1353629 - PBlob refactoring - part 2 - IPCStream must be available on PBackground, r=smaug

In order to use IPCBlob in any IPC protocol, IPCStream must be available also
on PBackground.
This commit is contained in:
Andrea Marchesini 2017-04-24 12:09:40 +02:00
parent f3bd4e6da7
commit 4f87431fb2

View File

@ -128,21 +128,24 @@ IPCStreamSource::Initialize()
}
// A source can be used on any thread, but we only support IPCStream on
// main thread and Worker threads right now. This is due to the requirement
// that the thread be guaranteed to live long enough to receive messages.
// We can enforce this guarantee with a feature on worker threads, but not
// other threads.
// main thread, Workers and PBackground thread right now. This is due
// to the requirement that the thread be guaranteed to live long enough to
// receive messages. We can enforce this guarantee with a WorkerHolder on
// worker threads, but not other threads. Main-thread and PBackground thread
// do not need anything special in order to be kept alive.
WorkerPrivate* workerPrivate = nullptr;
if (!NS_IsMainThread()) {
workerPrivate = GetCurrentThreadWorkerPrivate();
MOZ_RELEASE_ASSERT(workerPrivate);
if (workerPrivate) {
bool result = HoldWorker(workerPrivate, Canceling);
if (!result) {
return false;
}
bool result = HoldWorker(workerPrivate, Canceling);
if (!result) {
return false;
mWorkerPrivate = workerPrivate;
} else {
AssertIsOnBackgroundThread();
}
mWorkerPrivate = workerPrivate;
}
return true;
@ -186,7 +189,6 @@ void
IPCStreamSource::Start()
{
NS_ASSERT_OWNINGTHREAD(IPCStreamSource);
MOZ_ASSERT_IF(!NS_IsMainThread(), mWorkerPrivate);
DoRead();
}