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: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
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 | #include "gfxPlatform.h" // for gfxPlatform |
michael@0 | 7 | #include "mozilla/Assertions.h" // for MOZ_ASSERT_HELPER2 |
michael@0 | 8 | #include "mozilla/Attributes.h" // for MOZ_FINAL |
michael@0 | 9 | #include "mozilla/Module.h" // for Module, Module::CIDEntry, etc |
michael@0 | 10 | #include "mozilla/ModuleUtils.h" |
michael@0 | 11 | #include "mozilla/mozalloc.h" // for operator new |
michael@0 | 12 | #include "nsCOMPtr.h" // for nsCOMPtr |
michael@0 | 13 | #include "nsError.h" // for NS_ERROR_NO_AGGREGATION, etc |
michael@0 | 14 | #include "nsGfxCIID.h" // for NS_FONT_ENUMERATOR_CID, etc |
michael@0 | 15 | #include "nsID.h" // for NS_DEFINE_NAMED_CID, etc |
michael@0 | 16 | #include "nsIScriptableRegion.h" // for nsIScriptableRegion |
michael@0 | 17 | #include "nsISupports.h" // for NS_DECL_ISUPPORTS, etc |
michael@0 | 18 | #include "nsScriptableRegion.h" // for nsScriptableRegion |
michael@0 | 19 | #include "nsThebesFontEnumerator.h" // for nsThebesFontEnumerator |
michael@0 | 20 | |
michael@0 | 21 | NS_GENERIC_FACTORY_CONSTRUCTOR(nsThebesFontEnumerator) |
michael@0 | 22 | |
michael@0 | 23 | static nsresult |
michael@0 | 24 | nsScriptableRegionConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult) |
michael@0 | 25 | { |
michael@0 | 26 | if (!aResult) { |
michael@0 | 27 | return NS_ERROR_NULL_POINTER; |
michael@0 | 28 | } |
michael@0 | 29 | *aResult = nullptr; |
michael@0 | 30 | if (aOuter) { |
michael@0 | 31 | return NS_ERROR_NO_AGGREGATION; |
michael@0 | 32 | } |
michael@0 | 33 | |
michael@0 | 34 | nsCOMPtr<nsIScriptableRegion> scriptableRgn = new nsScriptableRegion(); |
michael@0 | 35 | return scriptableRgn->QueryInterface(aIID, aResult); |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | NS_DEFINE_NAMED_CID(NS_FONT_ENUMERATOR_CID); |
michael@0 | 39 | NS_DEFINE_NAMED_CID(NS_SCRIPTABLE_REGION_CID); |
michael@0 | 40 | |
michael@0 | 41 | static const mozilla::Module::CIDEntry kThebesCIDs[] = { |
michael@0 | 42 | { &kNS_FONT_ENUMERATOR_CID, false, nullptr, nsThebesFontEnumeratorConstructor }, |
michael@0 | 43 | { &kNS_SCRIPTABLE_REGION_CID, false, nullptr, nsScriptableRegionConstructor }, |
michael@0 | 44 | { nullptr } |
michael@0 | 45 | }; |
michael@0 | 46 | |
michael@0 | 47 | static const mozilla::Module::ContractIDEntry kThebesContracts[] = { |
michael@0 | 48 | { "@mozilla.org/gfx/fontenumerator;1", &kNS_FONT_ENUMERATOR_CID }, |
michael@0 | 49 | { "@mozilla.org/gfx/region;1", &kNS_SCRIPTABLE_REGION_CID }, |
michael@0 | 50 | { nullptr } |
michael@0 | 51 | }; |
michael@0 | 52 | |
michael@0 | 53 | static const mozilla::Module kThebesModule = { |
michael@0 | 54 | mozilla::Module::kVersion, |
michael@0 | 55 | kThebesCIDs, |
michael@0 | 56 | kThebesContracts, |
michael@0 | 57 | nullptr, |
michael@0 | 58 | nullptr, |
michael@0 | 59 | nullptr, |
michael@0 | 60 | nullptr |
michael@0 | 61 | }; |
michael@0 | 62 | |
michael@0 | 63 | NSMODULE_DEFN(nsGfxModule) = &kThebesModule; |