Bug 1186745 part 4 - Make TracedRunnable accept an already_AddRefed instead of a raw pointer. r=froydnj

This commit is contained in:
Xidorn Quan 2015-10-06 13:00:59 +11:00
parent ffffb48f52
commit 1c258c6b0b
4 changed files with 8 additions and 7 deletions

View File

@ -75,7 +75,8 @@ const PRTime GetStartTime();
Task* CreateTracedTask(Task* aTask);
already_AddRefed<nsIRunnable> CreateTracedRunnable(nsIRunnable* aRunnable);
already_AddRefed<nsIRunnable>
CreateTracedRunnable(already_AddRefed<nsIRunnable>&& aRunnable);
// Free the TraceInfo allocated on a thread's TLS. Currently we are wrapping
// tasks running on nsThreads and base::thread, so FreeTraceInfo is called at

View File

@ -90,9 +90,9 @@ TracedTaskCommon::ClearTLSTraceInfo()
/**
* Implementation of class TracedRunnable.
*/
TracedRunnable::TracedRunnable(nsIRunnable* aOriginalObj)
TracedRunnable::TracedRunnable(already_AddRefed<nsIRunnable>&& aOriginalObj)
: TracedTaskCommon()
, mOriginalObj(aOriginalObj)
, mOriginalObj(Move(aOriginalObj))
{
Init();
LogVirtualTablePtr(mTaskId, mSourceEventId, *(int**)(aOriginalObj));
@ -148,9 +148,9 @@ TracedTask::Run()
* nsIRunnable object, aRunnable.
*/
already_AddRefed<nsIRunnable>
CreateTracedRunnable(nsIRunnable* aRunnable)
CreateTracedRunnable(already_AddRefed<nsIRunnable>&& aRunnable)
{
nsCOMPtr<nsIRunnable> runnable = new TracedRunnable(aRunnable);
nsCOMPtr<nsIRunnable> runnable = new TracedRunnable(Move(aRunnable));
return runnable.forget();
}

View File

@ -46,7 +46,7 @@ class TracedRunnable : public TracedTaskCommon
public:
NS_DECL_NSIRUNNABLE
TracedRunnable(nsIRunnable* aOriginalObj);
TracedRunnable(already_AddRefed<nsIRunnable>&& aOriginalObj);
private:
virtual ~TracedRunnable();

View File

@ -592,7 +592,7 @@ nsThread::DispatchInternal(already_AddRefed<nsIRunnable>&& aEvent, uint32_t aFla
}
#ifdef MOZ_TASK_TRACER
nsCOMPtr<nsIRunnable> tracedRunnable = CreateTracedRunnable(event); // adds a ref
nsCOMPtr<nsIRunnable> tracedRunnable = CreateTracedRunnable(event.forget());
(static_cast<TracedRunnable*>(tracedRunnable.get()))->DispatchTask();
event = tracedRunnable.forget();
#endif