michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nscore.h" michael@0: #include "nsCOMPtr.h" michael@0: michael@0: #include "nsXULTemplateQueryProcessorRDF.h" michael@0: #include "nsRDFQuery.h" michael@0: michael@0: NS_IMPL_CYCLE_COLLECTION(nsRDFQuery, mQueryNode) michael@0: michael@0: NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsRDFQuery) michael@0: NS_INTERFACE_MAP_ENTRY(nsITemplateRDFQuery) michael@0: NS_INTERFACE_MAP_ENTRY(nsISupports) michael@0: NS_INTERFACE_MAP_END michael@0: michael@0: NS_IMPL_CYCLE_COLLECTING_ADDREF(nsRDFQuery) michael@0: NS_IMPL_CYCLE_COLLECTING_RELEASE(nsRDFQuery) michael@0: michael@0: void michael@0: nsRDFQuery::Finish() michael@0: { michael@0: // the template builder is going away and the query processor likely as michael@0: // well. Clear the reference to avoid calling it. michael@0: mProcessor = nullptr; michael@0: mCachedResults = nullptr; michael@0: } michael@0: michael@0: nsresult michael@0: nsRDFQuery::SetCachedResults(nsXULTemplateQueryProcessorRDF* aProcessor, michael@0: const InstantiationSet& aInstantiations) michael@0: { michael@0: mCachedResults = new nsXULTemplateResultSetRDF(aProcessor, this, &aInstantiations); michael@0: if (! mCachedResults) michael@0: return NS_ERROR_OUT_OF_MEMORY; michael@0: michael@0: return NS_OK; michael@0: } michael@0: michael@0: michael@0: void michael@0: nsRDFQuery::UseCachedResults(nsISimpleEnumerator** aResults) michael@0: { michael@0: *aResults = mCachedResults; michael@0: NS_IF_ADDREF(*aResults); michael@0: michael@0: mCachedResults = nullptr; michael@0: }