gecko/tools/profiler/TracedTaskCommon.h
Ehsan Akhgari b6e35bb4b4 Bug 1118486 - Part 1: Use = delete instead of MOZ_DELETE directly; r=Waldo
Most of this patch (with the exception of dom/bindings/Codegen.py) was
generated by the following bash script:

#!/bin/bash

function convert() {
echo "Converting $1 to $2..."
find . ! -wholename "*nsprpub*" \
       ! -wholename "*security/nss*" \
       ! -wholename "*/.hg*" \
       ! -wholename "*/.git*" \
       ! -wholename "obj-*" \
         -type f \
      \( -iname "*.cpp" \
         -o -iname "*.h" \
         -o -iname "*.cc" \
         -o -iname "*.idl" \
         -o -iname "*.ipdl" \
         -o -iname "*.ipdlh" \
         -o -iname "*.mm" \) | \
    xargs -n 1 sed -i -e "s/\b$1\b/$2/g"
}

convert MOZ_DELETE '= delete'
2015-01-08 23:19:05 -05:00

105 lines
2.3 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef TRACED_TASK_COMMON_H
#define TRACED_TASK_COMMON_H
#include "base/task.h"
#include "GeckoTaskTracer.h"
#include "nsCOMPtr.h"
#include "nsThreadUtils.h"
namespace mozilla {
namespace tasktracer {
class TracedTaskCommon
{
public:
TracedTaskCommon();
virtual ~TracedTaskCommon() {}
protected:
void Init();
// Sets up the metadata on the current thread's TraceInfo for this task.
// After Run(), ClearTraceInfo is called to reset the metadata.
void SetTraceInfo();
void ClearTraceInfo();
// Its own task Id, an unique number base on its thread Id and a last unique
// task Id stored in its TraceInfo.
uint64_t mTaskId;
uint64_t mSourceEventId;
SourceEventType mSourceEventType;
};
class TracedRunnable : public TracedTaskCommon
, public nsRunnable
{
public:
NS_DECL_NSIRUNNABLE
TracedRunnable(nsIRunnable* aOriginalObj);
private:
virtual ~TracedRunnable() {}
nsCOMPtr<nsIRunnable> mOriginalObj;
};
class TracedTask : public TracedTaskCommon
, public Task
{
public:
TracedTask(Task* aOriginalObj);
~TracedTask()
{
if (mOriginalObj) {
delete mOriginalObj;
mOriginalObj = nullptr;
}
}
virtual void Run();
private:
Task* mOriginalObj;
};
// FakeTracedTask is for tracking events that are not directly dispatched from
// their parents, e.g. The timer events.
class FakeTracedTask : public TracedTaskCommon
{
public:
NS_INLINE_DECL_REFCOUNTING(FakeTracedTask)
FakeTracedTask(int* aVptr);
void BeginFakeTracedTask();
void EndFakeTracedTask();
private:
virtual ~FakeTracedTask() {}
// No copy allowed.
FakeTracedTask() = delete;
FakeTracedTask(const FakeTracedTask& aTask) = delete;
FakeTracedTask& operator=(const FakeTracedTask& aTask) = delete;
};
class AutoRunFakeTracedTask
{
public:
AutoRunFakeTracedTask(FakeTracedTask* aFakeTracedTask);
~AutoRunFakeTracedTask();
private:
nsRefPtr<FakeTracedTask> mFakeTracedTask;
};
} // namespace tasktracer
} // namespace mozilla
#endif