tools/profiler/GeckoTaskTracer.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

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

mercurial