content/xul/templates/src/nsRDFQuery.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     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/. */
     6 #ifndef nsRDFQuery_h__
     7 #define nsRDFQuery_h__
     9 #include "nsAutoPtr.h"
    10 #include "nsISimpleEnumerator.h"
    11 #include "nsCycleCollectionParticipant.h"
    12 #include "mozilla/Attributes.h"
    14 #define NS_ITEMPLATERDFQUERY_IID \
    15   {0x8929ff60, 0x1c9c, 0x4d87, \
    16     { 0xac, 0x02, 0x09, 0x14, 0x15, 0x3b, 0x48, 0xc4 }}
    18 /**
    19  * A compiled query in the RDF query processor. This interface should not be
    20  * used directly outside of the RDF query processor.
    21  */
    22 class nsITemplateRDFQuery : public nsISupports
    23 {
    24 public:
    25     NS_DECLARE_STATIC_IID_ACCESSOR(NS_ITEMPLATERDFQUERY_IID)
    27     // return the processor the query was created from
    28     virtual nsXULTemplateQueryProcessorRDF* Processor() = 0;  // not addrefed
    30     // return the member variable for the query
    31     virtual nsIAtom* GetMemberVariable() = 0; // not addrefed
    33     // return the <query> node the query was compiled from
    34     virtual void GetQueryNode(nsIDOMNode** aQueryNode) = 0;
    36     // remove any results that are cached by the query
    37     virtual void ClearCachedResults() = 0;
    38 };
    40 class nsRDFQuery MOZ_FINAL : public nsITemplateRDFQuery
    41 {
    42 public:
    44     nsRDFQuery(nsXULTemplateQueryProcessorRDF* aProcessor)
    45       : mProcessor(aProcessor),
    46         mSimple(false),
    47         mRoot(nullptr),
    48         mCachedResults(nullptr)
    49     { }
    51     ~nsRDFQuery() { Finish(); }
    53     NS_DECL_CYCLE_COLLECTING_ISUPPORTS
    54     NS_DECL_CYCLE_COLLECTION_CLASS(nsRDFQuery)
    56     /**
    57      * Retrieve the root node in the rule network
    58      * @return the root node in the rule network
    59      */
    60     TestNode* GetRoot() { return mRoot; }
    62     void SetRoot(TestNode* aRoot) { mRoot = aRoot; }
    64     void GetQueryNode(nsIDOMNode** aQueryNode) MOZ_OVERRIDE
    65     {
    66        *aQueryNode = mQueryNode;
    67        NS_IF_ADDREF(*aQueryNode);
    68     }
    70     void SetQueryNode(nsIDOMNode* aQueryNode)
    71     {
    72        mQueryNode = aQueryNode;
    73     }
    75     // an optimization is used when several queries all use the simple query
    76     // syntax. Since simple queries can only generate one possible set of
    77     // results, they only need to be calculated once and reused for every
    78     // simple query. The results may be cached in the query for this purpose.
    79     // If successful, this method takes ownership of aInstantiations.
    80     nsresult SetCachedResults(nsXULTemplateQueryProcessorRDF* aProcessor,
    81                               const InstantiationSet& aInstantiations);
    83     // grab the cached results, if any, causing the caller to take ownership
    84     // of them. This also has the effect of setting the cached results in this
    85     // nsRDFQuery to null.
    86     void UseCachedResults(nsISimpleEnumerator** aResults);
    88     // clear the cached results
    89     void ClearCachedResults() MOZ_OVERRIDE
    90     {
    91         mCachedResults = nullptr;
    92     }
    94     nsXULTemplateQueryProcessorRDF* Processor() MOZ_OVERRIDE { return mProcessor; }
    96     nsIAtom* GetMemberVariable() MOZ_OVERRIDE { return mMemberVariable; }
    98     bool IsSimple() { return mSimple; }
   100     void SetSimple() { mSimple = true; }
   102     // the reference and member variables for the query
   103     nsCOMPtr<nsIAtom> mRefVariable;
   104     nsCOMPtr<nsIAtom> mMemberVariable;
   106 protected:
   108     nsXULTemplateQueryProcessorRDF* mProcessor;
   110     // true if the query is a simple rule (one with a default query)
   111     bool mSimple;
   113     /**
   114      * The root node in the network for this query
   115      */
   116     TestNode *mRoot;
   118     // the <query> node
   119     nsCOMPtr<nsIDOMNode> mQueryNode;
   121     // used for simple rules since their results are all determined in one step
   122     nsCOMPtr<nsISimpleEnumerator> mCachedResults;
   124     void Finish();
   125 };
   127 NS_DEFINE_STATIC_IID_ACCESSOR(nsITemplateRDFQuery, NS_ITEMPLATERDFQUERY_IID)
   129 #endif // nsRDFQuery_h__

mercurial