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 | /* vim: set ts=2 et sw=2 tw=80: */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
michael@0 | 5 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #include "EnumVariant.h" |
michael@0 | 8 | |
michael@0 | 9 | using namespace mozilla; |
michael@0 | 10 | using namespace mozilla::a11y; |
michael@0 | 11 | |
michael@0 | 12 | //////////////////////////////////////////////////////////////////////////////// |
michael@0 | 13 | // ChildrenEnumVariant |
michael@0 | 14 | //////////////////////////////////////////////////////////////////////////////// |
michael@0 | 15 | |
michael@0 | 16 | IMPL_IUNKNOWN_QUERY_HEAD(ChildrenEnumVariant) |
michael@0 | 17 | IMPL_IUNKNOWN_QUERY_IFACE(IEnumVARIANT); |
michael@0 | 18 | IMPL_IUNKNOWN_QUERY_IFACE(IUnknown); |
michael@0 | 19 | IMPL_IUNKNOWN_QUERY_AGGR_COND(mAnchorAcc, !mAnchorAcc->IsDefunct()); |
michael@0 | 20 | IMPL_IUNKNOWN_QUERY_TAIL |
michael@0 | 21 | |
michael@0 | 22 | STDMETHODIMP |
michael@0 | 23 | ChildrenEnumVariant::Next(ULONG aCount, VARIANT FAR* aItems, |
michael@0 | 24 | ULONG FAR* aCountFetched) |
michael@0 | 25 | { |
michael@0 | 26 | A11Y_TRYBLOCK_BEGIN |
michael@0 | 27 | |
michael@0 | 28 | if (!aItems || !aCountFetched) |
michael@0 | 29 | return E_INVALIDARG; |
michael@0 | 30 | |
michael@0 | 31 | *aCountFetched = 0; |
michael@0 | 32 | |
michael@0 | 33 | if (mAnchorAcc->IsDefunct() || mAnchorAcc->GetChildAt(mCurIndex) != mCurAcc) |
michael@0 | 34 | return CO_E_OBJNOTCONNECTED; |
michael@0 | 35 | |
michael@0 | 36 | ULONG countFetched = 0; |
michael@0 | 37 | for (; mCurAcc && countFetched < aCount; countFetched++) { |
michael@0 | 38 | VariantInit(aItems + countFetched); |
michael@0 | 39 | aItems[countFetched].pdispVal = AccessibleWrap::NativeAccessible(mCurAcc); |
michael@0 | 40 | aItems[countFetched].vt = VT_DISPATCH; |
michael@0 | 41 | |
michael@0 | 42 | mCurIndex++; |
michael@0 | 43 | mCurAcc = mAnchorAcc->GetChildAt(mCurIndex); |
michael@0 | 44 | } |
michael@0 | 45 | |
michael@0 | 46 | (*aCountFetched) = countFetched; |
michael@0 | 47 | |
michael@0 | 48 | return countFetched < aCount ? S_FALSE : S_OK; |
michael@0 | 49 | |
michael@0 | 50 | A11Y_TRYBLOCK_END |
michael@0 | 51 | } |
michael@0 | 52 | |
michael@0 | 53 | STDMETHODIMP |
michael@0 | 54 | ChildrenEnumVariant::Skip(ULONG aCount) |
michael@0 | 55 | { |
michael@0 | 56 | A11Y_TRYBLOCK_BEGIN |
michael@0 | 57 | |
michael@0 | 58 | if (mAnchorAcc->IsDefunct() || mAnchorAcc->GetChildAt(mCurIndex) != mCurAcc) |
michael@0 | 59 | return CO_E_OBJNOTCONNECTED; |
michael@0 | 60 | |
michael@0 | 61 | mCurIndex += aCount; |
michael@0 | 62 | mCurAcc = mAnchorAcc->GetChildAt(mCurIndex); |
michael@0 | 63 | |
michael@0 | 64 | return mCurAcc ? S_OK : S_FALSE; |
michael@0 | 65 | |
michael@0 | 66 | A11Y_TRYBLOCK_END |
michael@0 | 67 | } |
michael@0 | 68 | |
michael@0 | 69 | STDMETHODIMP |
michael@0 | 70 | ChildrenEnumVariant::Reset() |
michael@0 | 71 | { |
michael@0 | 72 | A11Y_TRYBLOCK_BEGIN |
michael@0 | 73 | |
michael@0 | 74 | if (mAnchorAcc->IsDefunct()) |
michael@0 | 75 | return CO_E_OBJNOTCONNECTED; |
michael@0 | 76 | |
michael@0 | 77 | mCurIndex = 0; |
michael@0 | 78 | mCurAcc = mAnchorAcc->GetChildAt(0); |
michael@0 | 79 | |
michael@0 | 80 | return S_OK; |
michael@0 | 81 | |
michael@0 | 82 | A11Y_TRYBLOCK_END |
michael@0 | 83 | } |
michael@0 | 84 | |
michael@0 | 85 | STDMETHODIMP |
michael@0 | 86 | ChildrenEnumVariant::Clone(IEnumVARIANT** aEnumVariant) |
michael@0 | 87 | { |
michael@0 | 88 | A11Y_TRYBLOCK_BEGIN |
michael@0 | 89 | |
michael@0 | 90 | if (!aEnumVariant) |
michael@0 | 91 | return E_INVALIDARG; |
michael@0 | 92 | |
michael@0 | 93 | *aEnumVariant = new ChildrenEnumVariant(*this); |
michael@0 | 94 | (*aEnumVariant)->AddRef(); |
michael@0 | 95 | |
michael@0 | 96 | return S_OK; |
michael@0 | 97 | |
michael@0 | 98 | A11Y_TRYBLOCK_END |
michael@0 | 99 | } |