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

Unified Diff: webrtc/examples/objc/AppRTCMobile/ARDAppEngineClient.m

Issue 2780433006: Fix deprecated methods in AppRTCMobile. (Closed)
Patch Set: Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/examples/BUILD.gn ('k') | webrtc/examples/objc/AppRTCMobile/common/ARDUtilities.m » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/examples/objc/AppRTCMobile/ARDAppEngineClient.m
diff --git a/webrtc/examples/objc/AppRTCMobile/ARDAppEngineClient.m b/webrtc/examples/objc/AppRTCMobile/ARDAppEngineClient.m
index d707b92d4486be631f5de4deab0d91e4a662aff1..62a97cd2425a55aad33f77cfa0067669c1433917 100644
--- a/webrtc/examples/objc/AppRTCMobile/ARDAppEngineClient.m
+++ b/webrtc/examples/objc/AppRTCMobile/ARDAppEngineClient.m
@@ -57,29 +57,27 @@ static NSInteger const kARDAppEngineClientErrorBadResponse = -1;
request.HTTPMethod = @"POST";
__weak ARDAppEngineClient *weakSelf = self;
[NSURLConnection sendAsyncRequest:request
- completionHandler:^(NSURLResponse *response,
- NSData *data,
- NSError *error) {
- ARDAppEngineClient *strongSelf = weakSelf;
- if (error) {
- if (completionHandler) {
- completionHandler(nil, error);
- }
- return;
- }
- ARDJoinResponse *joinResponse =
- [ARDJoinResponse responseFromJSONData:data];
- if (!joinResponse) {
- if (completionHandler) {
- NSError *error = [[self class] badResponseError];
- completionHandler(nil, error);
- }
- return;
- }
- if (completionHandler) {
- completionHandler(joinResponse, nil);
- }
- }];
+ completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
+ ARDAppEngineClient *strongSelf = weakSelf;
+ if (error) {
+ if (completionHandler) {
+ completionHandler(nil, error);
+ }
+ return;
+ }
+ ARDJoinResponse *joinResponse = [ARDJoinResponse responseFromJSONData:data];
+ if (!joinResponse) {
+ if (completionHandler) {
+ NSError *error = [[self class] badResponseError];
+ completionHandler(nil, error);
+ }
+ return;
+ }
+ if (completionHandler) {
+ completionHandler(joinResponse, nil);
+ }
+
daniela-webrtc 2017/03/29 12:25:56 Nit: remove extra line
kthelgason 2017/03/29 12:35:24 Done.
+ }];
}
- (void)sendMessage:(ARDSignalingMessage *)message
@@ -138,17 +136,24 @@ static NSInteger const kARDAppEngineClientErrorBadResponse = -1;
NSURL *url = [NSURL URLWithString:urlString];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
request.HTTPMethod = @"POST";
- NSURLResponse *response = nil;
- NSError *error = nil;
+
+ RTCLog(@"C->RS: BYE");
+ __block NSError *error = nil;
+
// We want a synchronous request so that we know that we've left the room on
// room server before we do any further work.
- RTCLog(@"C->RS: BYE");
- [NSURLConnection sendSynchronousRequest:request
- returningResponse:&response
- error:&error];
+ dispatch_semaphore_t sem = dispatch_semaphore_create(0);
+ [NSURLConnection sendAsyncRequest:request
daniela-webrtc 2017/03/29 12:25:56 Is it gonna be too much work to update to NSURLSes
kthelgason 2017/03/29 12:35:25 This is actually using NSURLSession, it's calling
+ completionHandler:^(NSURLResponse *response, NSData *data, NSError *e) {
+ if (e) {
+ error = e;
+ }
+ dispatch_semaphore_signal(sem);
+ }];
+
+ dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
if (error) {
- RTCLogError(@"Error leaving room %@ on room server: %@",
- roomId, error.localizedDescription);
+ RTCLogError(@"Error leaving room %@ on room server: %@", roomId, error.localizedDescription);
if (completionHandler) {
completionHandler(error);
}
« no previous file with comments | « webrtc/examples/BUILD.gn ('k') | webrtc/examples/objc/AppRTCMobile/common/ARDUtilities.m » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698