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

Unified Diff: extensions/browser/api/cast_channel/cast_channel_api.cc

Issue 2707543002: [Cast Channel] Fix "leaky" CastChannelOpenFunction. (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | extensions/browser/api/cast_channel/cast_socket.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/api/cast_channel/cast_channel_api.cc
diff --git a/extensions/browser/api/cast_channel/cast_channel_api.cc b/extensions/browser/api/cast_channel/cast_channel_api.cc
index 4355e0e418463847d6305a24e9cb592eff2b41a9..fe16cf2f3e5992eaafb55b614ed1375b7097da1a 100644
--- a/extensions/browser/api/cast_channel/cast_channel_api.cc
+++ b/extensions/browser/api/cast_channel/cast_channel_api.cc
@@ -346,12 +346,18 @@ void CastChannelOpenFunction::AsyncWorkStart() {
void CastChannelOpenFunction::OnOpen(cast_channel::ChannelError result) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
VLOG(1) << "Connect finished, OnOpen invoked.";
- CastSocket* socket = GetSocket(new_channel_id_);
- if (!socket) {
- SetResultFromError(new_channel_id_, result);
- } else {
+ // TODO: If we failed to open the CastSocket, we may want to clean up here,
+ // rather than relying on the extension to call close(). This can be done by
+ // calling RemoveSocket() and api_->GetLogger()->ClearLastErrors(channel_id).
+ if (result != cast_channel::CHANNEL_ERROR_UNKNOWN) {
+ CastSocket* socket = GetSocket(new_channel_id_);
+ CHECK(socket);
SetResultFromSocket(*socket);
+ } else {
+ // The socket is being destroyed.
+ SetResultFromError(new_channel_id_, result);
}
+
AsyncWorkCompleted();
}
« no previous file with comments | « no previous file | extensions/browser/api/cast_channel/cast_socket.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698