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-09-29 09:28:22 +10:00
parent ad0c24a0c5
commit 4707215240
4 changed files with 8 additions and 7 deletions

View File

@ -75,7 +75,8 @@ const PRTime GetStartTime();
Task* CreateTracedTask(Task* aTask); 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 // 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 // tasks running on nsThreads and base::thread, so FreeTraceInfo is called at

View File

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

View File

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

View File

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