tools/profiler/GeckoTaskTracerImpl.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.

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_IMPL_H
michael@0 8 #define GECKO_TASK_TRACER_IMPL_H
michael@0 9
michael@0 10 #include "GeckoTaskTracer.h"
michael@0 11
michael@0 12 namespace mozilla {
michael@0 13 namespace tasktracer {
michael@0 14
michael@0 15 struct TraceInfo
michael@0 16 {
michael@0 17 TraceInfo(uint32_t aThreadId) : mCurTraceSourceId(0)
michael@0 18 , mCurTaskId(0)
michael@0 19 , mSavedCurTraceSourceId(0)
michael@0 20 , mSavedCurTaskId(0)
michael@0 21 , mCurTraceSourceType(UNKNOWN)
michael@0 22 , mSavedCurTraceSourceType(UNKNOWN)
michael@0 23 , mThreadId(aThreadId)
michael@0 24 , mLastUniqueTaskId(0)
michael@0 25 {
michael@0 26 MOZ_COUNT_CTOR(TraceInfo);
michael@0 27 }
michael@0 28
michael@0 29 ~TraceInfo() { MOZ_COUNT_DTOR(TraceInfo); }
michael@0 30
michael@0 31 uint64_t mCurTraceSourceId;
michael@0 32 uint64_t mCurTaskId;
michael@0 33 uint64_t mSavedCurTraceSourceId;
michael@0 34 uint64_t mSavedCurTaskId;
michael@0 35 SourceEventType mCurTraceSourceType;
michael@0 36 SourceEventType mSavedCurTraceSourceType;
michael@0 37 uint32_t mThreadId;
michael@0 38 uint32_t mLastUniqueTaskId;
michael@0 39 };
michael@0 40
michael@0 41 void InitTaskTracer();
michael@0 42 void ShutdownTaskTracer();
michael@0 43
michael@0 44 // Return the TraceInfo of current thread, allocate a new one if not exit.
michael@0 45 TraceInfo* GetOrCreateTraceInfo();
michael@0 46
michael@0 47 uint64_t GenNewUniqueTaskId();
michael@0 48
michael@0 49 class AutoSaveCurTraceInfo
michael@0 50 {
michael@0 51 public:
michael@0 52 AutoSaveCurTraceInfo();
michael@0 53 ~AutoSaveCurTraceInfo();
michael@0 54 };
michael@0 55
michael@0 56 void SetCurTraceInfo(uint64_t aSourceEventId, uint64_t aParentTaskId,
michael@0 57 SourceEventType aSourceEventType);
michael@0 58
michael@0 59 void GetCurTraceInfo(uint64_t* aOutSourceEventId, uint64_t* aOutParentTaskId,
michael@0 60 SourceEventType* aOutSourceEventType);
michael@0 61
michael@0 62 /**
michael@0 63 * Logging functions of different trace actions.
michael@0 64 */
michael@0 65 enum ActionType {
michael@0 66 ACTION_DISPATCH = 0,
michael@0 67 ACTION_BEGIN,
michael@0 68 ACTION_END,
michael@0 69 ACTION_ADD_LABEL,
michael@0 70 ACTION_GET_VTABLE
michael@0 71 };
michael@0 72
michael@0 73 void LogDispatch(uint64_t aTaskId, uint64_t aParentTaskId,
michael@0 74 uint64_t aSourceEventId, SourceEventType aSourceEventType);
michael@0 75
michael@0 76 void LogBegin(uint64_t aTaskId, uint64_t aSourceEventId);
michael@0 77
michael@0 78 void LogEnd(uint64_t aTaskId, uint64_t aSourceEventId);
michael@0 79
michael@0 80 void LogVirtualTablePtr(uint64_t aTaskId, uint64_t aSourceEventId, int* aVptr);
michael@0 81
michael@0 82 } // namespace mozilla
michael@0 83 } // namespace tasktracer
michael@0 84
michael@0 85 #endif

mercurial