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

Side by Side Diff: remoting/protocol/jingle_session_unittest.cc

Issue 7605018: Simplify channel creation callbacks in remoting::Session interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/file_path.h" 6 #include "base/file_path.h"
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "base/test/test_timeouts.h" 10 #include "base/test/test_timeouts.h"
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 host_session_->CreateStreamChannel( 374 host_session_->CreateStreamChannel(
375 kChannelName, 375 kChannelName,
376 base::Bind(&TCPChannelTester::OnChannelReady, 376 base::Bind(&TCPChannelTester::OnChannelReady,
377 base::Unretained(this), 0)); 377 base::Unretained(this), 0));
378 client_session_->CreateStreamChannel( 378 client_session_->CreateStreamChannel(
379 kChannelName, 379 kChannelName,
380 base::Bind(&TCPChannelTester::OnChannelReady, 380 base::Bind(&TCPChannelTester::OnChannelReady,
381 base::Unretained(this), 1)); 381 base::Unretained(this), 1));
382 } 382 }
383 383
384 void OnChannelReady(int id, const std::string name, 384 void OnChannelReady(int id, net::StreamSocket* socket) {
385 net::StreamSocket* socket) {
386 ASSERT_TRUE(socket); 385 ASSERT_TRUE(socket);
387 ASSERT_EQ(name, kChannelName);
388 if (!socket) { 386 if (!socket) {
389 Done(); 387 Done();
390 return; 388 return;
391 } 389 }
392 390
393 DCHECK(id >= 0 && id < 2); 391 DCHECK(id >= 0 && id < 2);
394 sockets_[id].reset(socket); 392 sockets_[id].reset(socket);
395 393
396 if (sockets_[0].get() && sockets_[1].get()) { 394 if (sockets_[0].get() && sockets_[1].get()) {
397 InitBuffers(); 395 InitBuffers();
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 host_session_->CreateDatagramChannel( 538 host_session_->CreateDatagramChannel(
541 kChannelName, 539 kChannelName,
542 base::Bind(&UDPChannelTester::OnChannelReady, 540 base::Bind(&UDPChannelTester::OnChannelReady,
543 base::Unretained(this), 0)); 541 base::Unretained(this), 0));
544 client_session_->CreateDatagramChannel( 542 client_session_->CreateDatagramChannel(
545 kChannelName, 543 kChannelName,
546 base::Bind(&UDPChannelTester::OnChannelReady, 544 base::Bind(&UDPChannelTester::OnChannelReady,
547 base::Unretained(this), 1)); 545 base::Unretained(this), 1));
548 } 546 }
549 547
550 void OnChannelReady(int id, const std::string name, net::Socket* socket) { 548 void OnChannelReady(int id, net::Socket* socket) {
551 ASSERT_TRUE(socket); 549 ASSERT_TRUE(socket);
552 ASSERT_EQ(name, kChannelName);
553 if (!socket) { 550 if (!socket) {
554 Done(); 551 Done();
555 return; 552 return;
556 } 553 }
557 554
558 DCHECK(id >= 0 && id < 2); 555 DCHECK(id >= 0 && id < 2);
559 sockets_[id].reset(socket); 556 sockets_[id].reset(socket);
560 557
561 if (sockets_[0].get() && sockets_[1].get()) { 558 if (sockets_[0].get() && sockets_[1].get()) {
562 InitBuffers(); 559 InitBuffers();
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 ASSERT_TRUE(tester->WaitFinished()); 776 ASSERT_TRUE(tester->WaitFinished());
780 LOG(INFO) << "Time for 500k bytes " 777 LOG(INFO) << "Time for 500k bytes "
781 << tester->GetElapsedTime().InMilliseconds() << " ms."; 778 << tester->GetElapsedTime().InMilliseconds() << " ms.";
782 779
783 // Connections must be closed while |tester| still exists. 780 // Connections must be closed while |tester| still exists.
784 CloseSessions(); 781 CloseSessions();
785 } 782 }
786 783
787 } // namespace protocol 784 } // namespace protocol
788 } // namespace remoting 785 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698