cf29fbb7895c33eddf4aa088a9f238bfa72d56eb
[platform/framework/web/crosswalk.git] / src / media / cast / test / loopback_transport.h
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
3 // found in the LICENSE file.
4
5 #ifndef MEDIA_CAST_TEST_LOOPBACK_TRANSPORT_H_
6 #define MEDIA_CAST_TEST_LOOPBACK_TRANSPORT_H_
7
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "media/cast/cast_environment.h"
11 #include "media/cast/net/cast_transport_config.h"
12
13 namespace base {
14 class SingleThreadTaskRunner;
15 class TickClock;
16 }  // namespace base
17
18 namespace media {
19 namespace cast {
20
21 namespace test {
22 class PacketPipe;
23 }  // namespace test
24
25 // Class that sends the packet to a receiver through a stack of PacketPipes.
26 class LoopBackTransport : public PacketSender {
27  public:
28   explicit LoopBackTransport(
29       scoped_refptr<CastEnvironment> cast_environment);
30   virtual ~LoopBackTransport();
31
32   virtual bool SendPacket(PacketRef packet,
33                           const base::Closure& cb) OVERRIDE;
34
35   virtual int64 GetBytesSent() OVERRIDE;
36
37   // Initiailize this loopback transport.
38   // Establish a flow of packets from |pipe| to |packet_receiver|.
39   // The data flow looks like:
40   // SendPacket() -> |pipe| -> Fake loopback pipe -> |packet_receiver|.
41   void Initialize(
42       scoped_ptr<test::PacketPipe> pipe,
43       const PacketReceiverCallback& packet_receiver,
44       const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
45       base::TickClock* clock);
46
47  private:
48   const scoped_refptr<CastEnvironment> cast_environment_;
49   scoped_ptr<test::PacketPipe> packet_pipe_;
50   int64 bytes_sent_;
51
52   DISALLOW_COPY_AND_ASSIGN(LoopBackTransport);
53 };
54
55 }  // namespace cast
56 }  // namespace media
57
58 #endif  // MEDIA_CAST_TEST_LOOPBACK_TRANSPORT_H_