xpcom/ds/nsAtomService.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #include "nsAtomService.h"
     7 #include "nsIAtom.h"
     9 NS_IMPL_ISUPPORTS(nsAtomService, nsIAtomService)
    11 nsAtomService::nsAtomService()
    12 {
    13 }
    15 nsresult
    16 nsAtomService::GetAtom(const nsAString& aString, nsIAtom ** aResult)
    17 {
    18   *aResult = NS_NewAtom(aString).take();
    20   if (!*aResult)
    21     return NS_ERROR_OUT_OF_MEMORY;
    23   return NS_OK;
    24 }
    26 nsresult
    27 nsAtomService::GetPermanentAtom(const nsAString& aString, nsIAtom ** aResult)
    28 {
    29   *aResult = NS_NewPermanentAtom(aString);
    31   if (!*aResult)
    32     return NS_ERROR_OUT_OF_MEMORY;
    34   return NS_OK;
    35 }
    37 NS_IMETHODIMP
    38 nsAtomService::GetAtomUTF8(const char *aValue, nsIAtom* *aResult)
    39 {
    40     *aResult = NS_NewAtom(aValue).take();
    42     if (!*aResult)
    43         return NS_ERROR_OUT_OF_MEMORY;
    45     return NS_OK;
    46 }
    48 NS_IMETHODIMP
    49 nsAtomService::GetPermanentAtomUTF8(const char *aValue, nsIAtom* *aResult)
    50 {
    51     *aResult = NS_NewPermanentAtom(NS_ConvertUTF8toUTF16(aValue));
    53     if (!*aResult)
    54         return NS_ERROR_OUT_OF_MEMORY;
    56     return NS_OK;
    57 }

mercurial