Backed out changeset e96494792b66 (bug 335545)
authorSebastian Hengst <archaeopteryx@coole-files.de>
Wed, 20 Sep 2017 23:59:57 +0200
changeset 382061 e8f4ef8801fbe8013a7cb0eeb5a7fae23db19edf
parent 382060 0fb5cc4927b16358eb6fa8b6359c944ce077f1dc
child 382062 6694f4b93826511dd254dd36a7044891329beaf2
push id32546
push userarchaeopteryx@coole-files.de
push dateThu, 21 Sep 2017 13:14:27 +0000
treeherdermozilla-central@9caeafcec998 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs335545
milestone57.0a1
backs oute96494792b66b2b7d8199d532164a3d23f66b004
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
Backed out changeset e96494792b66 (bug 335545)
widget/nsTransferable.cpp
widget/nsTransferable.h
--- a/widget/nsTransferable.cpp
+++ b/widget/nsTransferable.cpp
@@ -63,47 +63,42 @@ DataStruct::~DataStruct()
 //-------------------------------------------------------------------------
 void
 DataStruct::SetData ( nsISupports* aData, uint32_t aDataLen, bool aIsPrivateData )
 {
   // Now, check to see if we consider the data to be "too large"
   // as well as ensuring that private browsing mode is disabled
   if (aDataLen > kLargeDatasetSize && !aIsPrivateData) {
     // if so, cache it to disk instead of memory
-    if (NS_SUCCEEDED(WriteCache(aData, aDataLen))) {
-      // Clear previously set small data.
-      mData = nullptr;
-      mDataLen = 0;
+    if ( NS_SUCCEEDED(WriteCache(aData, aDataLen)) )
       return;
-    }
-    NS_WARNING("Oh no, couldn't write data to the cache file");
+    else
+			NS_WARNING("Oh no, couldn't write data to the cache file");
   }
 
   mData    = aData;
   mDataLen = aDataLen;
 }
 
 
 //-------------------------------------------------------------------------
 void
 DataStruct::GetData ( nsISupports** aData, uint32_t *aDataLen )
 {
   // check here to see if the data is cached on disk
-  if (mCacheFD) {
+  if ( !mData && mCacheFD ) {
     // if so, read it in and pass it back
     // ReadCache creates memory and copies the data into it.
     if ( NS_SUCCEEDED(ReadCache(aData, aDataLen)) )
       return;
     else {
       // oh shit, something went horribly wrong here.
       NS_WARNING("Oh no, couldn't read data in from the cache file");
       *aData = nullptr;
       *aDataLen = 0;
-      PR_Close(mCacheFD);
-      mCacheFD = nullptr;
       return;
     }
   }
 
   *aData = mData;
   if ( mData )
     NS_ADDREF(*aData);
   *aDataLen = mDataLen;
@@ -127,18 +122,16 @@ DataStruct::WriteCache(nsISupports* aDat
   nsPrimitiveHelpers::CreateDataFromPrimitive(mFlavor, aData, &buff, aDataLen);
   if (buff) {
     int32_t written = PR_Write(mCacheFD, buff, aDataLen);
     free(buff);
     if (written) {
       return NS_OK;
     }
   }
-  PR_Close(mCacheFD);
-  mCacheFD = nullptr;
   return NS_ERROR_FAILURE;
 }
 
 
 //-------------------------------------------------------------------------
 nsresult
 DataStruct::ReadCache(nsISupports** aData, uint32_t* aDataLen)
 {
--- a/widget/nsTransferable.h
+++ b/widget/nsTransferable.h
@@ -38,17 +38,16 @@ protected:
     // The size of data over which we write the data to disk rather than
     // keep it around in memory.
     kLargeDatasetSize = 1000000        // 1 million bytes
   };
   
   nsresult WriteCache(nsISupports* aData, uint32_t aDataLen );
   nsresult ReadCache(nsISupports** aData, uint32_t* aDataLen );
   
-  // mData + mDataLen OR mCacheFD should be used, not both.
   nsCOMPtr<nsISupports> mData;   // OWNER - some varient of primitive wrapper
   uint32_t mDataLen;
   PRFileDesc* mCacheFD;
   const nsCString mFlavor;
 
 };
 
 /**