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: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "DrawEventRecorder.h"
7 #include "PathRecording.h"
9 namespace mozilla {
10 namespace gfx {
12 using namespace std;
14 const uint32_t kMagicInt = 0xc001feed;
16 DrawEventRecorderPrivate::DrawEventRecorderPrivate(std::ostream *aStream)
17 : mOutputStream(aStream)
18 {
19 }
21 void
22 DrawEventRecorderPrivate::RecordEvent(const RecordedEvent &aEvent)
23 {
24 WriteElement(*mOutputStream, aEvent.mType);
26 aEvent.RecordToStream(*mOutputStream);
28 Flush();
29 }
31 DrawEventRecorderFile::DrawEventRecorderFile(const char *aFilename)
32 : DrawEventRecorderPrivate(nullptr)
33 , mOutputFile(aFilename, ofstream::binary)
34 {
35 mOutputStream = &mOutputFile;
37 WriteElement(*mOutputStream, kMagicInt);
38 WriteElement(*mOutputStream, kMajorRevision);
39 WriteElement(*mOutputStream, kMinorRevision);
40 }
42 DrawEventRecorderFile::~DrawEventRecorderFile()
43 {
44 mOutputFile.close();
45 }
47 void
48 DrawEventRecorderFile::Flush()
49 {
50 mOutputFile.flush();
51 }
53 }
54 }