Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Side by Side Diff: webrtc/examples/objc/AppRTCMobile/third_party/SocketRocket/SRWebSocket.m

Issue 2718703002: Revert of move some warning suppressions from SocketRocket. (Closed)
Patch Set: Introduce temp variable for assert Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/examples/BUILD.gn ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // 1 //
2 // Copyright 2012 Square Inc. 2 // Copyright 2012 Square Inc.
3 // 3 //
4 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License. 5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at 6 // You may obtain a copy of the License at
7 // 7 //
8 // http://www.apache.org/licenses/LICENSE-2.0 8 // http://www.apache.org/licenses/LICENSE-2.0
9 // 9 //
10 // Unless required by applicable law or agreed to in writing, software 10 // Unless required by applicable law or agreed to in writing, software
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 497
498 - (void)didConnect 498 - (void)didConnect
499 { 499 {
500 SRFastLog(@"Connected"); 500 SRFastLog(@"Connected");
501 CFHTTPMessageRef request = CFHTTPMessageCreateRequest(NULL, CFSTR("GET"), (_ _bridge CFURLRef)_url, kCFHTTPVersion1_1); 501 CFHTTPMessageRef request = CFHTTPMessageCreateRequest(NULL, CFSTR("GET"), (_ _bridge CFURLRef)_url, kCFHTTPVersion1_1);
502 502
503 // Set host first so it defaults 503 // Set host first so it defaults
504 CFHTTPMessageSetHeaderFieldValue(request, CFSTR("Host"), (__bridge CFStringR ef)(_url.port ? [NSString stringWithFormat:@"%@:%@", _url.host, _url.port] : _ur l.host)); 504 CFHTTPMessageSetHeaderFieldValue(request, CFSTR("Host"), (__bridge CFStringR ef)(_url.port ? [NSString stringWithFormat:@"%@:%@", _url.host, _url.port] : _ur l.host));
505 505
506 NSMutableData *keyBytes = [[NSMutableData alloc] initWithLength:16]; 506 NSMutableData *keyBytes = [[NSMutableData alloc] initWithLength:16];
507 SecRandomCopyBytes(kSecRandomDefault, keyBytes.length, keyBytes.mutableBytes ); 507 BOOL success = SecRandomCopyBytes(kSecRandomDefault, keyBytes.length, keyByt es.mutableBytes);
508 assert(success);
508 509
509 if ([keyBytes respondsToSelector:@selector(base64EncodedStringWithOptions:)] ) { 510 if ([keyBytes respondsToSelector:@selector(base64EncodedStringWithOptions:)] ) {
510 _secKey = [keyBytes base64EncodedStringWithOptions:0]; 511 _secKey = [keyBytes base64EncodedStringWithOptions:0];
511 } else { 512 } else {
512 _secKey = [keyBytes base64Encoding]; 513 _secKey = [keyBytes base64Encoding];
513 } 514 }
514 515
515 assert([_secKey length] == 24); 516 assert([_secKey length] == 24);
516 517
517 CFHTTPMessageSetHeaderFieldValue(request, CFSTR("Upgrade"), CFSTR("websocket ")); 518 CFHTTPMessageSetHeaderFieldValue(request, CFSTR("Upgrade"), CFSTR("websocket "));
518 CFHTTPMessageSetHeaderFieldValue(request, CFSTR("Connection"), CFSTR("Upgrad e")); 519 CFHTTPMessageSetHeaderFieldValue(request, CFSTR("Connection"), CFSTR("Upgrad e"));
519 CFHTTPMessageSetHeaderFieldValue(request, CFSTR("Sec-WebSocket-Key"), (__bri dge CFStringRef)_secKey); 520 CFHTTPMessageSetHeaderFieldValue(request, CFSTR("Sec-WebSocket-Key"), (__bri dge CFStringRef)_secKey);
520 CFHTTPMessageSetHeaderFieldValue(request, CFSTR("Sec-WebSocket-Version"), (_ _bridge CFStringRef)[NSString stringWithFormat:@"%ld", (long)_webSocketVersion]) ; 521 CFHTTPMessageSetHeaderFieldValue(request, CFSTR("Sec-WebSocket-Version"), (_ _bridge CFStringRef)[NSString stringWithFormat:@"%ld", (long)_webSocketVersion]) ;
521 522
522 CFHTTPMessageSetHeaderFieldValue(request, CFSTR("Origin"), (__bridge CFStrin gRef)_url.SR_origin); 523 CFHTTPMessageSetHeaderFieldValue(request, CFSTR("Origin"), (__bridge CFStrin gRef)_url.SR_origin);
523 524
524 if (_requestedProtocols) { 525 if (_requestedProtocols) {
525 CFHTTPMessageSetHeaderFieldValue(request, CFSTR("Sec-WebSocket-Protocol" ), (__bridge CFStringRef)[_requestedProtocols componentsJoinedByString:@", "]); 526 CFHTTPMessageSetHeaderFieldValue(request, CFSTR("Sec-WebSocket-Protocol" ), (__bridge CFStringRef)[_requestedProtocols componentsJoinedByString:@", "]);
526 } 527 }
527 528
528 [_urlRequest.allHTTPHeaderFields enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { 529 [_urlRequest.allHTTPHeaderFields enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
529 CFHTTPMessageSetHeaderFieldValue(request, (__bridge CFStringRef)key, (__ bridge CFStringRef)obj); 530 CFHTTPMessageSetHeaderFieldValue(request, (__bridge CFStringRef)key, (__ bridge CFStringRef)obj);
530 }]; 531 }];
531 532
532 NSData *message = CFBridgingRelease(CFHTTPMessageCopySerializedMessage(reque st)); 533 NSData *message = CFBridgingRelease(CFHTTPMessageCopySerializedMessage(reque st));
533 534
534 CFRelease(request); 535 CFRelease(request);
535 536
536 [self _writeData:message]; 537 [self _writeData:message];
537 [self _readHTTPHeader]; 538 [self _readHTTPHeader];
538 } 539 }
539 540
540 - (void)_initializeStreams; 541 - (void)_initializeStreams;
541 { 542 {
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after
1354 frame_buffer_size += sizeof(uint64_t); 1355 frame_buffer_size += sizeof(uint64_t);
1355 } 1356 }
1356 1357
1357 if (!useMask) { 1358 if (!useMask) {
1358 for (size_t i = 0; i < payloadLength; i++) { 1359 for (size_t i = 0; i < payloadLength; i++) {
1359 frame_buffer[frame_buffer_size] = unmasked_payload[i]; 1360 frame_buffer[frame_buffer_size] = unmasked_payload[i];
1360 frame_buffer_size += 1; 1361 frame_buffer_size += 1;
1361 } 1362 }
1362 } else { 1363 } else {
1363 uint8_t *mask_key = frame_buffer + frame_buffer_size; 1364 uint8_t *mask_key = frame_buffer + frame_buffer_size;
1364 SecRandomCopyBytes(kSecRandomDefault, sizeof(uint32_t), (uint8_t *)mask_ key); 1365 BOOL success = SecRandomCopyBytes(kSecRandomDefault, sizeof(uint32_t), ( uint8_t *)mask_key);
1366 assert(success);
1365 frame_buffer_size += sizeof(uint32_t); 1367 frame_buffer_size += sizeof(uint32_t);
1366 1368
1367 // TODO: could probably optimize this with SIMD 1369 // TODO: could probably optimize this with SIMD
1368 for (size_t i = 0; i < payloadLength; i++) { 1370 for (size_t i = 0; i < payloadLength; i++) {
1369 frame_buffer[frame_buffer_size] = unmasked_payload[i] ^ mask_key[i % sizeof(uint32_t)]; 1371 frame_buffer[frame_buffer_size] = unmasked_payload[i] ^ mask_key[i % sizeof(uint32_t)];
1370 frame_buffer_size += 1; 1372 frame_buffer_size += 1;
1371 } 1373 }
1372 } 1374 }
1373 1375
1374 assert(frame_buffer_size <= [frame length]); 1376 assert(frame_buffer_size <= [frame length]);
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
1752 } 1754 }
1753 } 1755 }
1754 1756
1755 - (NSRunLoop *)runLoop; 1757 - (NSRunLoop *)runLoop;
1756 { 1758 {
1757 dispatch_group_wait(_waitGroup, DISPATCH_TIME_FOREVER); 1759 dispatch_group_wait(_waitGroup, DISPATCH_TIME_FOREVER);
1758 return _runLoop; 1760 return _runLoop;
1759 } 1761 }
1760 1762
1761 @end 1763 @end
OLDNEW
« no previous file with comments | « webrtc/examples/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698