xpcom/string/public/nsTDependentSubstring.h

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 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
     3 /* This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 // IWYU pragma: private, include "nsString.h"
     8   /**
     9    * nsTDependentSubstring_CharT
    10    *
    11    * A string class which wraps an external array of string characters. It
    12    * is the client code's responsibility to ensure that the external buffer
    13    * remains valid for a long as the string is alive.
    14    *
    15    * NAMES:
    16    *   nsDependentSubstring for wide characters
    17    *   nsDependentCSubstring for narrow characters
    18    */
    19 class nsTDependentSubstring_CharT : public nsTSubstring_CharT
    20   {
    21     public:
    23       typedef nsTDependentSubstring_CharT    self_type;
    25     public:
    27       void Rebind( const substring_type&, uint32_t startPos, uint32_t length = size_type(-1) );
    29       void Rebind( const char_type* data, size_type length );
    31       void Rebind( const char_type* start, const char_type* end )
    32         {
    33           Rebind(start, size_type(end - start));
    34         }
    36       nsTDependentSubstring_CharT( const substring_type& str, uint32_t startPos, uint32_t length = size_type(-1) )
    37         : substring_type()
    38         {
    39           Rebind(str, startPos, length);
    40         }
    42       nsTDependentSubstring_CharT( const char_type* data, size_type length )
    43         : substring_type(const_cast<char_type*>(data), length, F_NONE) {}
    45       nsTDependentSubstring_CharT( const char_type* start, const char_type* end )
    46         : substring_type(const_cast<char_type*>(start), uint32_t(end - start), F_NONE) {}
    48 #if defined(CharT_is_PRUnichar) && defined(MOZ_USE_CHAR16_WRAPPER)
    49       nsTDependentSubstring_CharT( char16ptr_t data, size_type length )
    50         : nsTDependentSubstring_CharT(static_cast<const char16_t*>(data), length) {}
    52       nsTDependentSubstring_CharT( char16ptr_t start, char16ptr_t end )
    53         : nsTDependentSubstring_CharT(static_cast<const char16_t*>(start), static_cast<const char16_t*>(end)) {}
    54 #endif
    56       nsTDependentSubstring_CharT( const const_iterator& start, const const_iterator& end )
    57         : substring_type(const_cast<char_type*>(start.get()), uint32_t(end.get() - start.get()), F_NONE) {}
    59       // Create a nsTDependentSubstring to be bound later
    60       nsTDependentSubstring_CharT()
    61         : substring_type() {}
    63       // auto-generated copy-constructor OK (XXX really?? what about base class copy-ctor?)
    65     private:
    66         // NOT USED
    67       void operator=( const self_type& );        // we're immutable, you can't assign into a substring
    68   };
    70 inline
    71 const nsTDependentSubstring_CharT
    72 Substring( const nsTSubstring_CharT& str, uint32_t startPos, uint32_t length = uint32_t(-1) )
    73   {
    74     return nsTDependentSubstring_CharT(str, startPos, length);
    75   }
    77 inline
    78 const nsTDependentSubstring_CharT
    79 Substring( const nsReadingIterator<CharT>& start, const nsReadingIterator<CharT>& end )
    80   {
    81     return nsTDependentSubstring_CharT(start.get(), end.get());
    82   }
    84 inline
    85 const nsTDependentSubstring_CharT
    86 Substring( const CharT* data, uint32_t length )
    87   {
    88     return nsTDependentSubstring_CharT(data, length);
    89   }
    91 inline
    92 const nsTDependentSubstring_CharT
    93 Substring( const CharT* start, const CharT* end )
    94   {
    95     return nsTDependentSubstring_CharT(start, end);
    96   }
    98 inline
    99 const nsTDependentSubstring_CharT
   100 StringHead( const nsTSubstring_CharT& str, uint32_t count )
   101   {
   102     return nsTDependentSubstring_CharT(str, 0, count);
   103   }
   105 inline
   106 const nsTDependentSubstring_CharT
   107 StringTail( const nsTSubstring_CharT& str, uint32_t count )
   108   {
   109     return nsTDependentSubstring_CharT(str, str.Length() - count, count);
   110   }

mercurial