2014-06-30 08:39:45 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#include "nsIInterfaceRequestor.h"
|
|
|
|
#include "nsIInterfaceRequestorUtils.h"
|
|
|
|
|
|
|
|
nsresult
|
2014-06-26 18:35:39 -07:00
|
|
|
nsGetInterface::operator()(const nsIID& aIID, void** aInstancePtr) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nsresult status;
|
|
|
|
|
2014-06-26 18:35:39 -07:00
|
|
|
if (mSource) {
|
|
|
|
nsCOMPtr<nsIInterfaceRequestor> factoryPtr = do_QueryInterface(mSource);
|
|
|
|
if (factoryPtr) {
|
2007-03-22 10:30:00 -07:00
|
|
|
status = factoryPtr->GetInterface(aIID, aInstancePtr);
|
2014-06-26 18:35:39 -07:00
|
|
|
} else {
|
2007-03-22 10:30:00 -07:00
|
|
|
status = NS_ERROR_NO_INTERFACE;
|
2014-06-26 18:35:39 -07:00
|
|
|
}
|
|
|
|
} else {
|
2007-03-22 10:30:00 -07:00
|
|
|
status = NS_ERROR_NULL_POINTER;
|
2014-06-26 18:35:39 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-06-26 18:35:39 -07:00
|
|
|
if (NS_FAILED(status)) {
|
2010-04-16 06:03:00 -07:00
|
|
|
*aInstancePtr = 0;
|
2014-06-26 18:35:39 -07:00
|
|
|
}
|
|
|
|
if (mErrorPtr) {
|
2007-03-22 10:30:00 -07:00
|
|
|
*mErrorPtr = status;
|
2014-06-26 18:35:39 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
return status;
|
|
|
|
}
|