Bug 1480678 part 10 - Remove unnecessary realm entering in TCPSocket::Send. r=bz
authorJan de Mooij <jdemooij@mozilla.com>
Thu, 09 Aug 2018 10:48:29 +0200
changeset 485907 f189ec6420b67a91e26283d968329e728d97e211
parent 485906 1b77b8693df1318724721514073a3f65d7efdd9e
child 485908 27e04584ae0fb6ce64ad5ad2d90e09bf6c73da4f
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1480678
milestone63.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 1480678 part 10 - Remove unnecessary realm entering in TCPSocket::Send. r=bz
dom/network/TCPSocket.cpp
netwerk/base/ArrayBufferInputStream.cpp
netwerk/base/nsIArrayBufferInputStream.idl
--- a/dom/network/TCPSocket.cpp
+++ b/dom/network/TCPSocket.cpp
@@ -853,22 +853,20 @@ TCPSocket::Send(JSContext* aCx,
 
   if (mSocketBridgeChild) {
     nsresult rv = mSocketBridgeChild->SendSend(aData, aByteOffset, byteLength, ++mTrackingNumber);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       aRv.Throw(rv);
       return false;
     }
   } else {
-    JS::Rooted<JSObject*> obj(aCx, aData.Obj());
-    JSAutoRealmAllowCCW ar(aCx, obj);
-    JS::Rooted<JS::Value> value(aCx, JS::ObjectValue(*obj));
+    JS::Rooted<JS::Value> value(aCx, JS::ObjectValue(*aData.Obj()));
 
     stream = do_CreateInstance("@mozilla.org/io/arraybuffer-input-stream;1");
-    nsresult rv = stream->SetData(value, aByteOffset, byteLength, aCx);
+    nsresult rv = stream->SetData(value, aByteOffset, byteLength);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       aRv.Throw(rv);
       return false;
     }
   }
   return Send(stream, byteLength);
 }
 
--- a/netwerk/base/ArrayBufferInputStream.cpp
+++ b/netwerk/base/ArrayBufferInputStream.cpp
@@ -4,38 +4,40 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include <algorithm>
 #include "ArrayBufferInputStream.h"
 #include "nsStreamUtils.h"
 #include "jsapi.h"
 #include "jsfriendapi.h"
 #include "mozilla/UniquePtrExtensions.h"
+#include "mozilla/dom/ScriptSettings.h"
+
+using mozilla::dom::RootingCx;
 
 NS_IMPL_ISUPPORTS(ArrayBufferInputStream, nsIArrayBufferInputStream, nsIInputStream);
 
 ArrayBufferInputStream::ArrayBufferInputStream()
 : mBufferLength(0)
 , mPos(0)
 , mClosed(false)
 {
 }
 
 NS_IMETHODIMP
 ArrayBufferInputStream::SetData(JS::Handle<JS::Value> aBuffer,
                                 uint32_t aByteOffset,
-                                uint32_t aLength,
-                                JSContext* aCx)
+                                uint32_t aLength)
 {
   NS_ASSERT_OWNINGTHREAD(ArrayBufferInputStream);
 
   if (!aBuffer.isObject()) {
     return NS_ERROR_FAILURE;
   }
-  JS::RootedObject arrayBuffer(aCx, &aBuffer.toObject());
+  JS::RootedObject arrayBuffer(RootingCx(), &aBuffer.toObject());
   if (!JS_IsArrayBufferObject(arrayBuffer)) {
     return NS_ERROR_FAILURE;
   }
 
   uint32_t buflen = JS_GetArrayBufferByteLength(arrayBuffer);
   uint32_t offset = std::min(buflen, aByteOffset);
   uint32_t bufferLength = std::min(buflen - offset, aLength);
 
--- a/netwerk/base/nsIArrayBufferInputStream.idl
+++ b/netwerk/base/nsIArrayBufferInputStream.idl
@@ -16,11 +16,10 @@ interface nsIArrayBufferInputStream : ns
 {
     /**
      * SetData - assign an ArrayBuffer to the input stream.
      *
      * @param buffer    - stream data
      * @param byteOffset - stream data offset
      * @param byteLen - stream data length
      */
-    [implicit_jscontext]
     void setData(in jsval buffer, in unsigned long byteOffset, in unsigned long byteLen);
 };