backout 118c07dc56f9 (bug 742179) for windows build bustage
authorDaniel Holbert <dholbert@cs.stanford.edu>
Thu, 05 Apr 2012 10:56:10 -0700
changeset 94407 290dd1ca19b6540f4cac41f32464a4dc3642e5d1
parent 94406 f2c60b01d75aed003c0861094be0d2dc41d135b7
child 94408 b1db4217e0682c2b5d3436cc90262c076c13c9cb
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs742179
milestone14.0a1
backs out118c07dc56f993c3e0d221342d80641bb37552f1
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
backout 118c07dc56f9 (bug 742179) for windows build bustage
netwerk/base/src/nsDownloader.cpp
widget/windows/nsDataObj.cpp
xpcom/glue/nsCRTGlue.cpp
xpcom/glue/nsCRTGlue.h
--- a/netwerk/base/src/nsDownloader.cpp
+++ b/netwerk/base/src/nsDownloader.cpp
@@ -36,17 +36,43 @@
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsDownloader.h"
 #include "nsICachingChannel.h"
 #include "nsIInputStream.h"
 #include "nsDirectoryServiceUtils.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsNetUtil.h"
-#include "nsCRT.h"
+
+// XXX this code is ripped from profile/src/nsProfile.cpp and is further
+//     duplicated in uriloader/exthandler.  this should probably be moved
+//     into xpcom or some other shared library.
+#include <stdlib.h>
+#define TABLE_SIZE 36
+static const char table[] =
+    { 'a','b','c','d','e','f','g','h','i','j',
+      'k','l','m','n','o','p','q','r','s','t',
+      'u','v','w','x','y','z','0','1','2','3',
+      '4','5','6','7','8','9' };
+static void
+MakeRandomString(char *buf, PRInt32 bufLen)
+{
+    // turn PR_Now() into milliseconds since epoch
+    // and salt rand with that.
+    double fpTime;
+    LL_L2D(fpTime, PR_Now());
+    srand((uint)(fpTime * 1e-6 + 0.5));   // use 1e-6, granularity of PR_Now() on the mac is seconds
+
+    PRInt32 i;
+    for (i=0;i<bufLen;i++) {
+        *buf++ = table[rand()%TABLE_SIZE];
+    }
+    *buf = 0;
+}
+// XXX
 
 nsDownloader::~nsDownloader()
 {
     if (mLocation && mLocationIsTemp) {
         // release the sink first since it may still hold an open file
         // descriptor to mLocation.  this needs to happen before the
         // file can be removed otherwise the Remove call will fail.
         if (mSink) {
@@ -85,17 +111,17 @@ nsDownloader::OnStartRequest(nsIRequest 
     if (NS_FAILED(rv)) {
         // OK, we will need to stream the data to disk ourselves.  Make
         // sure mLocation exists.
         if (!mLocation) {
             rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(mLocation));
             if (NS_FAILED(rv)) return rv;
 
             char buf[13];
-            NS_MakeRandomString(buf, 8);
+            MakeRandomString(buf, 8);
             memcpy(buf+8, ".tmp", 5);
             rv = mLocation->AppendNative(nsDependentCString(buf, 12));
             if (NS_FAILED(rv)) return rv;
 
             rv = mLocation->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0600);
             if (NS_FAILED(rv)) return rv;
 
             mLocationIsTemp = true;
--- a/widget/windows/nsDataObj.cpp
+++ b/widget/windows/nsDataObj.cpp
@@ -64,18 +64,43 @@
 #include "nsNetUtil.h"
 #include "nsXPCOMStrings.h"
 #include "nscore.h"
 #include "prtypes.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsITimer.h"
 #include "nsThreadUtils.h"
 
+// XXX Duped from profile/src/nsProfile.cpp.
+#include <stdlib.h>
+
 using namespace mozilla;
 
+#define TABLE_SIZE 36
+static const char table[] =
+    { 'a','b','c','d','e','f','g','h','i','j',
+      'k','l','m','n','o','p','q','r','s','t',
+      'u','v','w','x','y','z','0','1','2','3',
+      '4','5','6','7','8','9' };
+static void
+MakeRandomString(char *buf, PRInt32 bufLen)
+{
+    // turn PR_Now() into milliseconds since epoch
+    // and salt rand with that.
+    double fpTime;
+    LL_L2D(fpTime, PR_Now());
+    srand((uint)(fpTime * 1e-6 + 0.5));   // use 1e-6, granularity of PR_Now() on the mac is seconds
+
+    PRInt32 i;
+    for (i=0;i<bufLen;i++) {
+        *buf++ = table[rand()%TABLE_SIZE];
+    }
+    *buf = 0;
+}
+
 NS_IMPL_ISUPPORTS1(nsDataObj::CStream, nsIStreamListener)
 
 //-----------------------------------------------------------------------------
 // CStream implementation
 nsDataObj::CStream::CStream() :
   mChannelRead(false),
   mStreamRead(0)
 {
@@ -1437,17 +1462,17 @@ HRESULT nsDataObj::DropImage(FORMATETC& 
       GlobalFree(bits);
       return E_FAIL;
     }
 
     // Filename must be random so as not to confuse apps like
     // Photoshop which handle multiple drags into a single window.
     char buf[13];
     nsCString filename;
-    NS_MakeRandomString(buf, 8);
+    MakeRandomString(buf, 8);
     memcpy(buf+8, ".bmp", 5);
     filename.Append(nsDependentCString(buf, 12));
     dropFile->AppendNative(filename);
     rv = dropFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0660);
     if (NS_FAILED(rv)) { 
       GlobalFree(bits);
       return E_FAIL;
     }
--- a/xpcom/glue/nsCRTGlue.cpp
+++ b/xpcom/glue/nsCRTGlue.cpp
@@ -36,19 +36,16 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsCRTGlue.h"
 #include "nsXPCOM.h"
 #include "nsDebug.h"
-#include "prtime.h"
-
-#include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdarg.h>
 
 #ifdef XP_WIN
 #include <io.h>
 #endif
 
@@ -268,40 +265,16 @@ bool NS_IsAsciiWhitespace(PRUnichar aCha
          aChar == '\t';
 }
 
 bool NS_IsAsciiDigit(PRUnichar aChar)
 {
   return aChar >= '0' && aChar <= '9';
 }
 
-
-#define TABLE_SIZE 36
-static const char table[] = {
-  'a','b','c','d','e','f','g','h','i','j',
-  'k','l','m','n','o','p','q','r','s','t',
-  'u','v','w','x','y','z','0','1','2','3',
-  '4','5','6','7','8','9'
-};
-
-void NS_MakeRandomString(char *aBuf, PRInt32 aBufLen)
-{
-  // turn PR_Now() into milliseconds since epoch
-  // and salt rand with that.
-  double fpTime;
-  LL_L2D(fpTime, PR_Now());
-  srand((uint)(fpTime * 1e-6 + 0.5));   // use 1e-6, granularity of PR_Now() on the mac is seconds
-
-  PRInt32 i;
-  for (i=0;i<aBufLen;i++) {
-    *aBuf++ = table[rand()%TABLE_SIZE];
-  }
-  *aBuf = 0;
-}
-
 #if defined(XP_WIN)
 void
 printf_stderr(const char *fmt, ...)
 {
   FILE *fp = _fdopen(_dup(2), "a");
   if (!fp)
       return;
 
--- a/xpcom/glue/nsCRTGlue.h
+++ b/xpcom/glue/nsCRTGlue.h
@@ -128,18 +128,16 @@ NS_COM_GLUE bool NS_IsLower(char aChar);
 NS_COM_GLUE bool NS_IsAscii(PRUnichar aChar);
 NS_COM_GLUE bool NS_IsAscii(const PRUnichar* aString);
 NS_COM_GLUE bool NS_IsAsciiAlpha(PRUnichar aChar);
 NS_COM_GLUE bool NS_IsAsciiDigit(PRUnichar aChar);
 NS_COM_GLUE bool NS_IsAsciiWhitespace(PRUnichar aChar);
 NS_COM_GLUE bool NS_IsAscii(const char* aString);
 NS_COM_GLUE bool NS_IsAscii(const char* aString, PRUint32 aLength);
 
-NS_COM_GLUE void NS_MakeRandomString(char *buf, PRInt32 bufLen);
-
 #define FF '\f'
 #define TAB '\t'
 
 #define CRSTR "\015"
 #define LFSTR "\012"
 #define CRLF "\015\012"     /* A CR LF equivalent string */
 
 #if defined(XP_MACOSX)