parser/html/nsHtml5DependentUTF16Buffer.cpp

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 #include "nsHtml5DependentUTF16Buffer.h"
     7 nsHtml5DependentUTF16Buffer::nsHtml5DependentUTF16Buffer(const nsAString& aToWrap)
     8   : nsHtml5UTF16Buffer(const_cast<char16_t*> (aToWrap.BeginReading()),
     9                        aToWrap.Length())
    10 {
    11   MOZ_COUNT_CTOR(nsHtml5DependentUTF16Buffer);
    12 }
    14 nsHtml5DependentUTF16Buffer::~nsHtml5DependentUTF16Buffer()
    15 {
    16   MOZ_COUNT_DTOR(nsHtml5DependentUTF16Buffer);
    17 }
    19 already_AddRefed<nsHtml5OwningUTF16Buffer>
    20 nsHtml5DependentUTF16Buffer::FalliblyCopyAsOwningBuffer()
    21 {
    22   int32_t newLength = getEnd() - getStart();
    23   nsRefPtr<nsHtml5OwningUTF16Buffer> newObj =
    24     nsHtml5OwningUTF16Buffer::FalliblyCreate(newLength);
    25   if (!newObj) {
    26     return nullptr;
    27   }
    28   newObj->setEnd(newLength);
    29   memcpy(newObj->getBuffer(),
    30          getBuffer() + getStart(),
    31          newLength * sizeof(char16_t));
    32   return newObj.forget();
    33 }

mercurial