Bug 677079 - Part f: Expose structuredCloneCallbacks in jsfriendapi.h; r=jorendorff
authorMs2ger <ms2ger@gmail.com>
Sun, 15 Jan 2012 09:13:08 +0100
changeset 84458 6ffce4fb752ba5b7ae02a844415aa0ced8607462
parent 84457 10519108297f9e61058a85623e085a3cda243b8a
child 84459 58eef6ad44addac145082de0c48fce67e6f1feea
push id21852
push userMs2ger@gmail.com
push dateSun, 15 Jan 2012 08:23:22 +0000
treeherdermozilla-central@d7984d345c24 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs677079
milestone12.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 677079 - Part f: Expose structuredCloneCallbacks in jsfriendapi.h; r=jorendorff
dom/base/nsGlobalWindow.cpp
dom/indexedDB/IDBObjectStore.cpp
js/src/jsfriendapi.cpp
js/src/jsfriendapi.h
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -252,18 +252,16 @@
 #include "mozilla/Telemetry.h"
 #include "nsLocation.h"
 #include "nsWrapperCacheInlines.h"
 
 #ifdef ANDROID
 #include <android/log.h>
 #endif
 
-#include "jscntxt.h" // cx->runtime->structuredCloneCallbacks
-
 #ifdef PR_LOGGING
 static PRLogModuleInfo* gDOMLeakPRLog;
 #endif
 
 static const char kStorageEnabled[] = "dom.storage.enabled";
 
 using namespace mozilla;
 using namespace mozilla::dom;
@@ -6026,17 +6024,17 @@ PostMessageReadStructuredClone(JSContext
                                                     getter_AddRefs(wrapper)))) {
           return JSVAL_TO_OBJECT(val);
         }
       }
     }
   }
 
   const JSStructuredCloneCallbacks* runtimeCallbacks =
-    cx->runtime->structuredCloneCallbacks;
+    js::GetContextStructuredCloneCallbacks(cx);
 
   if (runtimeCallbacks) {
     return runtimeCallbacks->read(cx, reader, tag, data, nsnull);
   }
 
   return JS_FALSE;
 }
 
@@ -6066,17 +6064,17 @@ PostMessageWriteStructuredClone(JSContex
 
     if (scTag)
       return JS_WriteUint32Pair(writer, scTag, 0) &&
              JS_WriteBytes(writer, &supports, sizeof(supports)) &&
              scInfo->event->StoreISupports(supports);
   }
 
   const JSStructuredCloneCallbacks* runtimeCallbacks =
-    cx->runtime->structuredCloneCallbacks;
+    js::GetContextStructuredCloneCallbacks(cx);
 
   if (runtimeCallbacks) {
     return runtimeCallbacks->write(cx, writer, obj, nsnull);
   }
 
   return JS_FALSE;
 }
 
--- a/dom/indexedDB/IDBObjectStore.cpp
+++ b/dom/indexedDB/IDBObjectStore.cpp
@@ -36,17 +36,16 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "IDBObjectStore.h"
 
 #include "nsIJSContextStack.h"
 
-#include "jscntxt.h" // structuredCloneCallbacks
 #include "jsfriendapi.h"
 #include "mozilla/dom/StructuredCloneTags.h"
 #include "mozilla/storage.h"
 #include "nsCharSeparatedTokenizer.h"
 #include "nsContentUtils.h"
 #include "nsDOMClassInfo.h"
 #include "nsDOMFile.h"
 #include "nsDOMLists.h"
@@ -1019,17 +1018,17 @@ IDBObjectStore::StructuredCloneReadCallb
       NS_WARNING("Failed to wrap native!");
       return nsnull;
     }
 
     return JSVAL_TO_OBJECT(wrappedFile);
   }
 
   const JSStructuredCloneCallbacks* runtimeCallbacks =
-    aCx->runtime->structuredCloneCallbacks;
+    js::GetContextStructuredCloneCallbacks(aCx);
 
   if (runtimeCallbacks) {
     return runtimeCallbacks->read(aCx, aReader, aTag, aData, nsnull);
   }
 
   return nsnull;
 }
 
@@ -1100,17 +1099,17 @@ IDBObjectStore::StructuredCloneWriteCall
       cloneWriteInfo->mBlobs.AppendElement(blob);
 
       return true;
     }
   }
 
   // try using the runtime callbacks
   const JSStructuredCloneCallbacks* runtimeCallbacks =
-    aCx->runtime->structuredCloneCallbacks;
+    js::GetContextStructuredCloneCallbacks(aCx);
   if (runtimeCallbacks) {
     return runtimeCallbacks->write(aCx, aWriter, aObj, nsnull);
   }
 
   return false;
 }
 
 nsresult
--- a/js/src/jsfriendapi.cpp
+++ b/js/src/jsfriendapi.cpp
@@ -487,16 +487,22 @@ void
 AutoLockGC::lock(JSRuntime *rt)
 {
     JS_ASSERT(rt);
     JS_ASSERT(!runtime);
     runtime = rt;
     JS_LOCK_GC(rt);
 }
 
+JS_FRIEND_API(const JSStructuredCloneCallbacks *)
+GetContextStructuredCloneCallbacks(JSContext *cx)
+{
+    return cx->runtime->structuredCloneCallbacks;
+}
+
 #ifdef JS_THREADSAFE
 JSThread *
 GetContextThread(const JSContext *cx)
 {
     return cx->thread();
 }
 #endif
 
--- a/js/src/jsfriendapi.h
+++ b/js/src/jsfriendapi.h
@@ -481,16 +481,19 @@ class JS_FRIEND_API(AutoLockGC)
   private:
     static void LockGC(JSRuntime *rt);
     static void UnlockGC(JSRuntime *rt);
 
     JSRuntime *runtime;
     MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 };
 
+extern JS_FRIEND_API(const JSStructuredCloneCallbacks *)
+GetContextStructuredCloneCallbacks(JSContext *cx);
+
 } /* namespace js */
 
 /*
  * If protoKey is not JSProto_Null, then clasp is ignored. If protoKey is
  * JSProto_Null, clasp must non-null.
  */
 extern JS_FRIEND_API(JSBool)
 js_GetClassPrototype(JSContext *cx, JSObject *scope, JSProtoKey protoKey,