| OLD | NEW |
| 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 "media/cast/test/loopback_transport.h" | 5 #include "media/cast/test/loopback_transport.h" |
| 6 | 6 |
| 7 #include "base/single_thread_task_runner.h" | 7 #include "base/single_thread_task_runner.h" |
| 8 #include "base/time/tick_clock.h" | 8 #include "base/time/tick_clock.h" |
| 9 #include "media/cast/test/utility/udp_proxy.h" | 9 #include "media/cast/test/utility/udp_proxy.h" |
| 10 | 10 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 bool LoopBackTransport::SendPacket(PacketRef packet, | 47 bool LoopBackTransport::SendPacket(PacketRef packet, |
| 48 const base::Closure& cb) { | 48 const base::Closure& cb) { |
| 49 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); | 49 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); |
| 50 scoped_ptr<Packet> packet_copy(new Packet(packet->data)); | 50 scoped_ptr<Packet> packet_copy(new Packet(packet->data)); |
| 51 packet_pipe_->Send(packet_copy.Pass()); | 51 packet_pipe_->Send(packet_copy.Pass()); |
| 52 bytes_sent_ += packet->data.size(); | 52 bytes_sent_ += packet->data.size(); |
| 53 return true; | 53 return true; |
| 54 } | 54 } |
| 55 | 55 |
| 56 int64 LoopBackTransport::GetBytesSent() { | 56 int64_t LoopBackTransport::GetBytesSent() { |
| 57 return bytes_sent_; | 57 return bytes_sent_; |
| 58 } | 58 } |
| 59 | 59 |
| 60 void LoopBackTransport::Initialize( | 60 void LoopBackTransport::Initialize( |
| 61 scoped_ptr<test::PacketPipe> pipe, | 61 scoped_ptr<test::PacketPipe> pipe, |
| 62 const PacketReceiverCallback& packet_receiver, | 62 const PacketReceiverCallback& packet_receiver, |
| 63 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 63 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
| 64 base::TickClock* clock) { | 64 base::TickClock* clock) { |
| 65 scoped_ptr<test::PacketPipe> loopback_pipe( | 65 scoped_ptr<test::PacketPipe> loopback_pipe( |
| 66 new LoopBackPacketPipe(packet_receiver)); | 66 new LoopBackPacketPipe(packet_receiver)); |
| 67 if (pipe) { | 67 if (pipe) { |
| 68 // Append the loopback pipe to the end. | 68 // Append the loopback pipe to the end. |
| 69 pipe->AppendToPipe(loopback_pipe.Pass()); | 69 pipe->AppendToPipe(loopback_pipe.Pass()); |
| 70 packet_pipe_ = pipe.Pass(); | 70 packet_pipe_ = pipe.Pass(); |
| 71 } else { | 71 } else { |
| 72 packet_pipe_ = loopback_pipe.Pass(); | 72 packet_pipe_ = loopback_pipe.Pass(); |
| 73 } | 73 } |
| 74 packet_pipe_->InitOnIOThread(task_runner, clock); | 74 packet_pipe_->InitOnIOThread(task_runner, clock); |
| 75 } | 75 } |
| 76 | 76 |
| 77 } // namespace cast | 77 } // namespace cast |
| 78 } // namespace media | 78 } // namespace media |
| OLD | NEW |