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/. */
6 
7 #include "nsIInterfaceRequestor.h"
8 #include "nsIInterfaceRequestorUtils.h"
9 
operator ()(const nsIID & aIID,void ** aInstancePtr) const10 nsresult nsGetInterface::operator()(const nsIID& aIID,
11                                     void** aInstancePtr) const {
12   nsresult status;
13 
14   if (mSource) {
15     nsCOMPtr<nsIInterfaceRequestor> factoryPtr = do_QueryInterface(mSource);
16     if (factoryPtr) {
17       status = factoryPtr->GetInterface(aIID, aInstancePtr);
18     } else {
19       status = NS_ERROR_NO_INTERFACE;
20     }
21   } else {
22     status = NS_ERROR_NULL_POINTER;
23   }
24 
25   if (NS_FAILED(status)) {
26     *aInstancePtr = 0;
27   }
28   if (mErrorPtr) {
29     *mErrorPtr = status;
30   }
31   return status;
32 }
33