Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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 txResultRecycler_h__
7 #define txResultRecycler_h__
9 #include "nsCOMPtr.h"
10 #include "txStack.h"
12 class txAExprResult;
13 class StringResult;
14 class txNodeSet;
15 class txXPathNode;
16 class NumberResult;
17 class BooleanResult;
19 class txResultRecycler
20 {
21 public:
22 txResultRecycler();
23 ~txResultRecycler();
24 nsresult init();
26 void AddRef()
27 {
28 ++mRefCnt;
29 NS_LOG_ADDREF(this, mRefCnt, "txResultRecycler", sizeof(*this));
30 }
31 void Release()
32 {
33 --mRefCnt;
34 NS_LOG_RELEASE(this, mRefCnt, "txResultRecycler");
35 if (mRefCnt == 0) {
36 mRefCnt = 1; //stabilize
37 delete this;
38 }
39 }
41 /**
42 * Returns an txAExprResult to this recycler for reuse.
43 * @param aResult result to recycle
44 */
45 void recycle(txAExprResult* aResult);
47 /**
48 * Functions to return results that will be fully used by the caller.
49 * Returns nullptr on out-of-memory and an inited result otherwise.
50 */
51 nsresult getStringResult(StringResult** aResult);
52 nsresult getStringResult(const nsAString& aValue, txAExprResult** aResult);
53 nsresult getNodeSet(txNodeSet** aResult);
54 nsresult getNodeSet(txNodeSet* aNodeSet, txNodeSet** aResult);
55 nsresult getNodeSet(const txXPathNode& aNode, txAExprResult** aResult);
56 nsresult getNumberResult(double aValue, txAExprResult** aResult);
58 /**
59 * Functions to return a txAExprResult that is shared across several
60 * clients and must not be modified. Never returns nullptr.
61 */
62 void getEmptyStringResult(txAExprResult** aResult);
63 void getBoolResult(bool aValue, txAExprResult** aResult);
65 /**
66 * Functions that return non-shared resultsobjects
67 */
68 nsresult getNonSharedNodeSet(txNodeSet* aNodeSet, txNodeSet** aResult);
70 private:
71 nsAutoRefCnt mRefCnt;
72 txStack mStringResults;
73 txStack mNodeSetResults;
74 txStack mNumberResults;
75 StringResult* mEmptyStringResult;
76 BooleanResult* mTrueResult;
77 BooleanResult* mFalseResult;
78 };
80 #endif //txResultRecycler_h__