tools/profiler/GeckoTaskTracer.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/tools/profiler/GeckoTaskTracer.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,73 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* vim:set ts=2 sw=2 sts=2 et cindent: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef GECKO_TASK_TRACER_H
    1.11 +#define GECKO_TASK_TRACER_H
    1.12 +
    1.13 +#include "nsCOMPtr.h"
    1.14 +
    1.15 +/**
    1.16 + * TaskTracer provides a way to trace the correlation between different tasks
    1.17 + * across threads and processes. Unlike sampling based profilers, TaskTracer can
    1.18 + * tell you where a task is dispatched from, what its original source was, how
    1.19 + * long it waited in the event queue, and how long it took to execute.
    1.20 + *
    1.21 + * Source Events are usually some kinds of I/O events we're interested in, such
    1.22 + * as touch events, timer events, network events, etc. When a source event is
    1.23 + * created, TaskTracer records the entire chain of Tasks and nsRunnables as they
    1.24 + * are dispatched to different threads and processes. It records latency,
    1.25 + * execution time, etc. for each Task and nsRunnable that chains back to the
    1.26 + * original source event.
    1.27 + */
    1.28 +
    1.29 +class Task;
    1.30 +class nsIRunnable;
    1.31 +
    1.32 +namespace mozilla {
    1.33 +namespace tasktracer {
    1.34 +
    1.35 +class FakeTracedTask;
    1.36 +
    1.37 +enum SourceEventType {
    1.38 +  UNKNOWN = 0,
    1.39 +  TOUCH,
    1.40 +  MOUSE,
    1.41 +  KEY,
    1.42 +  BLUETOOTH,
    1.43 +  UNIXSOCKET,
    1.44 +  WIFI
    1.45 +};
    1.46 +
    1.47 +class AutoSourceEvent
    1.48 +{
    1.49 +public:
    1.50 +  AutoSourceEvent(SourceEventType aType);
    1.51 +  ~AutoSourceEvent();
    1.52 +};
    1.53 +
    1.54 +// Add a label to the currently running task, aFormat is the message to log,
    1.55 +// followed by corresponding parameters.
    1.56 +void AddLabel(const char* aFormat, ...);
    1.57 +
    1.58 +/**
    1.59 + * Internal functions.
    1.60 + */
    1.61 +
    1.62 +Task* CreateTracedTask(Task* aTask);
    1.63 +
    1.64 +already_AddRefed<nsIRunnable> CreateTracedRunnable(nsIRunnable* aRunnable);
    1.65 +
    1.66 +FakeTracedTask* CreateFakeTracedTask(int* aVptr);
    1.67 +
    1.68 +// Free the TraceInfo allocated on a thread's TLS. Currently we are wrapping
    1.69 +// tasks running on nsThreads and base::thread, so FreeTraceInfo is called at
    1.70 +// where nsThread and base::thread release themselves.
    1.71 +void FreeTraceInfo();
    1.72 +
    1.73 +} // namespace tasktracer
    1.74 +} // namespace mozilla.
    1.75 +
    1.76 +#endif

mercurial