mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-24 04:16:00 +08:00
Expose way for native modules to modify JSC context
Reviewed By: svcscm Differential Revision: D2933197 fb-gh-sync-id: 32eb943ab341804343bbcadd29f0377fccf75de6 shipit-source-id: 32eb943ab341804343bbcadd29f0377fccf75de6
This commit is contained in:
committed by
facebook-github-bot-1
parent
46a8f1d8e0
commit
e5ba46c30d
@@ -16,6 +16,15 @@
|
||||
*/
|
||||
RCT_EXTERN NSString *const RCTJSCThreadName;
|
||||
|
||||
/**
|
||||
* This notification fires on the JS thread immediately after a `JSContext`
|
||||
* is fully initialized, but before the JS bundle has been loaded. The object
|
||||
* of this notification is the `JSContext`. Native modules should listen for
|
||||
* notification only if they need to install custom functionality into the
|
||||
* context. Note that this notification won't fire when debugging in Chrome.
|
||||
*/
|
||||
RCT_EXTERN NSString *const RCTJavaScriptContextCreatedNotification;
|
||||
|
||||
/**
|
||||
* Uses a JavaScriptCore context as the execution engine.
|
||||
*/
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
|
||||
NSString *const RCTJSCThreadName = @"com.facebook.React.JavaScript";
|
||||
|
||||
NSString *const RCTJavaScriptContextCreatedNotification = @"RCTJavaScriptContextCreatedNotification";
|
||||
|
||||
static NSString *const RCTJSCProfilerEnabledDefaultsKey = @"RCTJSCProfilerEnabled";
|
||||
|
||||
@interface RCTJavaScriptContext : NSObject <RCTInvalidating>
|
||||
@@ -332,7 +334,16 @@ static void RCTInstallJSCProfiler(RCTBridge *bridge, JSContextRef context)
|
||||
}];
|
||||
|
||||
[self executeBlockOnJavaScriptQueue:^{
|
||||
RCTInstallJSCProfiler(_bridge, self.context.ctx);
|
||||
RCTJSCExecutor *strongSelf = weakSelf;
|
||||
if (!strongSelf.valid) {
|
||||
return;
|
||||
}
|
||||
|
||||
JSContext *context = strongSelf.context.context;
|
||||
RCTInstallJSCProfiler(_bridge, context.JSGlobalContextRef);
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:RCTJavaScriptContextCreatedNotification
|
||||
object:context];
|
||||
}];
|
||||
|
||||
for (NSString *event in @[RCTProfileDidStartProfiling, RCTProfileDidEndProfiling]) {
|
||||
|
||||
Reference in New Issue
Block a user