Bug 1816170 - Disable perftest-on-autoland cron. r=aglavic
[gecko.git] / xpcom / base / nsCOMPtr.cpp
blobf3c3a7ad19dcc4b3e2fa04742561af9a5148f399
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "nsCOMPtr.h"
9 nsresult nsQueryInterfaceISupports::operator()(const nsIID& aIID,
10 void** aAnswer) const {
11 nsresult status;
12 if (mRawPtr) {
13 status = mRawPtr->QueryInterface(aIID, aAnswer);
14 } else {
15 status = NS_ERROR_NULL_POINTER;
18 return status;
21 nsresult nsQueryInterfaceISupportsWithError::operator()(const nsIID& aIID,
22 void** aAnswer) const {
23 nsresult status;
24 if (mRawPtr) {
25 status = mRawPtr->QueryInterface(aIID, aAnswer);
26 } else {
27 status = NS_ERROR_NULL_POINTER;
30 if (mErrorPtr) {
31 *mErrorPtr = status;
33 return status;
36 void nsCOMPtr_base::assign_with_AddRef(nsISupports* aRawPtr) {
37 if (aRawPtr) {
38 NSCAP_ADDREF(this, aRawPtr);
40 assign_assuming_AddRef(aRawPtr);
43 void nsCOMPtr_base::assign_from_qi(const nsQueryInterfaceISupports aQI,
44 const nsIID& aIID) {
45 void* newRawPtr;
46 if (NS_FAILED(aQI(aIID, &newRawPtr))) {
47 newRawPtr = nullptr;
49 assign_assuming_AddRef(static_cast<nsISupports*>(newRawPtr));
52 void nsCOMPtr_base::assign_from_qi_with_error(
53 const nsQueryInterfaceISupportsWithError& aQI, const nsIID& aIID) {
54 void* newRawPtr;
55 if (NS_FAILED(aQI(aIID, &newRawPtr))) {
56 newRawPtr = nullptr;
58 assign_assuming_AddRef(static_cast<nsISupports*>(newRawPtr));
61 void nsCOMPtr_base::assign_from_gs_cid(const nsGetServiceByCID aGS,
62 const nsIID& aIID) {
63 void* newRawPtr;
64 if (NS_FAILED(aGS(aIID, &newRawPtr))) {
65 newRawPtr = nullptr;
67 assign_assuming_AddRef(static_cast<nsISupports*>(newRawPtr));
70 void nsCOMPtr_base::assign_from_gs_cid_with_error(
71 const nsGetServiceByCIDWithError& aGS, const nsIID& aIID) {
72 void* newRawPtr;
73 if (NS_FAILED(aGS(aIID, &newRawPtr))) {
74 newRawPtr = nullptr;
76 assign_assuming_AddRef(static_cast<nsISupports*>(newRawPtr));
79 void nsCOMPtr_base::assign_from_gs_contractid(
80 const nsGetServiceByContractID aGS, const nsIID& aIID) {
81 void* newRawPtr;
82 if (NS_FAILED(aGS(aIID, &newRawPtr))) {
83 newRawPtr = nullptr;
85 assign_assuming_AddRef(static_cast<nsISupports*>(newRawPtr));
88 void nsCOMPtr_base::assign_from_gs_contractid_with_error(
89 const nsGetServiceByContractIDWithError& aGS, const nsIID& aIID) {
90 void* newRawPtr;
91 if (NS_FAILED(aGS(aIID, &newRawPtr))) {
92 newRawPtr = nullptr;
94 assign_assuming_AddRef(static_cast<nsISupports*>(newRawPtr));
97 void nsCOMPtr_base::assign_from_query_referent(
98 const nsQueryReferent& aQueryReferent, const nsIID& aIID) {
99 void* newRawPtr;
100 if (NS_FAILED(aQueryReferent(aIID, &newRawPtr))) {
101 newRawPtr = nullptr;
103 assign_assuming_AddRef(static_cast<nsISupports*>(newRawPtr));
106 void nsCOMPtr_base::assign_from_helper(const nsCOMPtr_helper& aHelper,
107 const nsIID& aIID) {
108 void* newRawPtr;
109 if (NS_FAILED(aHelper(aIID, &newRawPtr))) {
110 newRawPtr = nullptr;
112 assign_assuming_AddRef(static_cast<nsISupports*>(newRawPtr));