content/xul/templates/src/nsRDFQuery.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/xul/templates/src/nsRDFQuery.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,50 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#include "nscore.h"
    1.10 +#include "nsCOMPtr.h"
    1.11 +
    1.12 +#include "nsXULTemplateQueryProcessorRDF.h"
    1.13 +#include "nsRDFQuery.h"
    1.14 +
    1.15 +NS_IMPL_CYCLE_COLLECTION(nsRDFQuery, mQueryNode)
    1.16 +
    1.17 +NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsRDFQuery)
    1.18 +  NS_INTERFACE_MAP_ENTRY(nsITemplateRDFQuery)
    1.19 +  NS_INTERFACE_MAP_ENTRY(nsISupports)
    1.20 +NS_INTERFACE_MAP_END
    1.21 +
    1.22 +NS_IMPL_CYCLE_COLLECTING_ADDREF(nsRDFQuery)
    1.23 +NS_IMPL_CYCLE_COLLECTING_RELEASE(nsRDFQuery)
    1.24 +
    1.25 +void
    1.26 +nsRDFQuery::Finish()
    1.27 +{
    1.28 +    // the template builder is going away and the query processor likely as
    1.29 +    // well. Clear the reference to avoid calling it.
    1.30 +    mProcessor = nullptr;
    1.31 +    mCachedResults = nullptr;
    1.32 +}
    1.33 +
    1.34 +nsresult
    1.35 +nsRDFQuery::SetCachedResults(nsXULTemplateQueryProcessorRDF* aProcessor,
    1.36 +                             const InstantiationSet& aInstantiations)
    1.37 +{
    1.38 +    mCachedResults = new nsXULTemplateResultSetRDF(aProcessor, this, &aInstantiations);
    1.39 +    if (! mCachedResults)
    1.40 +        return NS_ERROR_OUT_OF_MEMORY;
    1.41 +
    1.42 +    return NS_OK;
    1.43 +}
    1.44 +
    1.45 +
    1.46 +void
    1.47 +nsRDFQuery::UseCachedResults(nsISimpleEnumerator** aResults)
    1.48 +{
    1.49 +    *aResults = mCachedResults;
    1.50 +    NS_IF_ADDREF(*aResults);
    1.51 +
    1.52 +    mCachedResults = nullptr;
    1.53 +}

mercurial