Backed out 3 changesets (bug 1366011, bug 1359357) for mochitest failures in test_ipcBlob_workers.html

Backed out changeset a20220d687d4 (bug 1359357)
Backed out changeset 9f71fb3f4d1e (bug 1359357)
Backed out changeset 70e5477cdda0 (bug 1366011)
This commit is contained in:
Iris Hsiao 2017-05-19 15:59:55 +08:00
parent c1a2199259
commit 09507c3bc6
8 changed files with 14 additions and 152 deletions

View File

@ -192,10 +192,6 @@ IPCBlobInputStream::Clone(nsIInputStream** aResult)
MOZ_ASSERT(mActor);
nsCOMPtr<nsIInputStream> stream = mActor->CreateStream();
if (!stream) {
return NS_ERROR_FAILURE;
}
stream.forget(aResult);
return NS_OK;
}

View File

@ -5,7 +5,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "IPCBlobInputStreamChild.h"
#include "WorkerHolder.h"
namespace mozilla {
namespace dom {
@ -14,17 +13,19 @@ namespace {
// This runnable is used in case the last stream is forgotten on the 'wrong'
// thread.
class ShutdownRunnable final : public CancelableRunnable
class DeleteRunnable final : public Runnable
{
public:
explicit ShutdownRunnable(IPCBlobInputStreamChild* aActor)
explicit DeleteRunnable(IPCBlobInputStreamChild* aActor)
: mActor(aActor)
{}
NS_IMETHOD
Run() override
{
mActor->Shutdown();
if (mActor->IsAlive()) {
mActor->Send__delete__(mActor);
}
return NS_OK;
}
@ -34,7 +35,7 @@ private:
// This runnable is used in case StreamNeeded() has been called on a non-owning
// thread.
class StreamNeededRunnable final : public CancelableRunnable
class StreamNeededRunnable final : public Runnable
{
public:
explicit StreamNeededRunnable(IPCBlobInputStreamChild* aActor)
@ -80,26 +81,6 @@ private:
nsCOMPtr<nsIInputStream> mCreatedStream;
};
class IPCBlobInputStreamWorkerHolder final : public WorkerHolder
{
public:
explicit IPCBlobInputStreamWorkerHolder(IPCBlobInputStreamChild* aActor)
: mActor(aActor)
{}
bool Notify(Status aStatus) override
{
if (aStatus > Running) {
mActor->Shutdown();
// After this the WorkerHolder is gone.
}
return true;
}
private:
RefPtr<IPCBlobInputStreamChild> mActor;
};
} // anonymous
IPCBlobInputStreamChild::IPCBlobInputStreamChild(const nsID& aID,
@ -109,50 +90,16 @@ IPCBlobInputStreamChild::IPCBlobInputStreamChild(const nsID& aID,
, mSize(aSize)
, mActorAlive(true)
, mOwningThread(NS_GetCurrentThread())
{
// If we are running in a worker, we need to send a Close() to the parent side
// before the thread is released.
if (!NS_IsMainThread()) {
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
if (workerPrivate) {
UniquePtr<WorkerHolder> workerHolder(
new IPCBlobInputStreamWorkerHolder(this));
if (workerHolder->HoldWorker(workerPrivate, Canceling)) {
mWorkerHolder.swap(workerHolder);
}
}
}
}
{}
IPCBlobInputStreamChild::~IPCBlobInputStreamChild()
{}
void
IPCBlobInputStreamChild::Shutdown()
{
MutexAutoLock lock(mMutex);
RefPtr<IPCBlobInputStreamChild> kungFuDeathGrip = this;
mWorkerHolder = nullptr;
mPendingOperations.Clear();
if (mActorAlive) {
SendClose();
mActorAlive = false;
}
}
void
IPCBlobInputStreamChild::ActorDestroy(IProtocol::ActorDestroyReason aReason)
{
{
MutexAutoLock lock(mMutex);
mActorAlive = false;
}
// Let's cleanup the workerHolder and the pending operation queue.
Shutdown();
MutexAutoLock lock(mMutex);
mActorAlive = false;
}
bool
@ -167,10 +114,6 @@ IPCBlobInputStreamChild::CreateStream()
{
MutexAutoLock lock(mMutex);
if (!mActorAlive) {
return nullptr;
}
RefPtr<IPCBlobInputStream> stream = new IPCBlobInputStream(this);
mStreams.AppendElement(stream);
return stream.forget();
@ -181,7 +124,7 @@ IPCBlobInputStreamChild::ForgetStream(IPCBlobInputStream* aStream)
{
MOZ_ASSERT(aStream);
RefPtr<IPCBlobInputStreamChild> kungFuDeathGrip = this;
RefPtr<IPCBlobInputStreamChild> kungFoDeathGrip = this;
{
MutexAutoLock lock(mMutex);
@ -193,11 +136,11 @@ IPCBlobInputStreamChild::ForgetStream(IPCBlobInputStream* aStream)
}
if (mOwningThread == NS_GetCurrentThread()) {
Shutdown();
Send__delete__(this);
return;
}
RefPtr<ShutdownRunnable> runnable = new ShutdownRunnable(this);
RefPtr<DeleteRunnable> runnable = new DeleteRunnable(this);
mOwningThread->Dispatch(runnable, NS_DISPATCH_NORMAL);
}
@ -206,11 +149,6 @@ IPCBlobInputStreamChild::StreamNeeded(IPCBlobInputStream* aStream,
nsIEventTarget* aEventTarget)
{
MutexAutoLock lock(mMutex);
if (!mActorAlive) {
return;
}
MOZ_ASSERT(mStreams.Contains(aStream));
PendingOperation* opt = mPendingOperations.AppendElement();
@ -237,7 +175,6 @@ IPCBlobInputStreamChild::RecvStreamReady(const OptionalIPCStream& aStream)
{
MutexAutoLock lock(mMutex);
MOZ_ASSERT(!mPendingOperations.IsEmpty());
MOZ_ASSERT(mActorAlive);
pendingStream = mPendingOperations[0].mStream;
eventTarget = mPendingOperations[0].mEventTarget;

View File

@ -9,17 +9,12 @@
#include "mozilla/ipc/PIPCBlobInputStreamChild.h"
#include "mozilla/Mutex.h"
#include "mozilla/UniquePtr.h"
#include "nsIThread.h"
#include "nsTArray.h"
namespace mozilla {
namespace dom {
namespace workers {
class WorkerHolder;
}
class IPCBlobInputStream;
class IPCBlobInputStreamChild final
@ -61,9 +56,6 @@ public:
mozilla::ipc::IPCResult
RecvStreamReady(const OptionalIPCStream& aStream) override;
void
Shutdown();
private:
~IPCBlobInputStreamChild();
@ -90,8 +82,6 @@ private:
nsTArray<PendingOperation> mPendingOperations;
nsCOMPtr<nsIThread> mOwningThread;
UniquePtr<workers::WorkerHolder> mWorkerHolder;
};
} // namespace dom

View File

@ -96,17 +96,5 @@ IPCBlobInputStreamParent::RecvStreamNeeded()
return IPC_OK();
}
mozilla::ipc::IPCResult
IPCBlobInputStreamParent::RecvClose()
{
MOZ_ASSERT(mContentManager || mPBackgroundManager);
if (!Send__delete__(this)) {
return IPC_FAIL(this, "Send__delete_ failed");
}
return IPC_OK();
}
} // namespace dom
} // namespace mozilla

View File

@ -44,9 +44,6 @@ public:
mozilla::ipc::IPCResult
RecvStreamNeeded() override;
mozilla::ipc::IPCResult
RecvClose() override;
private:
IPCBlobInputStreamParent(const nsID& aID, uint64_t aSize,
nsIContentParent* aManager);

View File

@ -20,11 +20,11 @@ protocol PIPCBlobInputStream
parent:
async StreamNeeded();
async Close();
async __delete__();
child:
async StreamReady(OptionalIPCStream aStream);
async __delete__();
};
} // namespace dom

View File

@ -3,4 +3,3 @@ support-files =
script_file.js
[test_ipcBlob_fileReaderSync.html]
[test_ipcBlob_workers.html]

View File

@ -1,45 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test IPCBlob and Workers</title>
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<script type="text/javascript">
function workerScript() {
let bc = new BroadcastChannel('foo');
bc.onmessage = (event) => {
let reader = new FileReader();
reader.readAsText(event.data);
reader.onloadend = () => {
let status = reader.result == 'hello world';
bc.onmessage = null;
postMessage(status);
}
}
postMessage("start");
}
let workerUrl = URL.createObjectURL(new Blob(["(", workerScript.toSource(), ")()"]));
let worker = new Worker(workerUrl);
worker.onmessage = event => {
if (event.data == "start") {
let bc = new BroadcastChannel('foo');
bc.postMessage(new Blob(['hello world']));
} else {
ok(event.data, "All is done!");
SimpleTest.finish();
}
};
SimpleTest.waitForExplicitFinish();
</script>
</pre>
</body>
</html>