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

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

Issue 2780433006: Fix deprecated methods in AppRTCMobile. (Closed)
Patch Set: fix nits 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..ad7a6c2bf2b4d409ef6e6e159cbe4bb254ff554d 100644
--- a/webrtc/examples/objc/AppRTCMobile/ARDAppEngineClient.m
+++ b/webrtc/examples/objc/AppRTCMobile/ARDAppEngineClient.m
@@ -57,29 +57,26 @@ 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);
+ }
+ }];
}
- (void)sendMessage:(ARDSignalingMessage *)message
@@ -138,17 +135,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);
magjed_webrtc 2017/03/29 20:03:46 Maybe use rtc::Event instead?
kthelgason 2017/03/30 08:58:53 This is a pure ObjC file, and I'd prefer to keep i
magjed_webrtc 2017/03/30 11:19:46 Acknowledged.
+ [NSURLConnection sendAsyncRequest:request
+ 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