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