| Index: remoting/ios/session/remoting_client.mm
|
| diff --git a/remoting/ios/session/remoting_client.mm b/remoting/ios/session/remoting_client.mm
|
| index 8208fbc05156f74aa717173830d435caa8cddade..7a24abcc5695d1022297c87e042108aa62e874a1 100644
|
| --- a/remoting/ios/session/remoting_client.mm
|
| +++ b/remoting/ios/session/remoting_client.mm
|
| @@ -36,7 +36,7 @@ NSString* const kHostSessionPin = @"kHostSessionPin";
|
| @interface RemotingClient () {
|
| remoting::ChromotingClientRuntime* _runtime;
|
| std::unique_ptr<remoting::ChromotingSession> _session;
|
| - remoting::RemotingClientSessonDelegate* _sessonDelegate;
|
| + std::unique_ptr<remoting::RemotingClientSessonDelegate> _sessonDelegate;
|
| ClientSessionDetails* _sessionDetails;
|
| // Call _secretFetchedCallback on the network thread.
|
| remoting::protocol::SecretFetchedCallback _secretFetchedCallback;
|
| @@ -54,7 +54,7 @@ NSString* const kHostSessionPin = @"kHostSessionPin";
|
| self = [super init];
|
| if (self) {
|
| _runtime = remoting::ChromotingClientRuntime::GetInstance();
|
| - _sessonDelegate = new remoting::RemotingClientSessonDelegate(self);
|
| + _sessonDelegate.reset(new remoting::RemotingClientSessonDelegate(self));
|
| _sessionDetails = [[ClientSessionDetails alloc] init];
|
|
|
| [[NSNotificationCenter defaultCenter]
|
| @@ -99,16 +99,25 @@ NSString* const kHostSessionPin = @"kHostSessionPin";
|
| client_auth_config.host_id = info.host_id;
|
| client_auth_config.pairing_client_id = info.pairing_id;
|
| client_auth_config.pairing_secret = info.pairing_secret;
|
| +
|
| + // ChromotingClient keeps strong reference to |client_auth_config| through its
|
| + // lifetime.
|
| + __weak RemotingClient* weakSelf = self;
|
| client_auth_config.fetch_secret_callback = base::BindBlockArc(
|
| ^(bool pairing_supported, const remoting::protocol::SecretFetchedCallback&
|
| secret_fetched_callback) {
|
| - _secretFetchedCallback = secret_fetched_callback;
|
| - _sessionDetails.state = SessionPinPrompt;
|
| + RemotingClient* strongSelf = weakSelf;
|
| + if (!strongSelf) {
|
| + return;
|
| + }
|
| + strongSelf->_secretFetchedCallback = secret_fetched_callback;
|
| + strongSelf->_sessionDetails.state = SessionPinPrompt;
|
| [[NSNotificationCenter defaultCenter]
|
| postNotificationName:kHostSessionStatusChanged
|
| - object:self
|
| + object:weakSelf
|
| userInfo:[NSDictionary
|
| - dictionaryWithObject:_sessionDetails
|
| + dictionaryWithObject:strongSelf
|
| + ->_sessionDetails
|
| forKey:kSessionDetails]];
|
| });
|
|
|
| @@ -134,9 +143,17 @@ NSString* const kHostSessionPin = @"kHostSessionPin";
|
| - (void)disconnectFromHost {
|
| if (_session) {
|
| _session->Disconnect();
|
| + _runtime->network_task_runner()->DeleteSoon(FROM_HERE, _session.release());
|
| }
|
| _displayHandler = nil;
|
| - // TODO(nicholss): Do we need to cleanup more?
|
| +
|
| + // This needs to be deleted on the display thread since GlDisplayHandler binds
|
| + // its WeakPtrFactory to the display thread.
|
| + // TODO(yuweih): Ideally this constraint can be removed once we allow
|
| + // GlRenderer to be created on the UI thread before being used.
|
| + if (_renderer) {
|
| + _runtime->display_task_runner()->DeleteSoon(FROM_HERE, _renderer.release());
|
| + }
|
| }
|
|
|
| #pragma mark - Eventing
|
|
|