nsRDFQuery.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #include "nscore.h"
  6. #include "nsCOMPtr.h"
  7. #include "nsXULTemplateQueryProcessorRDF.h"
  8. #include "nsRDFQuery.h"
  9. NS_IMPL_CYCLE_COLLECTION(nsRDFQuery, mQueryNode)
  10. NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsRDFQuery)
  11. NS_INTERFACE_MAP_ENTRY(nsITemplateRDFQuery)
  12. NS_INTERFACE_MAP_ENTRY(nsISupports)
  13. NS_INTERFACE_MAP_END
  14. NS_IMPL_CYCLE_COLLECTING_ADDREF(nsRDFQuery)
  15. NS_IMPL_CYCLE_COLLECTING_RELEASE(nsRDFQuery)
  16. void
  17. nsRDFQuery::Finish()
  18. {
  19. // the template builder is going away and the query processor likely as
  20. // well. Clear the reference to avoid calling it.
  21. mProcessor = nullptr;
  22. mCachedResults = nullptr;
  23. }
  24. nsresult
  25. nsRDFQuery::SetCachedResults(nsXULTemplateQueryProcessorRDF* aProcessor,
  26. const InstantiationSet& aInstantiations)
  27. {
  28. mCachedResults = new nsXULTemplateResultSetRDF(aProcessor, this, &aInstantiations);
  29. return NS_OK;
  30. }
  31. void
  32. nsRDFQuery::UseCachedResults(nsISimpleEnumerator** aResults)
  33. {
  34. *aResults = mCachedResults;
  35. NS_IF_ADDREF(*aResults);
  36. mCachedResults = nullptr;
  37. }