xpcom/tests/SizeTest06.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/xpcom/tests/SizeTest06.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,150 @@
     1.4 +// Test06.cpp
     1.5 +
     1.6 +#include "nsPIDOMWindow.h"
     1.7 +#include "nsIDocShell.h"
     1.8 +#include "nsIBaseWindow.h"
     1.9 +#include "nsCOMPtr.h"
    1.10 +
    1.11 +NS_DEF_PTR(nsPIDOMWindow);
    1.12 +NS_DEF_PTR(nsIBaseWindow);
    1.13 +
    1.14 +  /*
    1.15 +    Windows:
    1.16 +      nsCOMPtr_optimized           176
    1.17 +      nsCOMPtr_as_found            181
    1.18 +      nsCOMPtr_optimized*          182
    1.19 +      nsCOMPtr02*                  184
    1.20 +      nsCOMPtr02                   187
    1.21 +      nsCOMPtr02*                  188
    1.22 +      nsCOMPtr03                   189
    1.23 +      raw_optimized, nsCOMPtr00    191
    1.24 +      nsCOMPtr00*                  199
    1.25 +      nsCOMPtr_as_found*           201
    1.26 +      raw                          214
    1.27 +
    1.28 +    Macintosh:
    1.29 +      nsCOMPtr_optimized           300    (1.0000)
    1.30 +      nsCOMPtr02                   320    (1.0667)  i.e., 6.67% bigger than nsCOMPtr_optimized
    1.31 +      nsCOMPtr00                   328    (1.0933)
    1.32 +      raw_optimized, nsCOMPtr03    332    (1.1067)
    1.33 +      nsCOMPtr_as_found            344    (1.1467)
    1.34 +      raw                          388    (1.2933)
    1.35 +
    1.36 +  */
    1.37 +
    1.38 +
    1.39 +void // nsresult
    1.40 +Test06_raw(nsIDOMWindow* aDOMWindow, nsIBaseWindow** aBaseWindow)
    1.41 +    // m388, w214
    1.42 +{
    1.43 +//  if (!aDOMWindow)
    1.44 +//    return NS_ERROR_NULL_POINTER;
    1.45 +  nsPIDOMWindow* window = 0;
    1.46 +  nsresult status = aDOMWindow->QueryInterface(NS_GET_IID(nsPIDOMWindow), (void**)&window);
    1.47 +  nsIDocShell* docShell = 0;
    1.48 +  if (window)
    1.49 +    window->GetDocShell(&docShell);
    1.50 +  nsIWebShell* rootWebShell = 0;
    1.51 +  NS_IF_RELEASE(rootWebShell);
    1.52 +  NS_IF_RELEASE(docShell);
    1.53 +  NS_IF_RELEASE(window);
    1.54 +//    return status;
    1.55 +}
    1.56 +
    1.57 +void // nsresult
    1.58 +Test06_raw_optimized(nsIDOMWindow* aDOMWindow, nsIBaseWindow** aBaseWindow)
    1.59 +    // m332, w191
    1.60 +{
    1.61 +//  if (!aDOMWindow)
    1.62 +//    return NS_ERROR_NULL_POINTER;
    1.63 +  (*aBaseWindow) = 0;
    1.64 +  nsPIDOMWindow* window;
    1.65 +  nsresult status = aDOMWindow->QueryInterface(NS_GET_IID(nsPIDOMWindow), (void**)&window);
    1.66 +  if (NS_SUCCEEDED(status)) {
    1.67 +    nsIDocShell* docShell = 0;
    1.68 +    window->GetDocShell(&docShell);
    1.69 +    if (docShell) {
    1.70 +      NS_RELEASE(docShell);
    1.71 +    }
    1.72 +    NS_RELEASE(window);
    1.73 +  }
    1.74 +//  return status;
    1.75 +}
    1.76 +
    1.77 +void
    1.78 +Test06_nsCOMPtr_as_found(nsIDOMWindow* aDOMWindow, nsCOMPtr<nsIBaseWindow>* aBaseWindow)
    1.79 +    // m344, w181/201
    1.80 +{
    1.81 +//  if (!aDOMWindow)
    1.82 +//    return;
    1.83 +  nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aDOMWindow);
    1.84 +  nsCOMPtr<nsIDocShell> docShell;
    1.85 +  if (window)
    1.86 +    window->GetDocShell(getter_AddRefs(docShell));  
    1.87 +}
    1.88 +
    1.89 +void // nsresult
    1.90 +Test06_nsCOMPtr00(nsIDOMWindow* aDOMWindow, nsIBaseWindow** aBaseWindow)
    1.91 +    // m328, w191/199
    1.92 +{
    1.93 +//  if (!aDOMWindow)
    1.94 +//    return NS_ERROR_NULL_POINTER;
    1.95 +  nsresult status;
    1.96 +  nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aDOMWindow, &status);
    1.97 +  nsIDocShell* temp0 = 0;
    1.98 +  if (window)
    1.99 +    window->GetDocShell(&temp0);
   1.100 +  nsCOMPtr<nsIDocShell> docShell = dont_AddRef(temp0);
   1.101 +  (*aBaseWindow) = 0;
   1.102 +//    return status;
   1.103 +}
   1.104 +
   1.105 +void // nsresult
   1.106 +Test06_nsCOMPtr_optimized(nsIDOMWindow* aDOMWindow, nsCOMPtr<nsIBaseWindow>* aBaseWindow)
   1.107 +    // m300, w176/182
   1.108 +{
   1.109 +//    if (!aDOMWindow)
   1.110 +//      return NS_ERROR_NULL_POINTER;
   1.111 +  nsresult status;
   1.112 +  nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aDOMWindow, &status);
   1.113 +  nsIDocShell* temp0 = 0;
   1.114 +  if (window)
   1.115 +    window->GetDocShell(&temp0);
   1.116 +  (*aBaseWindow) = do_QueryInterface(nullptr, &status);
   1.117 +//    return status;
   1.118 +}
   1.119 +
   1.120 +void // nsresult
   1.121 +Test06_nsCOMPtr02(nsIDOMWindow* aDOMWindow, nsIBaseWindow** aBaseWindow)
   1.122 +    // m320, w187/184
   1.123 +{
   1.124 +//    if (!aDOMWindow)
   1.125 +//      return NS_ERROR_NULL_POINTER;
   1.126 +  (*aBaseWindow) = 0;
   1.127 +  nsresult status;
   1.128 +  nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aDOMWindow, &status);
   1.129 +  if (window) {
   1.130 +    nsIDocShell* temp0;
   1.131 +    window->GetDocShell(&temp0);
   1.132 +  }
   1.133 +//    return status;
   1.134 +}
   1.135 +
   1.136 +void // nsresult
   1.137 +Test06_nsCOMPtr03(nsIDOMWindow* aDOMWindow, nsCOMPtr<nsIBaseWindow>* aBaseWindow)
   1.138 +    // m332, w189/188
   1.139 +{
   1.140 +//    if (!aDOMWindow)
   1.141 +//      return NS_ERROR_NULL_POINTER;
   1.142 +  (*aBaseWindow) = 0;
   1.143 +  nsresult status;
   1.144 +  nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aDOMWindow, &status);
   1.145 +  if (window) {
   1.146 +    nsIDocShell* temp0;
   1.147 +    window->GetDocShell(&temp0);
   1.148 +    nsCOMPtr<nsIDocShell> docShell = dont_AddRef(temp0);
   1.149 +    if (docShell) {
   1.150 +    }
   1.151 +  }
   1.152 +//    return status;
   1.153 +}

mercurial