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: set ts=8 sts=2 et sw=2 tw=80: */ |
michael@0 | 3 | /* This code is made available to you under your choice of the following sets |
michael@0 | 4 | * of licensing terms: |
michael@0 | 5 | */ |
michael@0 | 6 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 7 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 8 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
michael@0 | 9 | */ |
michael@0 | 10 | /* Copyright 2014 Mozilla Contributors |
michael@0 | 11 | * |
michael@0 | 12 | * Licensed under the Apache License, Version 2.0 (the "License"); |
michael@0 | 13 | * you may not use this file except in compliance with the License. |
michael@0 | 14 | * You may obtain a copy of the License at |
michael@0 | 15 | * |
michael@0 | 16 | * http://www.apache.org/licenses/LICENSE-2.0 |
michael@0 | 17 | * |
michael@0 | 18 | * Unless required by applicable law or agreed to in writing, software |
michael@0 | 19 | * distributed under the License is distributed on an "AS IS" BASIS, |
michael@0 | 20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
michael@0 | 21 | * See the License for the specific language governing permissions and |
michael@0 | 22 | * limitations under the License. |
michael@0 | 23 | */ |
michael@0 | 24 | #ifndef mozilla_pkix__pkixgtest_h |
michael@0 | 25 | #define mozilla_pkix__pkixgtest_h |
michael@0 | 26 | |
michael@0 | 27 | #include <ostream> |
michael@0 | 28 | |
michael@0 | 29 | #include "gtest/gtest.h" |
michael@0 | 30 | #include "pkixutil.h" |
michael@0 | 31 | #include "prerror.h" |
michael@0 | 32 | #include "stdint.h" |
michael@0 | 33 | |
michael@0 | 34 | namespace mozilla { namespace pkix { namespace test { |
michael@0 | 35 | |
michael@0 | 36 | class ResultWithPRErrorCode |
michael@0 | 37 | { |
michael@0 | 38 | public: |
michael@0 | 39 | ResultWithPRErrorCode(Result rv, PRErrorCode errorCode) |
michael@0 | 40 | : mRv(rv) |
michael@0 | 41 | , mErrorCode(errorCode) |
michael@0 | 42 | { |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | explicit ResultWithPRErrorCode(Result rv) |
michael@0 | 46 | : mRv(rv) |
michael@0 | 47 | , mErrorCode(rv == Success ? 0 : PR_GetError()) |
michael@0 | 48 | { |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | bool operator==(const ResultWithPRErrorCode& other) const |
michael@0 | 52 | { |
michael@0 | 53 | return mRv == other.mRv && mErrorCode == other.mErrorCode; |
michael@0 | 54 | } |
michael@0 | 55 | |
michael@0 | 56 | private: |
michael@0 | 57 | const Result mRv; |
michael@0 | 58 | const PRErrorCode mErrorCode; |
michael@0 | 59 | |
michael@0 | 60 | friend std::ostream& operator<<(std::ostream& os, |
michael@0 | 61 | const ResultWithPRErrorCode & value); |
michael@0 | 62 | |
michael@0 | 63 | void operator=(const ResultWithPRErrorCode&) /*= delete*/; |
michael@0 | 64 | }; |
michael@0 | 65 | |
michael@0 | 66 | ::std::ostream& operator<<(::std::ostream&, const ResultWithPRErrorCode &); |
michael@0 | 67 | |
michael@0 | 68 | #define ASSERT_Success(rv) \ |
michael@0 | 69 | ASSERT_EQ(::mozilla::pkix::test::ResultWithPRErrorCode( \ |
michael@0 | 70 | ::mozilla::pkix::Success, 0), \ |
michael@0 | 71 | ::mozilla::pkix::test::ResultWithPRErrorCode(rv)) |
michael@0 | 72 | #define EXPECT_Success(rv) \ |
michael@0 | 73 | EXPECT_EQ(::mozilla::pkix::test::ResultWithPRErrorCode( \ |
michael@0 | 74 | ::mozilla::pkix::Success, 0), \ |
michael@0 | 75 | ::mozilla::pkix::test::ResultWithPRErrorCode(rv)) |
michael@0 | 76 | |
michael@0 | 77 | #define ASSERT_RecoverableError(expectedError, rv) \ |
michael@0 | 78 | ASSERT_EQ(::mozilla::pkix::test::ResultWithPRErrorCode( \ |
michael@0 | 79 | ::mozilla::pkix::RecoverableError, expectedError), \ |
michael@0 | 80 | ::mozilla::pkix::test::ResultWithPRErrorCode(rv)) |
michael@0 | 81 | #define EXPECT_RecoverableError(expectedError, rv) \ |
michael@0 | 82 | EXPECT_EQ(::mozilla::pkix::test::ResultWithPRErrorCode( \ |
michael@0 | 83 | ::mozilla::pkix::RecoverableError, expectedError), \ |
michael@0 | 84 | ::mozilla::pkix::test::ResultWithPRErrorCode(rv)) |
michael@0 | 85 | |
michael@0 | 86 | #define ASSERT_FatalError(expectedError, rv) \ |
michael@0 | 87 | ASSERT_EQ(::mozilla::pkix::test::ResultWithPRErrorCode( \ |
michael@0 | 88 | ::mozilla::pkix::FatalError, expectedError), \ |
michael@0 | 89 | ::mozilla::pkix::test::ResultWithPRErrorCode(rv)) |
michael@0 | 90 | #define EXPECT_FatalError(expectedError, rv) \ |
michael@0 | 91 | EXPECT_EQ(::mozilla::pkix::test::ResultWithPRErrorCode( \ |
michael@0 | 92 | ::mozilla::pkix::FatalError, expectedError), \ |
michael@0 | 93 | ::mozilla::pkix::test::ResultWithPRErrorCode(rv)) |
michael@0 | 94 | |
michael@0 | 95 | } } } // namespace mozilla::pkix::test |
michael@0 | 96 | |
michael@0 | 97 | #endif // mozilla_pkix__pkixgtest_h |