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

Side by Side Diff: media/cast/test/loopback_transport.cc

Issue 1544313002: Convert Pass()→std::move() in //media (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 | « media/cast/test/fake_media_source.cc ('k') | media/cast/test/receiver.cc » ('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 "media/cast/test/loopback_transport.h" 5 #include "media/cast/test/loopback_transport.h"
6 6
7 #include <utility>
8
7 #include "base/macros.h" 9 #include "base/macros.h"
8 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
9 #include "base/time/tick_clock.h" 11 #include "base/time/tick_clock.h"
10 #include "media/cast/test/utility/udp_proxy.h" 12 #include "media/cast/test/utility/udp_proxy.h"
11 13
12 namespace media { 14 namespace media {
13 namespace cast { 15 namespace cast {
14 namespace { 16 namespace {
15 17
16 // Shim that turns forwards packets from a test::PacketPipe to a 18 // Shim that turns forwards packets from a test::PacketPipe to a
17 // PacketReceiverCallback. 19 // PacketReceiverCallback.
18 class LoopBackPacketPipe : public test::PacketPipe { 20 class LoopBackPacketPipe : public test::PacketPipe {
19 public: 21 public:
20 LoopBackPacketPipe( 22 LoopBackPacketPipe(
21 const PacketReceiverCallback& packet_receiver) 23 const PacketReceiverCallback& packet_receiver)
22 : packet_receiver_(packet_receiver) {} 24 : packet_receiver_(packet_receiver) {}
23 25
24 ~LoopBackPacketPipe() final {} 26 ~LoopBackPacketPipe() final {}
25 27
26 // PacketPipe implementations. 28 // PacketPipe implementations.
27 void Send(scoped_ptr<Packet> packet) final { 29 void Send(scoped_ptr<Packet> packet) final {
28 packet_receiver_.Run(packet.Pass()); 30 packet_receiver_.Run(std::move(packet));
29 } 31 }
30 32
31 private: 33 private:
32 PacketReceiverCallback packet_receiver_; 34 PacketReceiverCallback packet_receiver_;
33 35
34 DISALLOW_COPY_AND_ASSIGN(LoopBackPacketPipe); 36 DISALLOW_COPY_AND_ASSIGN(LoopBackPacketPipe);
35 }; 37 };
36 38
37 } // namespace 39 } // namespace
38 40
39 LoopBackTransport::LoopBackTransport( 41 LoopBackTransport::LoopBackTransport(
40 scoped_refptr<CastEnvironment> cast_environment) 42 scoped_refptr<CastEnvironment> cast_environment)
41 : cast_environment_(cast_environment), 43 : cast_environment_(cast_environment),
42 bytes_sent_(0) { 44 bytes_sent_(0) {
43 } 45 }
44 46
45 LoopBackTransport::~LoopBackTransport() { 47 LoopBackTransport::~LoopBackTransport() {
46 } 48 }
47 49
48 bool LoopBackTransport::SendPacket(PacketRef packet, 50 bool LoopBackTransport::SendPacket(PacketRef packet,
49 const base::Closure& cb) { 51 const base::Closure& cb) {
50 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 52 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
51 scoped_ptr<Packet> packet_copy(new Packet(packet->data)); 53 scoped_ptr<Packet> packet_copy(new Packet(packet->data));
52 packet_pipe_->Send(packet_copy.Pass()); 54 packet_pipe_->Send(std::move(packet_copy));
53 bytes_sent_ += packet->data.size(); 55 bytes_sent_ += packet->data.size();
54 return true; 56 return true;
55 } 57 }
56 58
57 int64_t LoopBackTransport::GetBytesSent() { 59 int64_t LoopBackTransport::GetBytesSent() {
58 return bytes_sent_; 60 return bytes_sent_;
59 } 61 }
60 62
61 void LoopBackTransport::Initialize( 63 void LoopBackTransport::Initialize(
62 scoped_ptr<test::PacketPipe> pipe, 64 scoped_ptr<test::PacketPipe> pipe,
63 const PacketReceiverCallback& packet_receiver, 65 const PacketReceiverCallback& packet_receiver,
64 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 66 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
65 base::TickClock* clock) { 67 base::TickClock* clock) {
66 scoped_ptr<test::PacketPipe> loopback_pipe( 68 scoped_ptr<test::PacketPipe> loopback_pipe(
67 new LoopBackPacketPipe(packet_receiver)); 69 new LoopBackPacketPipe(packet_receiver));
68 if (pipe) { 70 if (pipe) {
69 // Append the loopback pipe to the end. 71 // Append the loopback pipe to the end.
70 pipe->AppendToPipe(loopback_pipe.Pass()); 72 pipe->AppendToPipe(std::move(loopback_pipe));
71 packet_pipe_ = pipe.Pass(); 73 packet_pipe_ = std::move(pipe);
72 } else { 74 } else {
73 packet_pipe_ = loopback_pipe.Pass(); 75 packet_pipe_ = std::move(loopback_pipe);
74 } 76 }
75 packet_pipe_->InitOnIOThread(task_runner, clock); 77 packet_pipe_->InitOnIOThread(task_runner, clock);
76 } 78 }
77 79
78 } // namespace cast 80 } // namespace cast
79 } // namespace media 81 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/test/fake_media_source.cc ('k') | media/cast/test/receiver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698