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.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef gfxCrashReporterUtils_h__ |
michael@0 | 7 | #define gfxCrashReporterUtils_h__ |
michael@0 | 8 | |
michael@0 | 9 | #include "gfxCore.h" |
michael@0 | 10 | |
michael@0 | 11 | namespace mozilla { |
michael@0 | 12 | |
michael@0 | 13 | /** \class ScopedGfxFeatureReporter |
michael@0 | 14 | * |
michael@0 | 15 | * On creation, adds "FeatureName?" to AppNotes |
michael@0 | 16 | * On destruction, adds "FeatureName-", or "FeatureName+" if you called SetSuccessful(). |
michael@0 | 17 | * |
michael@0 | 18 | * Any such string is added at most once to AppNotes, and is subsequently skipped. |
michael@0 | 19 | * |
michael@0 | 20 | * This ScopedGfxFeatureReporter class is designed to be fool-proof to use in functions that |
michael@0 | 21 | * have many exit points. We don't want to encourage having function with many exit points. |
michael@0 | 22 | * It just happens that our graphics features initialization functions are like that. |
michael@0 | 23 | */ |
michael@0 | 24 | class NS_GFX ScopedGfxFeatureReporter |
michael@0 | 25 | { |
michael@0 | 26 | public: |
michael@0 | 27 | ScopedGfxFeatureReporter(const char *aFeature, bool force = false) |
michael@0 | 28 | : mFeature(aFeature), mStatusChar('-') |
michael@0 | 29 | { |
michael@0 | 30 | WriteAppNote(force ? '!' : '?'); |
michael@0 | 31 | } |
michael@0 | 32 | ~ScopedGfxFeatureReporter() { |
michael@0 | 33 | WriteAppNote(mStatusChar); |
michael@0 | 34 | } |
michael@0 | 35 | void SetSuccessful() { mStatusChar = '+'; } |
michael@0 | 36 | |
michael@0 | 37 | class AppNoteWritingRunnable; |
michael@0 | 38 | |
michael@0 | 39 | protected: |
michael@0 | 40 | const char *mFeature; |
michael@0 | 41 | char mStatusChar; |
michael@0 | 42 | |
michael@0 | 43 | private: |
michael@0 | 44 | void WriteAppNote(char statusChar); |
michael@0 | 45 | }; |
michael@0 | 46 | |
michael@0 | 47 | } // end namespace mozilla |
michael@0 | 48 | |
michael@0 | 49 | #endif // gfxCrashReporterUtils_h__ |