Bug 1208289 - Backout. r=backout

This commit is contained in:
Chris Pearce 2015-09-28 15:37:18 +13:00
Родитель 771aa6c979
Коммит e30c6e5fa9
5 изменённых файлов: 6 добавлений и 149 удалений

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

@ -369,78 +369,4 @@ CreateFlushableMediaDecodeTaskQueue()
return queue.forget();
}
void
SimpleTimer::Cancel() {
if (mTimer) {
#ifdef DEBUG
nsCOMPtr<nsIEventTarget> target;
mTimer->GetTarget(getter_AddRefs(target));
nsCOMPtr<nsIThread> thread(do_QueryInterface(target));
MOZ_ASSERT(NS_GetCurrentThread() == thread);
#endif
mTimer->Cancel();
mTimer = nullptr;
}
mTask = nullptr;
}
NS_IMETHODIMP
SimpleTimer::Notify(nsITimer *timer) {
nsRefPtr<SimpleTimer> deathGrip(this);
if (mTask) {
mTask->Run();
mTask = nullptr;
}
return NS_OK;
}
nsresult
SimpleTimer::Init(nsIRunnable* aTask, uint32_t aTimeoutMs, nsIThread* aTarget)
{
nsresult rv;
// Get target thread first, so we don't have to cancel the timer if it fails.
nsCOMPtr<nsIThread> target;
if (aTarget) {
target = aTarget;
} else {
rv = NS_GetMainThread(getter_AddRefs(target));
if (NS_FAILED(rv)) {
return rv;
}
}
nsCOMPtr<nsITimer> timer = do_CreateInstance(NS_TIMER_CONTRACTID, &rv);
if (NS_FAILED(rv)) {
return rv;
}
// Note: set target before InitWithCallback in case the timer fires before
// we change the event target.
rv = timer->SetTarget(aTarget);
if (NS_FAILED(rv)) {
timer->Cancel();
return rv;
}
rv = timer->InitWithCallback(this, aTimeoutMs, nsITimer::TYPE_ONE_SHOT);
if (NS_FAILED(rv)) {
return rv;
}
mTimer = timer.forget();
mTask = aTask;
return NS_OK;
}
NS_IMPL_ISUPPORTS(SimpleTimer, nsITimerCallback)
already_AddRefed<SimpleTimer>
SimpleTimer::Create(nsIRunnable* aTask, uint32_t aTimeoutMs, nsIThread* aTarget)
{
nsRefPtr<SimpleTimer> t(new SimpleTimer());
if (NS_FAILED(t->Init(aTask, aTimeoutMs, aTarget))) {
return nullptr;
}
return t.forget();
}
} // end namespace mozilla

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

@ -22,8 +22,6 @@
#include "prtime.h"
#include "AudioSampleFormat.h"
#include "TimeUnits.h"
#include "nsITimer.h"
#include "nsCOMPtr.h"
using mozilla::CheckedInt64;
using mozilla::CheckedUint64;
@ -303,29 +301,6 @@ nsRefPtr<GenericPromise> InvokeUntil(Work aWork, Condition aCondition) {
return p.forget();
}
// Simple timer to run a runnable after a timeout.
class SimpleTimer : public nsITimerCallback
{
public:
NS_DECL_ISUPPORTS
// Create a new timer to run aTask after aTimeoutMs milliseconds
// on thread aTarget. If aTarget is null, task is run on the main thread.
static already_AddRefed<SimpleTimer> Create(nsIRunnable* aTask,
uint32_t aTimeoutMs,
nsIThread* aTarget = nullptr);
void Cancel();
NS_IMETHOD Notify(nsITimer *timer) override;
private:
virtual ~SimpleTimer() {}
nsresult Init(nsIRunnable* aTask, uint32_t aTimeoutMs, nsIThread* aTarget);
nsRefPtr<nsIRunnable> mTask;
nsCOMPtr<nsITimer> mTimer;
};
} // end namespace mozilla
#endif

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

@ -7,7 +7,6 @@
#include "mozilla/EMEUtils.h"
#include "nsServiceManagerUtils.h"
#include "nsIConsoleService.h"
#include "nsThreadUtils.h"
namespace mozilla {
@ -114,13 +113,6 @@ ParseKeySystem(const nsAString& aInputKeySystem,
void
LogToBrowserConsole(const nsAString& aMsg)
{
if (!NS_IsMainThread()) {
nsAutoString msg(aMsg);
nsCOMPtr<nsIRunnable> task =
NS_NewRunnableFunction([msg]() { LogToBrowserConsole(msg); });
NS_DispatchToMainThread(task.forget(), NS_DISPATCH_NORMAL);
return;
}
nsCOMPtr<nsIConsoleService> console(
do_GetService("@mozilla.org/consoleservice;1"));
if (!console) {

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

@ -14,7 +14,6 @@
#include "GMPContentParent.h"
#include "GMPMessageUtils.h"
#include "mozilla/gmp/GMPTypes.h"
#include "mozilla/EMEUtils.h"
namespace mozilla {
@ -51,7 +50,6 @@ GMPVideoDecoderParent::GMPVideoDecoderParent(GMPContentParent* aPlugin)
, mCallback(nullptr)
, mVideoHost(this)
, mPluginId(aPlugin->GetPluginId())
, mFrameCount(0)
{
MOZ_ASSERT(mPlugin);
}
@ -159,7 +157,6 @@ GMPVideoDecoderParent::Decode(GMPUniquePtr<GMPVideoEncodedFrame> aInputFrame,
aRenderTimeMs)) {
return NS_ERROR_FAILURE;
}
mFrameCount++;
// Async IPC, we don't have access to a return value.
return NS_OK;
@ -183,33 +180,14 @@ GMPVideoDecoderParent::Reset()
mIsAwaitingResetComplete = true;
nsRefPtr<GMPVideoDecoderParent> self(this);
nsCOMPtr<nsIRunnable> task = NS_NewRunnableFunction([self]() -> void
{
LOGD(("GMPVideoDecoderParent[%p]::ResetCompleteTimeout() timed out waiting for ResetComplete", self));
self->mResetCompleteTimeout = nullptr;
LogToBrowserConsole(NS_LITERAL_STRING("GMPVideoDecoderParent timed out waiting for ResetComplete()"));
});
CancelResetCompleteTimeout();
mResetCompleteTimeout = SimpleTimer::Create(task, 5000, mPlugin->GMPThread());
// Async IPC, we don't have access to a return value.
return NS_OK;
}
void
GMPVideoDecoderParent::CancelResetCompleteTimeout()
{
if (mResetCompleteTimeout) {
mResetCompleteTimeout->Cancel();
mResetCompleteTimeout = nullptr;
}
}
nsresult
GMPVideoDecoderParent::Drain()
{
LOGD(("GMPVideoDecoderParent[%p]::Drain() frameCount=%d", this, mFrameCount));
LOGD(("GMPVideoDecoderParent[%p]::Drain()", this));
if (!mIsOpen) {
NS_WARNING("Trying to use an dead GMP video decoder");
@ -302,9 +280,8 @@ GMPVideoDecoderParent::ActorDestroy(ActorDestroyReason aWhy)
bool
GMPVideoDecoderParent::RecvDecoded(const GMPVideoi420FrameData& aDecodedFrame)
{
--mFrameCount;
LOGV(("GMPVideoDecoderParent[%p]::RecvDecoded() timestamp=%lld frameCount=%d",
this, aDecodedFrame.mTimestamp(), mFrameCount));
LOGV(("GMPVideoDecoderParent[%p]::RecvDecoded() timestamp=%lld",
this, aDecodedFrame.mTimestamp()));
if (!mCallback) {
return false;
@ -368,11 +345,8 @@ GMPVideoDecoderParent::RecvInputDataExhausted()
bool
GMPVideoDecoderParent::RecvDrainComplete()
{
LOGD(("GMPVideoDecoderParent[%p]::RecvDrainComplete() frameCount=%d", this, mFrameCount));
nsAutoString msg;
msg.AppendLiteral("GMPVideoDecoderParent::RecvDrainComplete() outstanding frames=");
msg.AppendInt(mFrameCount);
LogToBrowserConsole(msg);
LOGD(("GMPVideoDecoderParent[%p]::RecvDrainComplete()", this));
if (!mCallback) {
return false;
}
@ -393,8 +367,6 @@ GMPVideoDecoderParent::RecvResetComplete()
{
LOGD(("GMPVideoDecoderParent[%p]::RecvResetComplete()", this));
CancelResetCompleteTimeout();
if (!mCallback) {
return false;
}
@ -403,7 +375,6 @@ GMPVideoDecoderParent::RecvResetComplete()
return true;
}
mIsAwaitingResetComplete = false;
mFrameCount = 0;
// Ignore any return code. It is OK for this to fail without killing the process.
mCallback->ResetComplete();
@ -486,9 +457,7 @@ GMPVideoDecoderParent::Recv__delete__()
void
GMPVideoDecoderParent::UnblockResetAndDrain()
{
LOGD(("GMPVideoDecoderParent[%p]::UnblockResetAndDrain() "
"awaitingResetComplete=%d awaitingDrainComplete=%d",
this, mIsAwaitingResetComplete, mIsAwaitingDrainComplete));
LOGD(("GMPVideoDecoderParent[%p]::UnblockResetAndDrain()", this));
if (!mCallback) {
MOZ_ASSERT(!mIsAwaitingResetComplete);
@ -503,7 +472,6 @@ GMPVideoDecoderParent::UnblockResetAndDrain()
mIsAwaitingDrainComplete = false;
mCallback->DrainComplete();
}
CancelResetCompleteTimeout();
}
} // namespace gmp

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

@ -14,7 +14,6 @@
#include "GMPUtils.h"
#include "GMPVideoHost.h"
#include "GMPVideoDecoderProxy.h"
#include "VideoUtils.h"
namespace mozilla {
namespace gmp {
@ -81,7 +80,6 @@ private:
virtual bool Recv__delete__() override;
void UnblockResetAndDrain();
void CancelResetCompleteTimeout();
bool mIsOpen;
bool mShuttingDown;
@ -92,8 +90,6 @@ private:
GMPVideoDecoderCallbackProxy* mCallback;
GMPVideoHostImpl mVideoHost;
const uint32_t mPluginId;
int32_t mFrameCount;
nsRefPtr<SimpleTimer> mResetCompleteTimeout;
};
} // namespace gmp