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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | extensions/browser/api/cast_channel/cast_socket.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "extensions/browser/api/cast_channel/cast_channel_api.h" 5 #include "extensions/browser/api/cast_channel/cast_channel_api.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <limits> 10 #include <limits>
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 delegate.reset(keep_alive); 339 delegate.reset(keep_alive);
340 } 340 }
341 341
342 socket->Connect(std::move(delegate), 342 socket->Connect(std::move(delegate),
343 base::Bind(&CastChannelOpenFunction::OnOpen, this)); 343 base::Bind(&CastChannelOpenFunction::OnOpen, this));
344 } 344 }
345 345
346 void CastChannelOpenFunction::OnOpen(cast_channel::ChannelError result) { 346 void CastChannelOpenFunction::OnOpen(cast_channel::ChannelError result) {
347 DCHECK_CURRENTLY_ON(BrowserThread::IO); 347 DCHECK_CURRENTLY_ON(BrowserThread::IO);
348 VLOG(1) << "Connect finished, OnOpen invoked."; 348 VLOG(1) << "Connect finished, OnOpen invoked.";
349 CastSocket* socket = GetSocket(new_channel_id_); 349 // TODO: If we failed to open the CastSocket, we may want to clean up here,
350 if (!socket) { 350 // rather than relying on the extension to call close(). This can be done by
351 // calling RemoveSocket() and api_->GetLogger()->ClearLastErrors(channel_id).
352 if (result != cast_channel::CHANNEL_ERROR_UNKNOWN) {
353 CastSocket* socket = GetSocket(new_channel_id_);
354 CHECK(socket);
355 SetResultFromSocket(*socket);
356 } else {
357 // The socket is being destroyed.
351 SetResultFromError(new_channel_id_, result); 358 SetResultFromError(new_channel_id_, result);
352 } else {
353 SetResultFromSocket(*socket);
354 } 359 }
360
355 AsyncWorkCompleted(); 361 AsyncWorkCompleted();
356 } 362 }
357 363
358 CastChannelSendFunction::CastChannelSendFunction() { } 364 CastChannelSendFunction::CastChannelSendFunction() { }
359 365
360 CastChannelSendFunction::~CastChannelSendFunction() { } 366 CastChannelSendFunction::~CastChannelSendFunction() { }
361 367
362 bool CastChannelSendFunction::Prepare() { 368 bool CastChannelSendFunction::Prepare() {
363 params_ = Send::Params::Create(*args_); 369 params_ = Send::Params::Create(*args_);
364 EXTENSION_FUNCTION_VALIDATE(params_.get()); 370 EXTENSION_FUNCTION_VALIDATE(params_.get());
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 BrowserThread::PostTask( 518 BrowserThread::PostTask(
513 BrowserThread::UI, FROM_HERE, 519 BrowserThread::UI, FROM_HERE,
514 base::Bind(ui_dispatch_cb_, socket_->owner_extension_id(), 520 base::Bind(ui_dispatch_cb_, socket_->owner_extension_id(),
515 base::Passed(std::move(event)))); 521 base::Passed(std::move(event))));
516 } 522 }
517 523
518 void CastChannelOpenFunction::CastMessageHandler::Start() { 524 void CastChannelOpenFunction::CastMessageHandler::Start() {
519 } 525 }
520 526
521 } // namespace extensions 527 } // namespace extensions
OLDNEW
« 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