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

Unified Diff: remoting/ios/session/remoting_client.mm

Issue 2886233003: [CRD iOS] Fix the leaky RemotingClient (Closed)
Patch Set: WIP Created 3 years, 7 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 | « remoting/ios/display/gl_display_handler.mm ('k') | remoting/ios/session/remoting_client_session_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « remoting/ios/display/gl_display_handler.mm ('k') | remoting/ios/session/remoting_client_session_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698