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 | // Test03.cpp |
michael@0 | 2 | |
michael@0 | 3 | #include "nsIDOMNode.h" |
michael@0 | 4 | #include "nsCOMPtr.h" |
michael@0 | 5 | #include "nsString.h" |
michael@0 | 6 | |
michael@0 | 7 | NS_DEF_PTR(nsIDOMNode); |
michael@0 | 8 | |
michael@0 | 9 | /* |
michael@0 | 10 | Windows: |
michael@0 | 11 | nsCOMPtr_optimized* 45 |
michael@0 | 12 | raw_optimized 48 |
michael@0 | 13 | nsCOMPtr_optimized 50 |
michael@0 | 14 | nsCOMPtr 54 |
michael@0 | 15 | nsCOMPtr* 59 |
michael@0 | 16 | raw 62 |
michael@0 | 17 | |
michael@0 | 18 | Macintosh: |
michael@0 | 19 | nsCOMPtr_optimized 112 (1.0000) |
michael@0 | 20 | raw_optimized 124 bytes (1.1071) i.e., 10.71% bigger than nsCOMPtr_optimized |
michael@0 | 21 | nsCOMPtr 144 (1.2857) |
michael@0 | 22 | */ |
michael@0 | 23 | |
michael@0 | 24 | void // nsresult |
michael@0 | 25 | Test03_raw( nsIDOMNode* aDOMNode, nsString* aResult ) |
michael@0 | 26 | // m140, w62 |
michael@0 | 27 | { |
michael@0 | 28 | // -- the following code is assumed, but is commented out so we compare only |
michael@0 | 29 | // the relevent generated code |
michael@0 | 30 | |
michael@0 | 31 | // if ( !aDOMNode || !aResult ) |
michael@0 | 32 | // return NS_ERROR_NULL_POINTER; |
michael@0 | 33 | |
michael@0 | 34 | nsIDOMNode* parent = 0; |
michael@0 | 35 | nsresult status = aDOMNode->GetParentNode(&parent); |
michael@0 | 36 | |
michael@0 | 37 | if ( NS_SUCCEEDED(status) ) |
michael@0 | 38 | { |
michael@0 | 39 | parent->GetNodeName(*aResult); |
michael@0 | 40 | } |
michael@0 | 41 | |
michael@0 | 42 | NS_IF_RELEASE(parent); |
michael@0 | 43 | |
michael@0 | 44 | // return status; |
michael@0 | 45 | } |
michael@0 | 46 | |
michael@0 | 47 | |
michael@0 | 48 | void // nsresult |
michael@0 | 49 | Test03_raw_optimized( nsIDOMNode* aDOMNode, nsString* aResult ) |
michael@0 | 50 | // m124, w48 |
michael@0 | 51 | { |
michael@0 | 52 | // if ( !aDOMNode || !aResult ) |
michael@0 | 53 | // return NS_ERROR_NULL_POINTER; |
michael@0 | 54 | |
michael@0 | 55 | nsIDOMNode* parent; |
michael@0 | 56 | nsresult status = aDOMNode->GetParentNode(&parent); |
michael@0 | 57 | |
michael@0 | 58 | if ( NS_SUCCEEDED(status) ) |
michael@0 | 59 | { |
michael@0 | 60 | parent->GetNodeName(*aResult); |
michael@0 | 61 | NS_RELEASE(parent); |
michael@0 | 62 | } |
michael@0 | 63 | |
michael@0 | 64 | // return status; |
michael@0 | 65 | } |
michael@0 | 66 | |
michael@0 | 67 | |
michael@0 | 68 | void // nsresult |
michael@0 | 69 | Test03_nsCOMPtr( nsIDOMNode* aDOMNode, nsString* aResult ) |
michael@0 | 70 | // m144, w54/59 |
michael@0 | 71 | { |
michael@0 | 72 | // if ( !aDOMNode || !aResult ) |
michael@0 | 73 | // return NS_ERROR_NULL_POINTER; |
michael@0 | 74 | |
michael@0 | 75 | nsCOMPtr<nsIDOMNode> parent; |
michael@0 | 76 | nsresult status = aDOMNode->GetParentNode( getter_AddRefs(parent) ); |
michael@0 | 77 | if ( parent ) |
michael@0 | 78 | parent->GetNodeName(*aResult); |
michael@0 | 79 | |
michael@0 | 80 | // return status; |
michael@0 | 81 | } |
michael@0 | 82 | |
michael@0 | 83 | void // nsresult |
michael@0 | 84 | Test03_nsCOMPtr_optimized( nsIDOMNode* aDOMNode, nsString* aResult ) |
michael@0 | 85 | // m112, w50/45 |
michael@0 | 86 | { |
michael@0 | 87 | // if ( !aDOMNode || !aResult ) |
michael@0 | 88 | // return NS_ERROR_NULL_POINTER; |
michael@0 | 89 | |
michael@0 | 90 | nsIDOMNode* temp; |
michael@0 | 91 | nsresult status = aDOMNode->GetParentNode(&temp); |
michael@0 | 92 | nsCOMPtr<nsIDOMNode> parent( dont_AddRef(temp) ); |
michael@0 | 93 | if ( parent ) |
michael@0 | 94 | parent->GetNodeName(*aResult); |
michael@0 | 95 | |
michael@0 | 96 | // return status; |
michael@0 | 97 | } |