Changeset 186010 in webkit
- Timestamp:
- Jun 26, 2015 3:14:44 PM (9 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r186008 r186010 1 2015-06-26 Mark Lam <mark.lam@apple.com> 2 3 ScriptMessageHandlerDelegate::didPostMessage() should reuse its JSContext instance. 4 https://bugs.webkit.org/show_bug.cgi?id=146358 5 6 Reviewed by Anders Carlsson. 7 8 Currently, ScriptMessageHandlerDelegate::didPostMessage() creates a new JSContext each 9 time it is called. This JSContext is used only once to deserialized a JSON object 10 and then destroyed. We will change ScriptMessageHandlerDelegate to cache the JSContext 11 and reuse it in all subsequent calls to didPostMessage(). 12 13 Also added a @autoreleasepool scope in didPostMessage() so that transient ObjC objects 14 will be release sooner. 15 16 * UIProcess/API/Cocoa/WKUserContentController.mm: 17 1 18 2015-06-26 Beth Dakin <bdakin@apple.com> 2 19 -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUserContentController.mm
r185877 r186010 41 41 #import <JavaScriptCore/JSContext.h> 42 42 #import <JavaScriptCore/JSValue.h> 43 #import <WTF/MainThread.h> 43 44 #import <WebCore/SerializedScriptValue.h> 44 45 … … 88 89 virtual void didPostMessage(WebKit::WebPageProxy& page, WebKit::WebFrameProxy& frame, const WebKit::SecurityOriginData& securityOriginData, WebCore::SerializedScriptValue& serializedScriptValue) 89 90 { 90 RetainPtr<WKFrameInfo> frameInfo = wrapper(API::FrameInfo::create(frame, securityOriginData.securityOrigin())); 91 @autoreleasepool { 92 RetainPtr<WKFrameInfo> frameInfo = wrapper(API::FrameInfo::create(frame, securityOriginData.securityOrigin())); 91 93 92 RetainPtr<JSContext> context = adoptNS([[JSContext alloc] init]); 93 JSValueRef valueRef = serializedScriptValue.deserialize([context JSGlobalContextRef], 0); 94 JSValue *value = [JSValue valueWithJSValueRef:valueRef inContext:context.get()]; 95 id body = [value toObject]; 94 ASSERT(isUIThread()); 95 static JSContext* context = [[JSContext alloc] init]; 96 96 97 RetainPtr<WKScriptMessage> message = adoptNS([[WKScriptMessage alloc] _initWithBody:body webView:fromWebPageProxy(page) frameInfo:frameInfo.get() name:m_name.get()]); 98 99 [m_handler userContentController:m_controller.get() didReceiveScriptMessage:message.get()]; 97 JSValueRef valueRef = serializedScriptValue.deserialize([context JSGlobalContextRef], 0); 98 JSValue *value = [JSValue valueWithJSValueRef:valueRef inContext:context]; 99 id body = value.toObject; 100 101 auto message = adoptNS([[WKScriptMessage alloc] _initWithBody:body webView:fromWebPageProxy(page) frameInfo:frameInfo.get() name:m_name.get()]); 102 103 [m_handler userContentController:m_controller.get() didReceiveScriptMessage:message.get()]; 104 } 100 105 } 101 106
Note: See TracChangeset
for help on using the changeset viewer.