Sat, 03 Jan 2015 20:18:00 +0100
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.
michael@0 | 1 | // |
michael@0 | 2 | // Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved. |
michael@0 | 3 | // Use of this source code is governed by a BSD-style license that can be |
michael@0 | 4 | // found in the LICENSE file. |
michael@0 | 5 | // |
michael@0 | 6 | |
michael@0 | 7 | #ifndef COMPILER_DETECT_RECURSION_H_ |
michael@0 | 8 | #define COMPILER_DETECT_RECURSION_H_ |
michael@0 | 9 | |
michael@0 | 10 | #include "GLSLANG/ShaderLang.h" |
michael@0 | 11 | |
michael@0 | 12 | #include <limits.h> |
michael@0 | 13 | #include "compiler/intermediate.h" |
michael@0 | 14 | #include "compiler/VariableInfo.h" |
michael@0 | 15 | |
michael@0 | 16 | class TInfoSink; |
michael@0 | 17 | |
michael@0 | 18 | // Traverses intermediate tree to detect function recursion. |
michael@0 | 19 | class DetectCallDepth : public TIntermTraverser { |
michael@0 | 20 | public: |
michael@0 | 21 | enum ErrorCode { |
michael@0 | 22 | kErrorMissingMain, |
michael@0 | 23 | kErrorRecursion, |
michael@0 | 24 | kErrorMaxDepthExceeded, |
michael@0 | 25 | kErrorNone |
michael@0 | 26 | }; |
michael@0 | 27 | |
michael@0 | 28 | DetectCallDepth(TInfoSink& infoSync, bool limitCallStackDepth, int maxCallStackDepth); |
michael@0 | 29 | ~DetectCallDepth(); |
michael@0 | 30 | |
michael@0 | 31 | virtual bool visitAggregate(Visit, TIntermAggregate*); |
michael@0 | 32 | |
michael@0 | 33 | bool checkExceedsMaxDepth(int depth); |
michael@0 | 34 | |
michael@0 | 35 | ErrorCode detectCallDepth(); |
michael@0 | 36 | |
michael@0 | 37 | private: |
michael@0 | 38 | class FunctionNode { |
michael@0 | 39 | public: |
michael@0 | 40 | static const int kInfiniteCallDepth = INT_MAX; |
michael@0 | 41 | |
michael@0 | 42 | FunctionNode(const TString& fname); |
michael@0 | 43 | |
michael@0 | 44 | const TString& getName() const; |
michael@0 | 45 | |
michael@0 | 46 | // If a function is already in the callee list, this becomes a no-op. |
michael@0 | 47 | void addCallee(FunctionNode* callee); |
michael@0 | 48 | |
michael@0 | 49 | // Returns kInifinityCallDepth if recursive function calls are detected. |
michael@0 | 50 | int detectCallDepth(DetectCallDepth* detectCallDepth, int depth); |
michael@0 | 51 | |
michael@0 | 52 | // Reset state. |
michael@0 | 53 | void reset(); |
michael@0 | 54 | |
michael@0 | 55 | private: |
michael@0 | 56 | // mangled function name is unique. |
michael@0 | 57 | TString name; |
michael@0 | 58 | |
michael@0 | 59 | // functions that are directly called by this function. |
michael@0 | 60 | TVector<FunctionNode*> callees; |
michael@0 | 61 | |
michael@0 | 62 | Visit visit; |
michael@0 | 63 | }; |
michael@0 | 64 | |
michael@0 | 65 | ErrorCode detectCallDepthForFunction(FunctionNode* func); |
michael@0 | 66 | FunctionNode* findFunctionByName(const TString& name); |
michael@0 | 67 | void resetFunctionNodes(); |
michael@0 | 68 | |
michael@0 | 69 | TInfoSink& getInfoSink() { return infoSink; } |
michael@0 | 70 | |
michael@0 | 71 | TVector<FunctionNode*> functions; |
michael@0 | 72 | FunctionNode* currentFunction; |
michael@0 | 73 | TInfoSink& infoSink; |
michael@0 | 74 | int maxDepth; |
michael@0 | 75 | |
michael@0 | 76 | DetectCallDepth(const DetectCallDepth&); |
michael@0 | 77 | void operator=(const DetectCallDepth&); |
michael@0 | 78 | }; |
michael@0 | 79 | |
michael@0 | 80 | #endif // COMPILER_DETECT_RECURSION_H_ |