xpcom/tests/SizeTest06.cpp

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.

michael@0 1 // Test06.cpp
michael@0 2
michael@0 3 #include "nsPIDOMWindow.h"
michael@0 4 #include "nsIDocShell.h"
michael@0 5 #include "nsIBaseWindow.h"
michael@0 6 #include "nsCOMPtr.h"
michael@0 7
michael@0 8 NS_DEF_PTR(nsPIDOMWindow);
michael@0 9 NS_DEF_PTR(nsIBaseWindow);
michael@0 10
michael@0 11 /*
michael@0 12 Windows:
michael@0 13 nsCOMPtr_optimized 176
michael@0 14 nsCOMPtr_as_found 181
michael@0 15 nsCOMPtr_optimized* 182
michael@0 16 nsCOMPtr02* 184
michael@0 17 nsCOMPtr02 187
michael@0 18 nsCOMPtr02* 188
michael@0 19 nsCOMPtr03 189
michael@0 20 raw_optimized, nsCOMPtr00 191
michael@0 21 nsCOMPtr00* 199
michael@0 22 nsCOMPtr_as_found* 201
michael@0 23 raw 214
michael@0 24
michael@0 25 Macintosh:
michael@0 26 nsCOMPtr_optimized 300 (1.0000)
michael@0 27 nsCOMPtr02 320 (1.0667) i.e., 6.67% bigger than nsCOMPtr_optimized
michael@0 28 nsCOMPtr00 328 (1.0933)
michael@0 29 raw_optimized, nsCOMPtr03 332 (1.1067)
michael@0 30 nsCOMPtr_as_found 344 (1.1467)
michael@0 31 raw 388 (1.2933)
michael@0 32
michael@0 33 */
michael@0 34
michael@0 35
michael@0 36 void // nsresult
michael@0 37 Test06_raw(nsIDOMWindow* aDOMWindow, nsIBaseWindow** aBaseWindow)
michael@0 38 // m388, w214
michael@0 39 {
michael@0 40 // if (!aDOMWindow)
michael@0 41 // return NS_ERROR_NULL_POINTER;
michael@0 42 nsPIDOMWindow* window = 0;
michael@0 43 nsresult status = aDOMWindow->QueryInterface(NS_GET_IID(nsPIDOMWindow), (void**)&window);
michael@0 44 nsIDocShell* docShell = 0;
michael@0 45 if (window)
michael@0 46 window->GetDocShell(&docShell);
michael@0 47 nsIWebShell* rootWebShell = 0;
michael@0 48 NS_IF_RELEASE(rootWebShell);
michael@0 49 NS_IF_RELEASE(docShell);
michael@0 50 NS_IF_RELEASE(window);
michael@0 51 // return status;
michael@0 52 }
michael@0 53
michael@0 54 void // nsresult
michael@0 55 Test06_raw_optimized(nsIDOMWindow* aDOMWindow, nsIBaseWindow** aBaseWindow)
michael@0 56 // m332, w191
michael@0 57 {
michael@0 58 // if (!aDOMWindow)
michael@0 59 // return NS_ERROR_NULL_POINTER;
michael@0 60 (*aBaseWindow) = 0;
michael@0 61 nsPIDOMWindow* window;
michael@0 62 nsresult status = aDOMWindow->QueryInterface(NS_GET_IID(nsPIDOMWindow), (void**)&window);
michael@0 63 if (NS_SUCCEEDED(status)) {
michael@0 64 nsIDocShell* docShell = 0;
michael@0 65 window->GetDocShell(&docShell);
michael@0 66 if (docShell) {
michael@0 67 NS_RELEASE(docShell);
michael@0 68 }
michael@0 69 NS_RELEASE(window);
michael@0 70 }
michael@0 71 // return status;
michael@0 72 }
michael@0 73
michael@0 74 void
michael@0 75 Test06_nsCOMPtr_as_found(nsIDOMWindow* aDOMWindow, nsCOMPtr<nsIBaseWindow>* aBaseWindow)
michael@0 76 // m344, w181/201
michael@0 77 {
michael@0 78 // if (!aDOMWindow)
michael@0 79 // return;
michael@0 80 nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aDOMWindow);
michael@0 81 nsCOMPtr<nsIDocShell> docShell;
michael@0 82 if (window)
michael@0 83 window->GetDocShell(getter_AddRefs(docShell));
michael@0 84 }
michael@0 85
michael@0 86 void // nsresult
michael@0 87 Test06_nsCOMPtr00(nsIDOMWindow* aDOMWindow, nsIBaseWindow** aBaseWindow)
michael@0 88 // m328, w191/199
michael@0 89 {
michael@0 90 // if (!aDOMWindow)
michael@0 91 // return NS_ERROR_NULL_POINTER;
michael@0 92 nsresult status;
michael@0 93 nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aDOMWindow, &status);
michael@0 94 nsIDocShell* temp0 = 0;
michael@0 95 if (window)
michael@0 96 window->GetDocShell(&temp0);
michael@0 97 nsCOMPtr<nsIDocShell> docShell = dont_AddRef(temp0);
michael@0 98 (*aBaseWindow) = 0;
michael@0 99 // return status;
michael@0 100 }
michael@0 101
michael@0 102 void // nsresult
michael@0 103 Test06_nsCOMPtr_optimized(nsIDOMWindow* aDOMWindow, nsCOMPtr<nsIBaseWindow>* aBaseWindow)
michael@0 104 // m300, w176/182
michael@0 105 {
michael@0 106 // if (!aDOMWindow)
michael@0 107 // return NS_ERROR_NULL_POINTER;
michael@0 108 nsresult status;
michael@0 109 nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aDOMWindow, &status);
michael@0 110 nsIDocShell* temp0 = 0;
michael@0 111 if (window)
michael@0 112 window->GetDocShell(&temp0);
michael@0 113 (*aBaseWindow) = do_QueryInterface(nullptr, &status);
michael@0 114 // return status;
michael@0 115 }
michael@0 116
michael@0 117 void // nsresult
michael@0 118 Test06_nsCOMPtr02(nsIDOMWindow* aDOMWindow, nsIBaseWindow** aBaseWindow)
michael@0 119 // m320, w187/184
michael@0 120 {
michael@0 121 // if (!aDOMWindow)
michael@0 122 // return NS_ERROR_NULL_POINTER;
michael@0 123 (*aBaseWindow) = 0;
michael@0 124 nsresult status;
michael@0 125 nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aDOMWindow, &status);
michael@0 126 if (window) {
michael@0 127 nsIDocShell* temp0;
michael@0 128 window->GetDocShell(&temp0);
michael@0 129 }
michael@0 130 // return status;
michael@0 131 }
michael@0 132
michael@0 133 void // nsresult
michael@0 134 Test06_nsCOMPtr03(nsIDOMWindow* aDOMWindow, nsCOMPtr<nsIBaseWindow>* aBaseWindow)
michael@0 135 // m332, w189/188
michael@0 136 {
michael@0 137 // if (!aDOMWindow)
michael@0 138 // return NS_ERROR_NULL_POINTER;
michael@0 139 (*aBaseWindow) = 0;
michael@0 140 nsresult status;
michael@0 141 nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aDOMWindow, &status);
michael@0 142 if (window) {
michael@0 143 nsIDocShell* temp0;
michael@0 144 window->GetDocShell(&temp0);
michael@0 145 nsCOMPtr<nsIDocShell> docShell = dont_AddRef(temp0);
michael@0 146 if (docShell) {
michael@0 147 }
michael@0 148 }
michael@0 149 // return status;
michael@0 150 }

mercurial