xpcom/tests/SizeTest02.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.

     1 // Test02.cpp
     3 #include "nsIDOMNode.h"
     4 #include "nsCOMPtr.h"
     5 #include "nsString.h"
     7 NS_DEF_PTR(nsIDOMNode);
     9 	/*
    10 		This test file compares the generated code size of similar functions between raw
    11                 COM interface pointers (|AddRef|ing and |Release|ing by hand) and |nsCOMPtr|s.
    13 		Function size results were determined by examining dissassembly of the generated code.
    14 		mXXX is the size of the generated code on the Macintosh.  wXXX is the size on Windows.
    15 		For these tests, all reasonable optimizations were enabled and exceptions were
    16 		disabled (just as we build for release).
    18 		The tests in this file explore more complicated functionality: assigning a pointer
    19                 to be reference counted into a [raw, nsCOMPtr] object using |QueryInterface|;
    20 		ensuring that it is |AddRef|ed and |Release|d appropriately; calling through the pointer
    21 		to a function supplied by the underlying COM interface.  The tests in this file expand
    22 		on the tests in "Test01.cpp" by adding |QueryInterface|.
    24 		Windows:
    25 			raw01									 52
    26 			nsCOMPtr							 63
    27 			raw										 66
    28 			nsCOMPtr*							 68
    30 		Macintosh:
    31 			nsCOMPtr							120 	(1.0000)
    32 			Raw01									128		(1.1429)	i.e., 14.29% bigger than nsCOMPtr
    33 			Raw00									144		(1.2000)
    34 	*/
    37 void // nsresult
    38 Test02_Raw00( nsISupports* aDOMNode, nsString* aResult )
    39 		// m144, w66
    40 	{
    41 // -- the following code is assumed, but is commented out so we compare only
    42 //		 the relevent generated code
    44 //		if ( !aDOMNode )
    45 //			return NS_ERROR_NULL_POINTER;
    47 		nsIDOMNode* node = 0;
    48 		nsresult status = aDOMNode->QueryInterface(NS_GET_IID(nsIDOMNode), (void**)&node);
    49 		if ( NS_SUCCEEDED(status) )
    50 			{
    51 				node->GetNodeName(*aResult);
    52 			}
    54 		NS_IF_RELEASE(node);
    56 //		return status;
    57 	}
    59 void // nsresult
    60 Test02_Raw01( nsISupports* aDOMNode, nsString* aResult )
    61 		// m128, w52
    62 	{
    63 //		if ( !aDOMNode )
    64 //			return NS_ERROR_NULL_POINTER;
    66 		nsIDOMNode* node;
    67                 nsresult status = aDOMNode->QueryInterface(NS_GET_IID(nsIDOMNode), (void**)&node);
    68 		if ( NS_SUCCEEDED(status) )
    69 			{
    70 				node->GetNodeName(*aResult);
    71 				NS_RELEASE(node);
    72 			}
    74 //		return status;
    75 	}
    77 void // nsresult
    78 Test02_nsCOMPtr( nsISupports* aDOMNode, nsString* aResult )
    79 		// m120, w63/68
    80 	{
    81 		nsresult status;
    82 		nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aDOMNode, &status);
    84 		if ( node )
    85 			node->GetNodeName(*aResult);
    87 //		return status;
    88 	}

mercurial