// Copyright 2014 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef REMOTING_PROTOCOL_FAKE_DATAGRAM_SOCKET_H_ #define REMOTING_PROTOCOL_FAKE_DATAGRAM_SOCKET_H_ #include <map> #include <memory> #include <string> #include <vector> #include "base/memory/weak_ptr.h" #include "net/base/completion_repeating_callback.h" #include "remoting/protocol/datagram_channel_factory.h" #include "remoting/protocol/p2p_datagram_socket.h" namespace base { class SingleThreadTaskRunner; } namespace remoting::protocol { // FakeDatagramSocket implement P2PStreamSocket interface. All data written to // FakeDatagramSocket is stored in a buffer returned by written_packets(). // Read() reads data from another buffer that can be set with // AppendInputPacket(). Pending reads are supported, so if there is a pending // read AppendInputPacket() calls the read callback. // // Two fake sockets can be connected to each other using the // PairWith() method, e.g.: a->PairWith(b). After this all data // written to |a| can be read from |b| and vice versa. Two connected // sockets |a| and |b| must be created and used on the same thread. class FakeDatagramSocket : public P2PDatagramSocket { … }; class FakeDatagramChannelFactory : public DatagramChannelFactory { … }; } // namespace remoting::protocol #endif // REMOTING_PROTOCOL_FAKE_DATAGRAM_SOCKET_H_