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: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
michael@0 | 2 | * vim: sw=2 ts=8 et : |
michael@0 | 3 | */ |
michael@0 | 4 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 7 | |
michael@0 | 8 | #ifndef mozilla_layers_ShadowLayerUtilsX11_h |
michael@0 | 9 | #define mozilla_layers_ShadowLayerUtilsX11_h |
michael@0 | 10 | |
michael@0 | 11 | #include "ipc/IPCMessageUtils.h" |
michael@0 | 12 | #include "mozilla/GfxMessageUtils.h" |
michael@0 | 13 | #include "nsCOMPtr.h" // for already_AddRefed |
michael@0 | 14 | |
michael@0 | 15 | #define MOZ_HAVE_SURFACEDESCRIPTORX11 |
michael@0 | 16 | #define MOZ_HAVE_PLATFORM_SPECIFIC_LAYER_BUFFERS |
michael@0 | 17 | |
michael@0 | 18 | typedef unsigned long XID; |
michael@0 | 19 | typedef XID Drawable; |
michael@0 | 20 | |
michael@0 | 21 | class gfxXlibSurface; |
michael@0 | 22 | |
michael@0 | 23 | namespace IPC { |
michael@0 | 24 | class Message; |
michael@0 | 25 | } |
michael@0 | 26 | |
michael@0 | 27 | namespace mozilla { |
michael@0 | 28 | namespace layers { |
michael@0 | 29 | |
michael@0 | 30 | struct SurfaceDescriptorX11 { |
michael@0 | 31 | SurfaceDescriptorX11() |
michael@0 | 32 | { } |
michael@0 | 33 | |
michael@0 | 34 | SurfaceDescriptorX11(gfxXlibSurface* aSurf); |
michael@0 | 35 | |
michael@0 | 36 | SurfaceDescriptorX11(Drawable aDrawable, XID aFormatID, |
michael@0 | 37 | const gfx::IntSize& aSize); |
michael@0 | 38 | |
michael@0 | 39 | // Default copy ctor and operator= are OK |
michael@0 | 40 | |
michael@0 | 41 | bool operator==(const SurfaceDescriptorX11& aOther) const { |
michael@0 | 42 | // Define == as two descriptors having the same XID for now, |
michael@0 | 43 | // ignoring size and render format. If the two indeed refer to |
michael@0 | 44 | // the same valid XID, then size/format are "actually" the same |
michael@0 | 45 | // anyway, regardless of the values of the fields in |
michael@0 | 46 | // SurfaceDescriptorX11. |
michael@0 | 47 | return mId == aOther.mId; |
michael@0 | 48 | } |
michael@0 | 49 | |
michael@0 | 50 | already_AddRefed<gfxXlibSurface> OpenForeign() const; |
michael@0 | 51 | |
michael@0 | 52 | Drawable mId; |
michael@0 | 53 | XID mFormat; // either a PictFormat or VisualID |
michael@0 | 54 | gfx::IntSize mSize; |
michael@0 | 55 | }; |
michael@0 | 56 | |
michael@0 | 57 | } // namespace layers |
michael@0 | 58 | } // namespace mozilla |
michael@0 | 59 | |
michael@0 | 60 | namespace IPC { |
michael@0 | 61 | |
michael@0 | 62 | template <> |
michael@0 | 63 | struct ParamTraits<mozilla::layers::SurfaceDescriptorX11> { |
michael@0 | 64 | typedef mozilla::layers::SurfaceDescriptorX11 paramType; |
michael@0 | 65 | |
michael@0 | 66 | static void Write(Message* aMsg, const paramType& aParam) { |
michael@0 | 67 | WriteParam(aMsg, aParam.mId); |
michael@0 | 68 | WriteParam(aMsg, aParam.mSize); |
michael@0 | 69 | WriteParam(aMsg, aParam.mFormat); |
michael@0 | 70 | } |
michael@0 | 71 | |
michael@0 | 72 | static bool Read(const Message* aMsg, void** aIter, paramType* aResult) { |
michael@0 | 73 | return (ReadParam(aMsg, aIter, &aResult->mId) && |
michael@0 | 74 | ReadParam(aMsg, aIter, &aResult->mSize) && |
michael@0 | 75 | ReadParam(aMsg, aIter, &aResult->mFormat)); |
michael@0 | 76 | } |
michael@0 | 77 | }; |
michael@0 | 78 | |
michael@0 | 79 | } // namespace IPC |
michael@0 | 80 | |
michael@0 | 81 | #endif // mozilla_layers_ShadowLayerUtilsX11_h |