tools/profiler/GeckoTaskTracer.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef GECKO_TASK_TRACER_H
michael@0 8 #define GECKO_TASK_TRACER_H
michael@0 9
michael@0 10 #include "nsCOMPtr.h"
michael@0 11
michael@0 12 /**
michael@0 13 * TaskTracer provides a way to trace the correlation between different tasks
michael@0 14 * across threads and processes. Unlike sampling based profilers, TaskTracer can
michael@0 15 * tell you where a task is dispatched from, what its original source was, how
michael@0 16 * long it waited in the event queue, and how long it took to execute.
michael@0 17 *
michael@0 18 * Source Events are usually some kinds of I/O events we're interested in, such
michael@0 19 * as touch events, timer events, network events, etc. When a source event is
michael@0 20 * created, TaskTracer records the entire chain of Tasks and nsRunnables as they
michael@0 21 * are dispatched to different threads and processes. It records latency,
michael@0 22 * execution time, etc. for each Task and nsRunnable that chains back to the
michael@0 23 * original source event.
michael@0 24 */
michael@0 25
michael@0 26 class Task;
michael@0 27 class nsIRunnable;
michael@0 28
michael@0 29 namespace mozilla {
michael@0 30 namespace tasktracer {
michael@0 31
michael@0 32 class FakeTracedTask;
michael@0 33
michael@0 34 enum SourceEventType {
michael@0 35 UNKNOWN = 0,
michael@0 36 TOUCH,
michael@0 37 MOUSE,
michael@0 38 KEY,
michael@0 39 BLUETOOTH,
michael@0 40 UNIXSOCKET,
michael@0 41 WIFI
michael@0 42 };
michael@0 43
michael@0 44 class AutoSourceEvent
michael@0 45 {
michael@0 46 public:
michael@0 47 AutoSourceEvent(SourceEventType aType);
michael@0 48 ~AutoSourceEvent();
michael@0 49 };
michael@0 50
michael@0 51 // Add a label to the currently running task, aFormat is the message to log,
michael@0 52 // followed by corresponding parameters.
michael@0 53 void AddLabel(const char* aFormat, ...);
michael@0 54
michael@0 55 /**
michael@0 56 * Internal functions.
michael@0 57 */
michael@0 58
michael@0 59 Task* CreateTracedTask(Task* aTask);
michael@0 60
michael@0 61 already_AddRefed<nsIRunnable> CreateTracedRunnable(nsIRunnable* aRunnable);
michael@0 62
michael@0 63 FakeTracedTask* CreateFakeTracedTask(int* aVptr);
michael@0 64
michael@0 65 // Free the TraceInfo allocated on a thread's TLS. Currently we are wrapping
michael@0 66 // tasks running on nsThreads and base::thread, so FreeTraceInfo is called at
michael@0 67 // where nsThread and base::thread release themselves.
michael@0 68 void FreeTraceInfo();
michael@0 69
michael@0 70 } // namespace tasktracer
michael@0 71 } // namespace mozilla.
michael@0 72
michael@0 73 #endif

mercurial