diff --git a/driver/js/src/scope.cc b/driver/js/src/scope.cc index 8880775e5af..e0520bf8e90 100644 --- a/driver/js/src/scope.cc +++ b/driver/js/src/scope.cc @@ -125,8 +125,8 @@ Scope::Scope(std::weak_ptr engine, : engine_(std::move(engine)), context_(nullptr), name_(std::move(name)), - call_ui_function_callback_id_(0), extra_function_map_(std::make_unique()), + call_ui_function_callback_id_(0), performance_(std::make_shared()) {} Scope::~Scope() { diff --git a/framework/ios/debug/websocket/HippySRWebSocket.m b/framework/ios/debug/websocket/HippySRWebSocket.m index d7cbb4f8161..bbe7374dbd1 100644 --- a/framework/ios/debug/websocket/HippySRWebSocket.m +++ b/framework/ios/debug/websocket/HippySRWebSocket.m @@ -111,14 +111,14 @@ @interface _HippySRRunLoopThread : NSThread @implementation NSData (HippySRWebSocket) -- (NSString *)stringBySHA1ThenBase64Encoding; +- (NSString *)stringBySHA1ThenBase64Encoding { return newSHA1String(self.bytes, self.length); } @end @implementation NSString (HippySRWebSocket) -- (NSString *)stringBySHA1ThenBase64Encoding; +- (NSString *)stringBySHA1ThenBase64Encoding { return newSHA1String(self.UTF8String, self.length); } @end @@ -253,7 +253,7 @@ @implementation HippySRWebSocket { static __strong NSData *CRLFCRLF; -+ (void)initialize; ++ (void)initialize { CRLFCRLF = [[NSData alloc] initWithBytes:"\r\n\r\n" length:4]; } - (instancetype)initWithURLRequest:(NSURLRequest *)request protocols:(NSArray *)protocols { @@ -270,13 +270,13 @@ - (instancetype)initWithURLRequest:(NSURLRequest *)request protocols:(NSArray *)protocols; +- (instancetype)initWithURL:(NSURL *)URL protocols:(NSArray *)protocols { NSMutableURLRequest *request; if (URL) { @@ -298,7 +298,7 @@ - (instancetype)initWithURL:(NSURL *)URL protocols:(NSArray *)protoc return [self initWithURLRequest:request protocols:protocols]; } -- (void)_HippySR_commonInit; +- (void)_HippySR_commonInit { NSString *scheme = _url.scheme.lowercaseString; assert( @@ -334,7 +334,7 @@ - (void)_HippySR_commonInit; // default handlers } -- (void)assertOnWorkQueue; +- (void)assertOnWorkQueue { assert(dispatch_get_specific((__bridge void *)self) == (__bridge void *)_workQueue); } - (void)dealloc { @@ -358,7 +358,7 @@ - (void)dealloc { #ifndef NDEBUG -- (void)setReadyState:(HippySRReadyState)aReadyState; +- (void)setReadyState:(HippySRReadyState)aReadyState { [self willChangeValueForKey:@"readyState"]; assert(aReadyState > _readyState); @@ -368,7 +368,7 @@ - (void)setReadyState:(HippySRReadyState)aReadyState; #endif -- (void)open; +- (void)open { assert(_url); HippyAssert(_readyState == HippySR_CONNECTING, @"Cannot call -(void)open on HippySRWebSocket more than once"); @@ -379,7 +379,7 @@ - (void)open; } // Calls block on delegate queue -- (void)_performDelegateBlock:(dispatch_block_t)block; +- (void)_performDelegateBlock:(dispatch_block_t)block { if (_delegateOperationQueue) { [_delegateOperationQueue addOperationWithBlock:block]; @@ -389,10 +389,10 @@ - (void)_performDelegateBlock:(dispatch_block_t)block; } } -- (void)setDelegateDispatchQueue:(dispatch_queue_t)queue; +- (void)setDelegateDispatchQueue:(dispatch_queue_t)queue { _delegateDispatchQueue = queue; } -- (BOOL)_checkHandshake:(CFHTTPMessageRef)httpMessage; +- (BOOL)_checkHandshake:(CFHTTPMessageRef)httpMessage { NSString *acceptHeader = CFBridgingRelease(CFHTTPMessageCopyHeaderFieldValue(httpMessage, CFSTR("Sec-WebSocket-Accept"))); @@ -406,7 +406,7 @@ - (BOOL)_checkHandshake:(CFHTTPMessageRef)httpMessage; return [acceptHeader isEqualToString:expectedAccept]; } -- (void)_HTTPHeadersDidFinish; +- (void)_HTTPHeadersDidFinish { NSInteger responseCode = CFHTTPMessageGetResponseStatusCode(_receivedHTTPHeaders); @@ -454,7 +454,7 @@ - (void)_HTTPHeadersDidFinish; }]; } -- (void)_readHTTPHeader; +- (void)_readHTTPHeader { if (_receivedHTTPHeaders == NULL) { _receivedHTTPHeaders = CFHTTPMessageCreateEmpty(NULL, NO); @@ -511,7 +511,7 @@ - (void)didConnect { [self _readHTTPHeader]; } -- (void)_initializeStreams; +- (void)_initializeStreams { assert(_url.port.unsignedIntValue <= UINT32_MAX); uint32_t port = _url.port.unsignedIntValue; @@ -553,7 +553,7 @@ - (void)_initializeStreams; _outputStream.delegate = self; } -- (void)_connect; +- (void)_connect { if (!_scheduledRunloops.count) { [self scheduleInRunLoop:[NSRunLoop HippySR_networkRunLoop] forMode:NSDefaultRunLoopMode]; @@ -563,7 +563,7 @@ - (void)_connect; [_inputStream open]; } -- (void)scheduleInRunLoop:(NSRunLoop *)aRunLoop forMode:(NSString *)mode; +- (void)scheduleInRunLoop:(NSRunLoop *)aRunLoop forMode:(NSString *)mode { [_outputStream scheduleInRunLoop:aRunLoop forMode:mode]; [_inputStream scheduleInRunLoop:aRunLoop forMode:mode]; @@ -571,7 +571,7 @@ - (void)scheduleInRunLoop:(NSRunLoop *)aRunLoop forMode:(NSString *)mode; [_scheduledRunloops addObject:@[aRunLoop, mode]]; } -- (void)unscheduleFromRunLoop:(NSRunLoop *)aRunLoop forMode:(NSString *)mode; +- (void)unscheduleFromRunLoop:(NSRunLoop *)aRunLoop forMode:(NSString *)mode { [_outputStream removeFromRunLoop:aRunLoop forMode:mode]; [_inputStream removeFromRunLoop:aRunLoop forMode:mode]; @@ -583,7 +583,7 @@ - (void)close { [self closeWithCode:HippySRStatusCodeNormal reason:nil]; } -- (void)closeWithCode:(NSInteger)code reason:(NSString *)reason; +- (void)closeWithCode:(NSInteger)code reason:(NSString *)reason { dispatch_async(_workQueue, ^{ if (self.readyState == HippySR_CLOSING || self.readyState == HippySR_CLOSED) { @@ -631,7 +631,7 @@ - (void)closeWithCode:(NSInteger)code reason:(NSString *)reason; }); } -- (void)_closeWithProtocolError:(NSString *)message; +- (void)_closeWithProtocolError:(NSString *)message { // Need to shunt this on the _callbackQueue first to see if they received any messages [self _performDelegateBlock:^{ @@ -642,7 +642,7 @@ - (void)_closeWithProtocolError:(NSString *)message; }]; } -- (void)_failWithError:(NSError *)error; +- (void)_failWithError:(NSError *)error { dispatch_async(_workQueue, ^{ if (self.readyState != HippySR_CLOSED) { @@ -663,7 +663,7 @@ - (void)_failWithError:(NSError *)error; }); } -- (void)_writeData:(NSData *)data; +- (void)_writeData:(NSData *)data { [self assertOnWorkQueue]; @@ -674,7 +674,7 @@ - (void)_writeData:(NSData *)data; [self _pumpWriting]; } -- (void)send:(id)data; +- (void)send:(id)data { HippyAssert(self.readyState != HippySR_CONNECTING, @"Invalid State: Cannot call send: until connection is open"); // TODO: maybe not copy this for performance @@ -692,7 +692,7 @@ - (void)send:(id)data; }); } -- (void)sendPing:(NSData *)data; +- (void)sendPing:(NSData *)data { HippyAssert(self.readyState == HippySR_OPEN, @"Invalid State: Cannot call send: until connection is open"); // TODO: maybe not copy this for performance @@ -702,7 +702,7 @@ - (void)sendPing:(NSData *)data; }); } -- (void)handlePing:(NSData *)pingData; +- (void)handlePing:(NSData *)pingData { // Need to pingpong this off _callbackQueue first to make sure messages happen in order [self _performDelegateBlock:^{ @@ -712,7 +712,7 @@ - (void)handlePing:(NSData *)pingData; }]; } -- (void)handlePong:(NSData *)pongData; +- (void)handlePong:(NSData *)pongData { HippySRLog(@"Received pong"); [self _performDelegateBlock:^{ @@ -761,7 +761,7 @@ static inline BOOL closeCodeIsValid(int closeCode) { // encoded data with value /reason/, the interpretation of which is not // defined by this specification. -- (void)handleCloseWithData:(NSData *)data; +- (void)handleCloseWithData:(NSData *)data { size_t dataSize = data.length; __block uint16_t closeCode = 0; @@ -800,7 +800,7 @@ - (void)handleCloseWithData:(NSData *)data; }); } -- (void)_disconnect; +- (void)_disconnect { [self assertOnWorkQueue]; HippySRLog(@"Trying to disconnect"); @@ -808,7 +808,7 @@ - (void)_disconnect; [self _pumpWriting]; } -- (void)_handleFrameWithData:(NSData *)frameData opCode:(NSInteger)opcode; +- (void)_handleFrameWithData:(NSData *)frameData opCode:(NSInteger)opcode { // Check that the current data is valid UTF8 @@ -854,7 +854,7 @@ - (void)_handleFrameWithData:(NSData *)frameData opCode:(NSInteger)opcode; } } -- (void)_handleFrameHeader:(frame_header)frame_header curData:(NSData *)curData; +- (void)_handleFrameHeader:(frame_header)frame_header curData:(NSData *)curData { assert(frame_header.opcode != 0); @@ -936,7 +936,7 @@ - (void)_handleFrameHeader:(frame_header)frame_header curData:(NSData *)curData; static const uint8_t HippySRMaskMask = 0x80; static const uint8_t HippySRPayloadLenMask = 0x7F; -- (void)_readFrameContinue; +- (void)_readFrameContinue { assert((_currentFrameCount == 0 && _currentFrameOpcode == 0) || (_currentFrameCount > 0 && _currentFrameOpcode > 0)); @@ -1019,7 +1019,7 @@ - (void)_readFrameContinue; } readToCurrentFrame:NO unmaskBytes:NO]; } -- (void)_readFrameNew; +- (void)_readFrameNew { dispatch_async(_workQueue, ^{ self->_currentFrameData.length = 0; @@ -1033,7 +1033,7 @@ - (void)_readFrameNew; }); } -- (void)_pumpWriting; +- (void)_pumpWriting { [self assertOnWorkQueue]; @@ -1078,7 +1078,7 @@ - (void)_pumpWriting; } } -- (void)_addConsumerWithScanner:(stream_scanner)consumer callback:(data_callback)callback; +- (void)_addConsumerWithScanner:(stream_scanner)consumer callback:(data_callback)callback { [self assertOnWorkQueue]; [self _addConsumerWithScanner:consumer callback:callback dataLength:0]; @@ -1087,7 +1087,7 @@ - (void)_addConsumerWithScanner:(stream_scanner)consumer callback:(data_callback - (void)_addConsumerWithDataLength:(size_t)dataLength callback:(data_callback)callback readToCurrentFrame:(BOOL)readToCurrentFrame - unmaskBytes:(BOOL)unmaskBytes; + unmaskBytes:(BOOL)unmaskBytes { [self assertOnWorkQueue]; assert(dataLength); @@ -1097,7 +1097,7 @@ - (void)_addConsumerWithDataLength:(size_t)dataLength [self _pumpScanner]; } -- (void)_addConsumerWithScanner:(stream_scanner)consumer callback:(data_callback)callback dataLength:(size_t)dataLength; +- (void)_addConsumerWithScanner:(stream_scanner)consumer callback:(data_callback)callback dataLength:(size_t)dataLength { [self assertOnWorkQueue]; [_consumers addObject:[_consumerPool consumerWithScanner:consumer handler:callback bytesNeeded:dataLength readToCurrentFrame:NO unmaskBytes:NO]]; @@ -1106,10 +1106,10 @@ - (void)_addConsumerWithScanner:(stream_scanner)consumer callback:(data_callback static const char CRLFCRLFBytes[] = { '\r', '\n', '\r', '\n' }; -- (void)_readUntilHeaderCompleteWithCallback:(data_callback)dataHandler; +- (void)_readUntilHeaderCompleteWithCallback:(data_callback)dataHandler { [self _readUntilBytes:CRLFCRLFBytes length:sizeof(CRLFCRLFBytes) callback:dataHandler]; } -- (void)_readUntilBytes:(const void *)bytes length:(size_t)length callback:(data_callback)dataHandler; +- (void)_readUntilBytes:(const void *)bytes length:(size_t)length callback:(data_callback)dataHandler { // TODO: optimize so this can continue from where we last searched stream_scanner consumer = ^size_t(NSData *data) { @@ -1242,7 +1242,7 @@ - (BOOL)_innerPumpScanner { return didWork; } -- (void)_pumpScanner; +- (void)_pumpScanner { [self assertOnWorkQueue]; @@ -1262,7 +1262,7 @@ - (void)_pumpScanner; static const size_t HippySRFrameHeaderOverhead = 32; -- (void)_sendFrameWithOpcode:(HippySROpCode)opCode data:(id)data; +- (void)_sendFrameWithOpcode:(HippySROpCode)opCode data:(id)data { [self assertOnWorkQueue]; @@ -1333,7 +1333,7 @@ - (void)_sendFrameWithOpcode:(HippySROpCode)opCode data:(id)data; [self _writeData:frameData]; } -- (void)stream:(NSStream *)aStream handleEvent:(NSStreamEvent)eventCode; +- (void)stream:(NSStream *)aStream handleEvent:(NSStreamEvent)eventCode { if (_secure && !_pinnedCertFound && (eventCode == NSStreamEventHasBytesAvailable || eventCode == NSStreamEventHasSpaceAvailable)) { NSArray *sslCerts = _urlRequest.HippySR_SSLPinnedCertificates; @@ -1466,7 +1466,7 @@ - (void)setupWithScanner:(stream_scanner)scanner handler:(data_callback)handler bytesNeeded:(size_t)bytesNeeded readToCurrentFrame:(BOOL)readToCurrentFrame - unmaskBytes:(BOOL)unmaskBytes; + unmaskBytes:(BOOL)unmaskBytes { _consumer = [scanner copy]; _handler = [handler copy]; @@ -1483,7 +1483,7 @@ @implementation HippySRIOConsumerPool { NSMutableArray *_bufferedConsumers; } -- (instancetype)initWithBufferCapacity:(NSUInteger)poolSize; +- (instancetype)initWithBufferCapacity:(NSUInteger)poolSize { if ((self = [super init])) { _poolSize = poolSize; @@ -1500,7 +1500,7 @@ - (HippySRIOConsumer *)consumerWithScanner:(stream_scanner)scanner handler:(data_callback)handler bytesNeeded:(size_t)bytesNeeded readToCurrentFrame:(BOOL)readToCurrentFrame - unmaskBytes:(BOOL)unmaskBytes; + unmaskBytes:(BOOL)unmaskBytes { HippySRIOConsumer *consumer = nil; if (_bufferedConsumers.count) { @@ -1515,7 +1515,7 @@ - (HippySRIOConsumer *)consumerWithScanner:(stream_scanner)scanner return consumer; } -- (void)returnConsumer:(HippySRIOConsumer *)consumer; +- (void)returnConsumer:(HippySRIOConsumer *)consumer { if (_bufferedConsumers.count < _poolSize) { [_bufferedConsumers addObject:consumer]; @@ -1526,24 +1526,24 @@ - (void)returnConsumer:(HippySRIOConsumer *)consumer; @implementation NSURLRequest (CertificateAdditions) -- (NSArray *)HippySR_SSLPinnedCertificates; +- (NSArray *)HippySR_SSLPinnedCertificates { return [NSURLProtocol propertyForKey:@"HippySR_SSLPinnedCertificates" inRequest:self]; } @end @implementation NSMutableURLRequest (CertificateAdditions) -- (NSArray *)HippySR_SSLPinnedCertificates; +- (NSArray *)HippySR_SSLPinnedCertificates { return [NSURLProtocol propertyForKey:@"HippySR_SSLPinnedCertificates" inRequest:self]; } -- (void)setHippySR_SSLPinnedCertificates:(NSArray *)HippySR_SSLPinnedCertificates; +- (void)setHippySR_SSLPinnedCertificates:(NSArray *)HippySR_SSLPinnedCertificates { [NSURLProtocol setProperty:HippySR_SSLPinnedCertificates forKey:@"HippySR_SSLPinnedCertificates" inRequest:self]; } @end @implementation NSURL (HippySRWebSocket) -- (NSString *)HippySR_origin; +- (NSString *)HippySR_origin { NSString *scheme = self.scheme.lowercaseString; @@ -1597,7 +1597,7 @@ - (instancetype)init { return self; } -- (void)main; +- (void)main { @autoreleasepool { _runLoop = [NSRunLoop currentRunLoop]; @@ -1617,7 +1617,7 @@ - (void)step { // Does nothing } -- (NSRunLoop *)runLoop; +- (NSRunLoop *)runLoop { dispatch_group_wait(_waitGroup, DISPATCH_TIME_FOREVER); return _runLoop; diff --git a/framework/ios/utils/NSObject+CtxValue.mm b/framework/ios/utils/NSObject+CtxValue.mm index 1ee6b0c3fef..00cf1ab915f 100644 --- a/framework/ios/utils/NSObject+CtxValue.mm +++ b/framework/ios/utils/NSObject+CtxValue.mm @@ -30,7 +30,7 @@ @implementation NSObject (CtxValue) -- (CtxValuePtr)convertToCtxValue:(const CtxPtr &)context; { +- (CtxValuePtr)convertToCtxValue:(const CtxPtr &)context { @autoreleasepool { HippyLogWarn(@"%@ No convertToCtxValue method", NSStringFromClass([self class])); std::unordered_map valueMap;