Back out 3 changesets (bug 1162720) for mozilla::media::Parent::Release crashes

CLOSED TREE

Backed out changeset 05306872093a (bug 1162720)
Backed out changeset 94a7098042fb (bug 1162720)
Backed out changeset 7c2f391a7fdd (bug 1162720)
This commit is contained in:
Phil Ringnalda 2015-05-16 09:09:25 -07:00
Родитель cb58c0c05c
Коммит 9fd5acd0bd
5 изменённых файлов: 96 добавлений и 131 удалений

Просмотреть файл

@ -2288,7 +2288,7 @@ MediaManager::Observe(nsISupports* aSubject, const char* aTopic,
// cleared until the lambda function clears it.
MediaManager::GetMessageLoop()->PostTask(FROM_HERE, new ShutdownTask(
media::NewRunnableFrom([this]() mutable {
media::CallbackRunnable::New([this]() mutable {
// Close off any remaining active windows.
MutexAutoLock lock(mMutex);
GetActiveWindows()->Clear();

Просмотреть файл

@ -104,7 +104,10 @@ class ParentSingleton : public nsISupports
class OriginKeysLoader : public OriginKeysTable
{
public:
OriginKeysLoader() {}
OriginKeysLoader()
{
Load();
}
nsresult
GetOriginKey(const nsACString& aOrigin, nsCString& result)
@ -120,7 +123,13 @@ class ParentSingleton : public nsISupports
already_AddRefed<nsIFile>
GetFile()
{
MOZ_ASSERT(mProfileDir);
if (!mProfileDir) {
nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR,
getter_AddRefs(mProfileDir));
if (NS_WARN_IF(NS_FAILED(rv))) {
return nullptr;
}
}
nsCOMPtr<nsIFile> file;
nsresult rv = mProfileDir->Clone(getter_AddRefs(file));
if (NS_WARN_IF(NS_FAILED(rv))) {
@ -308,17 +317,6 @@ class ParentSingleton : public nsISupports
return NS_OK;
}
void
SetProfileDir(nsIFile* aProfileDir)
{
MOZ_ASSERT(!NS_IsMainThread());
bool first = !mProfileDir;
mProfileDir = aProfileDir;
// Load from disk when we first get a profileDir, but not subsequently.
if (first) {
Load();
}
}
private:
nsCOMPtr<nsIFile> mProfileDir;
};
@ -357,60 +355,25 @@ Parent::RecvGetOriginKey(const uint32_t& aRequestId,
const nsCString& aOrigin,
const bool& aPrivateBrowsing)
{
// TODO: Replace all this when moving MediaParent to PContent soon (1037389)
// Hand over to stream-transport thread.
nsCOMPtr<nsIEventTarget> sts = do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
MOZ_ASSERT(sts);
nsRefPtr<ParentSingleton> singleton(mSingleton);
nsCOMPtr<nsIThread> returnThread = NS_GetCurrentThread();
nsRefPtr<Pledge<nsCString>> p = new Pledge<nsCString>();
nsresult rv;
// First, over to main thread to get profile dir.
rv = NS_DispatchToMainThread(NewRunnableFrom([p, returnThread, singleton, aOrigin,
aPrivateBrowsing]() -> nsresult {
MOZ_ASSERT(NS_IsMainThread());
nsCOMPtr<nsIFile> profileDir;
nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR,
getter_AddRefs(profileDir));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
// Then from there over to stream-transport thread to do the actual file io.
nsCOMPtr<nsIEventTarget> sts = do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
MOZ_ASSERT(sts);
rv = sts->Dispatch(NewRunnableFrom([profileDir, p, returnThread, singleton,
aOrigin, aPrivateBrowsing]() -> nsresult {
MOZ_ASSERT(!NS_IsMainThread());
singleton->mOriginKeys.SetProfileDir(profileDir);
nsCString result;
if (aPrivateBrowsing) {
singleton->mPrivateBrowsingOriginKeys.GetOriginKey(aOrigin, result);
} else {
singleton->mOriginKeys.GetOriginKey(aOrigin, result);
}
// Pass result back to original thread.
nsresult rv;
rv = returnThread->Dispatch(NewRunnableFrom([p, result]() -> nsresult {
p->Resolve(result);
return NS_OK;
}), NS_DISPATCH_NORMAL);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
return NS_OK;
}), NS_DISPATCH_NORMAL);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
nsRefPtr<PledgeRunnable<nsCString>> p = PledgeRunnable<nsCString>::New(
[singleton, aOrigin, aPrivateBrowsing](nsCString& aResult) {
if (aPrivateBrowsing) {
singleton->mPrivateBrowsingOriginKeys.GetOriginKey(aOrigin, aResult);
} else {
singleton->mOriginKeys.GetOriginKey(aOrigin, aResult);
}
return NS_OK;
}));
});
nsresult rv = sts->Dispatch(p, NS_DISPATCH_NORMAL);
if (NS_WARN_IF(NS_FAILED(rv))) {
return false;
}
nsRefPtr<media::Parent> keepAlive(this);
p->Then([this, keepAlive, aRequestId](const nsCString& aKey) mutable {
if (!mDestroyed) {
@ -424,36 +387,19 @@ Parent::RecvGetOriginKey(const uint32_t& aRequestId,
bool
Parent::RecvSanitizeOriginKeys(const uint64_t& aSinceWhen)
{
// Hand over to stream-transport thread.
nsCOMPtr<nsIEventTarget> sts = do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
MOZ_ASSERT(sts);
nsRefPtr<ParentSingleton> singleton(mSingleton);
// First, over to main to get profile dir.
nsresult rv;
rv = NS_DispatchToMainThread(NewRunnableFrom([singleton,
aSinceWhen]() -> nsresult {
MOZ_ASSERT(NS_IsMainThread());
nsCOMPtr<nsIFile> profileDir;
nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR,
getter_AddRefs(profileDir));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
// Then from there over to stream-transport thread to do the file io.
nsCOMPtr<nsIEventTarget> sts = do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
MOZ_ASSERT(sts);
rv = sts->Dispatch(NewRunnableFrom([profileDir, singleton, aSinceWhen]() -> nsresult {
MOZ_ASSERT(!NS_IsMainThread());
singleton->mOriginKeys.SetProfileDir(profileDir);
singleton->mPrivateBrowsingOriginKeys.Clear(aSinceWhen);
singleton->mOriginKeys.Clear(aSinceWhen);
return NS_OK;
}), NS_DISPATCH_NORMAL);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
nsRefPtr<PledgeRunnable<bool>> p = PledgeRunnable<bool>::New(
[singleton, aSinceWhen](bool) {
singleton->mPrivateBrowsingOriginKeys.Clear(aSinceWhen);
singleton->mOriginKeys.Clear(aSinceWhen);
return NS_OK;
}));
});
nsresult rv = sts->Dispatch(p, NS_DISPATCH_NORMAL);
if (NS_WARN_IF(NS_FAILED(rv))) {
return false;
}

Просмотреть файл

@ -37,7 +37,6 @@ class Pledge
};
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(Pledge);
explicit Pledge() : mDone(false), mResult(NS_OK) {}
template<typename OnSuccessType>
@ -78,12 +77,13 @@ public:
}
}
protected:
void Resolve(const ValueType& aValue)
{
mValue = aValue;
Resolve();
}
protected:
void Resolve()
{
if (!mDone) {
@ -108,20 +108,72 @@ protected:
ValueType mValue;
protected:
~Pledge() {};
bool mDone;
nsresult mResult;
private:
nsAutoPtr<FunctorsBase> mFunctors;
};
// General purpose runnable with an eye toward lambdas
// General purpose runnable that also acts as a Pledge for the resulting value.
// Use PledgeRunnable<>::New() factory function to use with lambdas.
template<typename OnRunType>
class LambdaRunnable : public nsRunnable
template<typename ValueType>
class PledgeRunnable : public Pledge<ValueType>, public nsRunnable
{
public:
explicit LambdaRunnable(OnRunType& aOnRun) : mOnRun(aOnRun) {}
template<typename OnRunType>
static PledgeRunnable<ValueType>*
New(OnRunType aOnRun)
{
class P : public PledgeRunnable<ValueType>
{
public:
explicit P(OnRunType& aOnRun)
: mOriginThread(NS_GetCurrentThread())
, mOnRun(aOnRun)
, mHasRun(false) {}
private:
virtual ~P() {}
NS_IMETHODIMP
Run()
{
if (!mHasRun) {
P::mResult = mOnRun(P::mValue);
mHasRun = true;
return mOriginThread->Dispatch(this, NS_DISPATCH_NORMAL);
}
bool on;
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(mOriginThread->IsOnCurrentThread(&on)));
MOZ_RELEASE_ASSERT(on);
if (NS_SUCCEEDED(P::mResult)) {
P::Resolve();
} else {
P::Reject(P::mResult);
}
return NS_OK;
}
nsCOMPtr<nsIThread> mOriginThread;
OnRunType mOnRun;
bool mHasRun;
};
return new P(aOnRun);
}
protected:
virtual ~PledgeRunnable() {}
};
// General purpose runnable with an eye toward lambdas
namespace CallbackRunnable
{
template<typename OnRunType>
class Impl : public nsRunnable
{
public:
explicit Impl(OnRunType& aOnRun) : mOnRun(aOnRun) {}
private:
NS_IMETHODIMP
Run()
@ -132,10 +184,11 @@ private:
};
template<typename OnRunType>
LambdaRunnable<OnRunType>*
NewRunnableFrom(OnRunType aOnRun)
Impl<OnRunType>*
New(OnRunType aOnRun)
{
return new LambdaRunnable<OnRunType>(aOnRun);
return new Impl<OnRunType>(aOnRun);
}
}
}

Просмотреть файл

@ -29,8 +29,6 @@ skip-if = toolkit == 'gonk' || buildapp == 'mulet' # b2g(Bug 960442, video suppo
skip-if = toolkit == 'gonk' || buildapp == 'mulet' # b2g emulator seems to be too slow (Bug 1016498 and 1008080)
[test_dataChannel_noOffer.html]
skip-if = toolkit == 'gonk' || buildapp == 'mulet' # b2g (Bug 1059867)
[test_enumerateDevices.html]
skip-if = buildapp == 'mulet'
[test_getUserMedia_basicAudio.html]
skip-if = (toolkit == 'gonk' || buildapp == 'mulet' && debug) # debug-only failure
[test_getUserMedia_basicVideo.html]

Просмотреть файл

@ -1,32 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<script src="mediaStreamPlayback.js"></script>
</head>
<body>
<pre id="test">
<script type="application/javascript">
createHTML({ title: "Run enumerateDevices code", bug: "1046245" });
/**
Tests covering enumerateDevices API. Exercise code.
*/
runTest(function() {
navigator.mediaDevices.enumerateDevices()
.then(devices => {
ok(devices.length > 0, "At least one device found");
devices.forEach(d => {
ok(d.kind == "videoinput" || d.kind == "audioinput", "Known device kind");
is(d.deviceId.length, 44, "Correct device id length");
ok(d.label.length !== undefined, "Device label: " + d.label);
is(d.groupId, "", "Don't support groupId yet");
});
})
.catch(e => ok(false, "Unexpected failure: " + e.name + ", " + e.message))
.then(SimpleTest.finish);
});
</script>
</pre>
</body>
</html>