Thu, 15 Jan 2015 15:59:08 +0100
Implement a real Private Browsing Mode condition by changing the API/ABI;
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: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
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 timecard_h__ |
michael@0 | 8 | #define timecard_h__ |
michael@0 | 9 | |
michael@0 | 10 | #include <stdlib.h> |
michael@0 | 11 | #include "prtime.h" |
michael@0 | 12 | |
michael@0 | 13 | #ifdef __cplusplus |
michael@0 | 14 | extern "C" { |
michael@0 | 15 | #endif |
michael@0 | 16 | |
michael@0 | 17 | #define STAMP_TIMECARD(card,event) \ |
michael@0 | 18 | do { \ |
michael@0 | 19 | if (card) { \ |
michael@0 | 20 | stamp_timecard((card), (event), __FILE__, __LINE__, __FUNCTION__); \ |
michael@0 | 21 | } \ |
michael@0 | 22 | } while (0) |
michael@0 | 23 | |
michael@0 | 24 | #define TIMECARD_INITIAL_TABLE_SIZE 16 |
michael@0 | 25 | |
michael@0 | 26 | /* |
michael@0 | 27 | * The "const char *" members of this structure point to static strings. |
michael@0 | 28 | * We do not own them, and should not attempt to deallocate them. |
michael@0 | 29 | */ |
michael@0 | 30 | |
michael@0 | 31 | typedef struct { |
michael@0 | 32 | PRTime timestamp; |
michael@0 | 33 | const char *event; |
michael@0 | 34 | const char *file; |
michael@0 | 35 | unsigned int line; |
michael@0 | 36 | const char *function; |
michael@0 | 37 | } TimecardEntry; |
michael@0 | 38 | |
michael@0 | 39 | typedef struct Timecard { |
michael@0 | 40 | size_t curr_entry; |
michael@0 | 41 | size_t entries_allocated; |
michael@0 | 42 | TimecardEntry *entries; |
michael@0 | 43 | PRTime start_time; |
michael@0 | 44 | } Timecard; |
michael@0 | 45 | |
michael@0 | 46 | /** |
michael@0 | 47 | * Creates a new Timecard structure for tracking events. |
michael@0 | 48 | */ |
michael@0 | 49 | Timecard * |
michael@0 | 50 | create_timecard(); |
michael@0 | 51 | |
michael@0 | 52 | /** |
michael@0 | 53 | * Frees the memory associated with a timecard. After returning, the |
michael@0 | 54 | * timecard pointed to by tc is no longer valid. |
michael@0 | 55 | */ |
michael@0 | 56 | void |
michael@0 | 57 | destroy_timecard(Timecard *tc); |
michael@0 | 58 | |
michael@0 | 59 | /** |
michael@0 | 60 | * Records a new event in the indicated timecard. This should not be |
michael@0 | 61 | * called directly; code should instead use the STAMP_TIMECARD macro, |
michael@0 | 62 | * above. |
michael@0 | 63 | */ |
michael@0 | 64 | void |
michael@0 | 65 | stamp_timecard(Timecard *tc, |
michael@0 | 66 | const char *event, |
michael@0 | 67 | const char *file, |
michael@0 | 68 | unsigned int line, |
michael@0 | 69 | const char *function); |
michael@0 | 70 | |
michael@0 | 71 | /** |
michael@0 | 72 | * Formats and outputs the contents of a timecard onto stdout. |
michael@0 | 73 | */ |
michael@0 | 74 | void |
michael@0 | 75 | print_timecard(Timecard *tc); |
michael@0 | 76 | |
michael@0 | 77 | #ifdef __cplusplus |
michael@0 | 78 | } |
michael@0 | 79 | #endif |
michael@0 | 80 | |
michael@0 | 81 | #endif |