Bug 1332639 - Remove the external string API: nsStringAPI.h/cpp and nsEmbedString.h, r=glandium
authorBenjamin Smedberg <benjamin@smedbergs.us>
Mon, 27 Feb 2017 11:41:52 -0500
changeset 345311 a8f45b2afbf3bc116fc9c52d4631e426fb3d5733
parent 345310 cae4a255be3f8edf44a4e6a91ef16a214bd1c9fe
child 345312 36730ac6b59ff964fcc0fdfdc9425aad6349272c
push id31436
push userkwierso@gmail.com
push dateThu, 02 Mar 2017 01:18:52 +0000
treeherdermozilla-central@e91de6fb2b3d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs1332639
milestone54.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1332639 - Remove the external string API: nsStringAPI.h/cpp and nsEmbedString.h, r=glandium MozReview-Commit-ID: 9dZcmMAI0Vk
dom/media/webrtc/PeerIdentity.h
gfx/thebes/gfxASurface.h
netwerk/base/nsNetUtil.h
toolkit/profile/ProfileUnlockerWin.h
toolkit/profile/nsProfileLock.cpp
toolkit/profile/nsProfileStringTypes.h
xpcom/glue/FileUtils.cpp
xpcom/glue/FileUtils.h
xpcom/glue/moz.build
xpcom/glue/nsStringGlue.h
xpcom/string/moz.build
xpcom/string/nsEmbedString.h
--- a/dom/media/webrtc/PeerIdentity.h
+++ b/dom/media/webrtc/PeerIdentity.h
@@ -2,21 +2,17 @@
   * vim: sw=2 ts=2 sts=2 expandtab
   * This Source Code Form is subject to the terms of the Mozilla Public
   * License, v. 2.0. If a copy of the MPL was not distributed with this
   * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef PeerIdentity_h
 #define PeerIdentity_h
 
-#ifdef MOZILLA_INTERNAL_API
 #include "nsString.h"
-#else
-#include "nsStringAPI.h"
-#endif
 
 template <class T> class nsCOMPtr;
 class nsIIDNService;
 
 namespace mozilla {
 
 /**
  * This class implements the identifier used in WebRTC identity.  Peers are
--- a/gfx/thebes/gfxASurface.h
+++ b/gfx/thebes/gfxASurface.h
@@ -9,21 +9,17 @@
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/UniquePtr.h"
 
 #include "gfxTypes.h"
 #include "nscore.h"
 #include "nsSize.h"
 #include "mozilla/gfx/Rect.h"
 
-#ifdef MOZILLA_INTERNAL_API
 #include "nsStringFwd.h"
-#else
-#include "nsStringAPI.h"
-#endif
 
 class gfxImageSurface;
 struct gfxRect;
 struct gfxPoint;
 
 template <typename T>
 struct already_AddRefed;
 
--- a/netwerk/base/nsNetUtil.h
+++ b/netwerk/base/nsNetUtil.h
@@ -13,17 +13,19 @@
 #include "nsILoadGroup.h"
 #include "nsINetUtil.h"
 #include "nsIRequest.h"
 #include "nsILoadInfo.h"
 #include "nsIIOService.h"
 #include "mozilla/Services.h"
 #include "mozilla/Unused.h"
 #include "nsNetCID.h"
+#include "nsReadableUtils.h"
 #include "nsServiceManagerUtils.h"
+#include "nsString.h"
 
 class nsIURI;
 class nsIPrincipal;
 class nsIAsyncStreamCopier;
 class nsIAuthPrompt;
 class nsIAuthPrompt2;
 class nsIChannel;
 class nsIChannelPolicy;
@@ -49,37 +51,20 @@ class nsIIncrementalStreamLoaderObserver
 class nsIUnicharStreamLoader;
 class nsIUnicharStreamLoaderObserver;
 
 namespace mozilla { class OriginAttributes; }
 
 template <class> class nsCOMPtr;
 template <typename> struct already_AddRefed;
 
-#ifdef MOZILLA_INTERNAL_API
-#include "nsReadableUtils.h"
-#include "nsString.h"
-#else
-#include "nsStringAPI.h"
-#endif
-
-#ifdef MOZILLA_INTERNAL_API
 already_AddRefed<nsIIOService> do_GetIOService(nsresult *error = 0);
 
 already_AddRefed<nsINetUtil> do_GetNetUtil(nsresult *error = 0);
 
-#else
-// Helper, to simplify getting the I/O service.
-const nsGetServiceByContractIDWithError do_GetIOService(nsresult *error = 0);
-
-// An alias to do_GetIOService
-const nsGetServiceByContractIDWithError do_GetNetUtil(nsresult *error = 0);
-
-#endif
-
 // private little helper function... don't call this directly!
 nsresult net_EnsureIOService(nsIIOService **ios, nsCOMPtr<nsIIOService> &grip);
 
 nsresult NS_NewURI(nsIURI **result,
                    const nsACString &spec,
                    const char *charset = nullptr,
                    nsIURI *baseURI = nullptr,
                    nsIIOService *ioService = nullptr);     // pass in nsIIOService to optimize callers
@@ -554,25 +539,20 @@ NS_BufferInputStream(nsIInputStream *aIn
 nsresult NS_NewPostDataStream(nsIInputStream  **result,
                               bool              isFile,
                               const nsACString &data);
 
 nsresult NS_ReadInputStreamToBuffer(nsIInputStream *aInputStream,
                                     void **aDest,
                                     uint32_t aCount);
 
-// external code can't see fallible_t
-#ifdef MOZILLA_INTERNAL_API
-
 nsresult NS_ReadInputStreamToString(nsIInputStream *aInputStream,
                                     nsACString &aDest,
                                     uint32_t aCount);
 
-#endif
-
 nsresult
 NS_LoadPersistentPropertiesFromURISpec(nsIPersistentProperties **outResult,
                                        const nsACString         &aSpec);
 
 /**
  * NS_QueryNotificationCallbacks implements the canonical algorithm for
  * querying interfaces from a channel's notification callbacks.  It first
  * searches the channel's notificationCallbacks attribute, and if the interface
@@ -974,14 +954,9 @@ const static  int64_t kJS_MAX_SAFE_INTEG
 bool InScriptableRange(int64_t val);
 
 // Make sure a 64bit value can be captured by JS MAX_SAFE_INTEGER
 bool InScriptableRange(uint64_t val);
 
 } // namespace net
 } // namespace mozilla
 
-// Include some function bodies for callers with external linkage
-#ifndef MOZILLA_INTERNAL_API
-#include "nsNetUtilInlines.h"
-#endif
-
 #endif // !nsNetUtil_h__
--- a/toolkit/profile/ProfileUnlockerWin.h
+++ b/toolkit/profile/ProfileUnlockerWin.h
@@ -6,17 +6,17 @@
 
 #ifndef ProfileUnlockerWin_h
 #define ProfileUnlockerWin_h
 
 #include <windows.h>
 #include <restartmanager.h>
 
 #include "nsIProfileUnlocker.h"
-#include "nsProfileStringTypes.h"
+#include "nsString.h"
 #include "nsWindowsHelpers.h"
 
 namespace mozilla {
 
 class ProfileUnlockerWin final : public nsIProfileUnlocker
 {
 public:
   NS_DECL_ISUPPORTS
--- a/toolkit/profile/nsProfileLock.cpp
+++ b/toolkit/profile/nsProfileLock.cpp
@@ -1,17 +1,17 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "nsProfileStringTypes.h"
 #include "nsProfileLock.h"
 #include "nsCOMPtr.h"
 #include "nsQueryObject.h"
+#include "nsString.h"
 
 #if defined(XP_WIN)
 #include "ProfileUnlockerWin.h"
 #include "nsAutoPtr.h"
 #endif
 
 #if defined(XP_MACOSX)
 #include <Carbon/Carbon.h>
deleted file mode 100644
--- a/toolkit/profile/nsProfileStringTypes.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * We support two builds of the directory service provider.
- * One, linked into the profile component, uses the internal
- * string API. The other can be used by standalone embedding
- * clients, and uses embed strings.
- * To keep the code clean, we are using typedefs to equate
- * embed/internal string types. We are also defining some
- * internal macros in terms of the embedding strings API.
- *
- * When modifying the profile directory service provider, be
- * sure to use methods supported by both the internal and
- * embed strings APIs.
- */
-
-#ifndef MOZILLA_INTERNAL_API
-
-#include "nsEmbedString.h"
-
-typedef nsCString nsPromiseFlatCString;
-typedef nsCString nsAutoCString;
-
-#define PromiseFlatCString nsCString
-
-#else
-#include "nsString.h"
-#include "nsPromiseFlatString.h"
-#endif
--- a/xpcom/glue/FileUtils.cpp
+++ b/xpcom/glue/FileUtils.cpp
@@ -3,17 +3,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include <errno.h>
 #include <stdio.h>
 
 #include "nscore.h"
-#include "nsStringGlue.h"
 #include "private/pprio.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/FileUtils.h"
 
 #if defined(XP_MACOSX)
 #include <fcntl.h>
 #include <unistd.h>
 #include <mach/machine.h>
@@ -31,17 +30,19 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #elif defined(XP_WIN)
 #include <windows.h>
 #endif
 
 // Functions that are not to be used in standalone glue must be implemented
 // within this #if block
-#if !defined(XPCOM_GLUE)
+#if defined(MOZILLA_INTERNAL_API)
+
+#include "nsString.h"
 
 bool
 mozilla::fallocate(PRFileDesc* aFD, int64_t aLength)
 {
 #if defined(HAVE_POSIX_FALLOCATE)
   return posix_fallocate(PR_FileDesc2NativeHandle(aFD), 0, aLength) == 0;
 #elif defined(XP_WIN)
   int64_t oldpos = PR_Seek64(aFD, 0, PR_SEEK_CUR);
--- a/xpcom/glue/FileUtils.h
+++ b/xpcom/glue/FileUtils.h
@@ -45,17 +45,17 @@ struct ScopedCloseFDTraits
     if (aFd != -1) {
       while (close(aFd) == -1 && errno == EINTR) {
       }
     }
   }
 };
 typedef Scoped<ScopedCloseFDTraits> ScopedClose;
 
-#if !defined(XPCOM_GLUE)
+#if defined(MOZILLA_INTERNAL_API)
 
 /**
  * AutoFDClose is a RAII wrapper for PRFileDesc.
  *
  * Instances |PR_Close| their fds when they go out of scope.
  **/
 struct ScopedClosePRFDTraits
 {
@@ -114,17 +114,17 @@ void ReadAheadLib(nsIFile* aFile);
  * @param aCount Number of bytes to preload (SIZE_MAX implies file size)
  * @param aOutFd Pointer to file descriptor. If specified, ReadAheadFile will
  *        return its internal, opened file descriptor instead of closing it.
  */
 void ReadAheadFile(nsIFile* aFile, const size_t aOffset = 0,
                    const size_t aCount = SIZE_MAX,
                    filedesc_t* aOutFd = nullptr);
 
-#endif // !defined(XPCOM_GLUE)
+#endif // MOZILLA_INTERNAL_API
 
 /**
  * Use readahead to preload shared libraries into the file cache before loading.
  * WARNING: This function should not be used without a telemetry field trial
  *          demonstrating a clear performance improvement!
  *
  * @param aFilePath path to shared library
  */
--- a/xpcom/glue/moz.build
+++ b/xpcom/glue/moz.build
@@ -5,17 +5,16 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 with Files('nsString*'):
     BUG_COMPONENT = ('Core', 'String')
 
 DIRS += ['standalone']
 
 EXPORTS += [
-    'nsStringAPI.h',
     'nsStringGlue.h',
 ]
 
 EXPORTS.mozilla += [
     'FileUtils.h',
 ]
 
 if CONFIG['ENABLE_TESTS']:
--- a/xpcom/glue/nsStringGlue.h
+++ b/xpcom/glue/nsStringGlue.h
@@ -9,16 +9,16 @@
  * @file nsStringGlue.h
  * This header exists solely to #include the proper internal/frozen string
  * headers, depending on whether MOZILLA_INTERNAL_API is defined.
  */
 
 #ifndef nsStringGlue_h__
 #define nsStringGlue_h__
 
-#ifdef MOZILLA_INTERNAL_API
+#ifndef MOZILLA_INTERNAL_API
+#error "Using XPCOM strings is limited to code linked into libxul."
+#endif
+
 #include "nsString.h"
 #include "nsReadableUtils.h"
-#else
-#include "nsStringAPI.h"
-#endif
 
 #endif // nsStringGlue_h__
--- a/xpcom/string/moz.build
+++ b/xpcom/string/moz.build
@@ -7,17 +7,16 @@
 with Files('**'):
     BUG_COMPONENT = ('Core', 'String')
 
 EXPORTS += [
     'nsAString.h',
     'nsCharTraits.h',
     'nsDependentString.h',
     'nsDependentSubstring.h',
-    'nsEmbedString.h',
     'nsLiteralString.h',
     'nsPrintfCString.h',
     'nsPromiseFlatString.h',
     'nsReadableUtils.h',
     'nsString.h',
     'nsStringBuffer.h',
     'nsStringFwd.h',
     'nsStringIterator.h',
deleted file mode 100644
--- a/xpcom/string/nsEmbedString.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef nsEmbedString_h___
-#define nsEmbedString_h___
-
-#include "nsStringAPI.h"
-
-/**
- * compatibility
- */
-typedef nsString  nsEmbedString;
-typedef nsCString nsEmbedCString;
-
-#endif