Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
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 "nsCOMPtr.h" |
michael@0 | 7 | |
michael@0 | 8 | nsresult |
michael@0 | 9 | nsQueryInterface::operator()( const nsIID& aIID, void** answer ) const |
michael@0 | 10 | { |
michael@0 | 11 | nsresult status; |
michael@0 | 12 | if ( mRawPtr ) |
michael@0 | 13 | { |
michael@0 | 14 | status = mRawPtr->QueryInterface(aIID, answer); |
michael@0 | 15 | #ifdef NSCAP_FEATURE_TEST_NONNULL_QUERY_SUCCEEDS |
michael@0 | 16 | NS_ASSERTION(NS_SUCCEEDED(status), "interface not found---were you expecting that?"); |
michael@0 | 17 | #endif |
michael@0 | 18 | } |
michael@0 | 19 | else |
michael@0 | 20 | status = NS_ERROR_NULL_POINTER; |
michael@0 | 21 | |
michael@0 | 22 | return status; |
michael@0 | 23 | } |
michael@0 | 24 | |
michael@0 | 25 | nsresult |
michael@0 | 26 | nsQueryInterfaceWithError::operator()( const nsIID& aIID, void** answer ) const |
michael@0 | 27 | { |
michael@0 | 28 | nsresult status; |
michael@0 | 29 | if ( mRawPtr ) |
michael@0 | 30 | { |
michael@0 | 31 | status = mRawPtr->QueryInterface(aIID, answer); |
michael@0 | 32 | #ifdef NSCAP_FEATURE_TEST_NONNULL_QUERY_SUCCEEDS |
michael@0 | 33 | NS_ASSERTION(NS_SUCCEEDED(status), "interface not found---were you expecting that?"); |
michael@0 | 34 | #endif |
michael@0 | 35 | } |
michael@0 | 36 | else |
michael@0 | 37 | status = NS_ERROR_NULL_POINTER; |
michael@0 | 38 | |
michael@0 | 39 | if ( mErrorPtr ) |
michael@0 | 40 | *mErrorPtr = status; |
michael@0 | 41 | return status; |
michael@0 | 42 | } |
michael@0 | 43 | |
michael@0 | 44 | void |
michael@0 | 45 | nsCOMPtr_base::assign_with_AddRef( nsISupports* rawPtr ) |
michael@0 | 46 | { |
michael@0 | 47 | if ( rawPtr ) |
michael@0 | 48 | NSCAP_ADDREF(this, rawPtr); |
michael@0 | 49 | assign_assuming_AddRef(rawPtr); |
michael@0 | 50 | } |
michael@0 | 51 | |
michael@0 | 52 | void |
michael@0 | 53 | nsCOMPtr_base::assign_from_qi( const nsQueryInterface qi, const nsIID& iid ) |
michael@0 | 54 | { |
michael@0 | 55 | void* newRawPtr; |
michael@0 | 56 | if ( NS_FAILED( qi(iid, &newRawPtr) ) ) |
michael@0 | 57 | newRawPtr = 0; |
michael@0 | 58 | assign_assuming_AddRef(static_cast<nsISupports*>(newRawPtr)); |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | void |
michael@0 | 62 | nsCOMPtr_base::assign_from_qi_with_error( const nsQueryInterfaceWithError& qi, const nsIID& iid ) |
michael@0 | 63 | { |
michael@0 | 64 | void* newRawPtr; |
michael@0 | 65 | if ( NS_FAILED( qi(iid, &newRawPtr) ) ) |
michael@0 | 66 | newRawPtr = 0; |
michael@0 | 67 | assign_assuming_AddRef(static_cast<nsISupports*>(newRawPtr)); |
michael@0 | 68 | } |
michael@0 | 69 | |
michael@0 | 70 | void |
michael@0 | 71 | nsCOMPtr_base::assign_from_gs_cid( const nsGetServiceByCID gs, const nsIID& iid ) |
michael@0 | 72 | { |
michael@0 | 73 | void* newRawPtr; |
michael@0 | 74 | if ( NS_FAILED( gs(iid, &newRawPtr) ) ) |
michael@0 | 75 | newRawPtr = 0; |
michael@0 | 76 | assign_assuming_AddRef(static_cast<nsISupports*>(newRawPtr)); |
michael@0 | 77 | } |
michael@0 | 78 | |
michael@0 | 79 | void |
michael@0 | 80 | nsCOMPtr_base::assign_from_gs_cid_with_error( const nsGetServiceByCIDWithError& gs, const nsIID& iid ) |
michael@0 | 81 | { |
michael@0 | 82 | void* newRawPtr; |
michael@0 | 83 | if ( NS_FAILED( gs(iid, &newRawPtr) ) ) |
michael@0 | 84 | newRawPtr = 0; |
michael@0 | 85 | assign_assuming_AddRef(static_cast<nsISupports*>(newRawPtr)); |
michael@0 | 86 | } |
michael@0 | 87 | |
michael@0 | 88 | void |
michael@0 | 89 | nsCOMPtr_base::assign_from_gs_contractid( const nsGetServiceByContractID gs, const nsIID& iid ) |
michael@0 | 90 | { |
michael@0 | 91 | void* newRawPtr; |
michael@0 | 92 | if ( NS_FAILED( gs(iid, &newRawPtr) ) ) |
michael@0 | 93 | newRawPtr = 0; |
michael@0 | 94 | assign_assuming_AddRef(static_cast<nsISupports*>(newRawPtr)); |
michael@0 | 95 | } |
michael@0 | 96 | |
michael@0 | 97 | void |
michael@0 | 98 | nsCOMPtr_base::assign_from_gs_contractid_with_error( const nsGetServiceByContractIDWithError& gs, const nsIID& iid ) |
michael@0 | 99 | { |
michael@0 | 100 | void* newRawPtr; |
michael@0 | 101 | if ( NS_FAILED( gs(iid, &newRawPtr) ) ) |
michael@0 | 102 | newRawPtr = 0; |
michael@0 | 103 | assign_assuming_AddRef(static_cast<nsISupports*>(newRawPtr)); |
michael@0 | 104 | } |
michael@0 | 105 | |
michael@0 | 106 | void |
michael@0 | 107 | nsCOMPtr_base::assign_from_helper( const nsCOMPtr_helper& helper, const nsIID& iid ) |
michael@0 | 108 | { |
michael@0 | 109 | void* newRawPtr; |
michael@0 | 110 | if ( NS_FAILED( helper(iid, &newRawPtr) ) ) |
michael@0 | 111 | newRawPtr = 0; |
michael@0 | 112 | assign_assuming_AddRef(static_cast<nsISupports*>(newRawPtr)); |
michael@0 | 113 | } |
michael@0 | 114 | |
michael@0 | 115 | void** |
michael@0 | 116 | nsCOMPtr_base::begin_assignment() |
michael@0 | 117 | { |
michael@0 | 118 | assign_assuming_AddRef(0); |
michael@0 | 119 | return reinterpret_cast<void**>(&mRawPtr); |
michael@0 | 120 | } |