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 et tw=79: */
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 file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_RootedDictionary_h__
8 #define mozilla_dom_RootedDictionary_h__
10 #include "mozilla/GuardObjects.h"
11 #include "mozilla/dom/Nullable.h"
12 #include "jsapi.h"
14 namespace mozilla {
15 namespace dom {
17 template<typename T>
18 class MOZ_STACK_CLASS RootedDictionary : public T,
19 private JS::CustomAutoRooter
20 {
21 public:
22 RootedDictionary(JSContext* cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) :
23 T(),
24 JS::CustomAutoRooter(cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT)
25 {
26 }
28 virtual void trace(JSTracer *trc) MOZ_OVERRIDE
29 {
30 this->TraceDictionary(trc);
31 }
32 };
34 template<typename T>
35 class MOZ_STACK_CLASS NullableRootedDictionary : public Nullable<T>,
36 private JS::CustomAutoRooter
37 {
38 public:
39 NullableRootedDictionary(JSContext* cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) :
40 Nullable<T>(),
41 JS::CustomAutoRooter(cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT)
42 {
43 }
45 virtual void trace(JSTracer *trc) MOZ_OVERRIDE
46 {
47 if (!this->IsNull()) {
48 this->Value().TraceDictionary(trc);
49 }
50 }
51 };
53 } // namespace dom
54 } // namespace mozilla
56 #endif /* mozilla_dom_RootedDictionary_h__ */