Chromium Code Reviews| Index: webrtc/p2p/base/packettransportinterface.h |
| diff --git a/webrtc/p2p/base/packettransportinterface.h b/webrtc/p2p/base/packettransportinterface.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..401ffb62b45c3d5b3181fc42dccfc9518f3afad1 |
| --- /dev/null |
| +++ b/webrtc/p2p/base/packettransportinterface.h |
| @@ -0,0 +1,66 @@ |
| +/* |
| + * Copyright 2016 The WebRTC Project Authors. All rights reserved. |
| + * |
| + * Use of this source code is governed by a BSD-style license |
| + * that can be found in the LICENSE file in the root of the source |
| + * tree. An additional intellectual property rights grant can be found |
| + * in the file PATENTS. All contributing project authors may |
| + * be found in the AUTHORS file in the root of the source tree. |
| + */ |
| + |
| +#ifndef WEBRTC_P2P_BASE_PACKETTRANSPORTINTERFACE_H_ |
| +#define WEBRTC_P2P_BASE_PACKETTRANSPORTINTERFACE_H_ |
| + |
| +#include <string> |
| +#include <vector> |
| + |
| +#include "webrtc/base/sigslot.h" |
| + |
| +namespace rtc { |
| +struct PacketOptions; |
| +struct PacketTime; |
| + |
| +struct PacketTransportInterface : public sigslot::has_slots<> { |
|
Taylor Brandstetter
2016/10/17 23:24:51
Any reason to use struct? As a matter of style, we
johan
2016/10/18 09:17:09
"struct" usually helps to let people consider twic
|
| + virtual ~PacketTransportInterface() {} |
| + virtual const std::string debug_name() const = 0; |
|
Taylor Brandstetter
2016/10/17 23:24:51
nit: Could be just "name()", with a comment explai
johan
2016/10/18 09:17:08
Ack on adding a comment.
Please discuss with Peter
|
| + virtual bool writable() const = 0; |
|
Taylor Brandstetter
2016/10/17 23:24:51
Should have a comment explaining what "writable" m
johan
2016/10/18 09:17:09
Acknowledged.
|
| + |
| + // Attempts to send the given packet. The return value is < 0 on failure. |
| + // TODO(johan): Remove the default argument once channel code is updated. |
|
Taylor Brandstetter
2016/10/17 23:24:50
Could the comments document where the return codes
johan
2016/10/18 09:17:09
Documenting current behaviour. You won't like it :
|
| + virtual int SendPacket(const char* data, |
| + size_t len, |
| + const rtc::PacketOptions& options, |
| + int flags = 0) = 0; |
| + |
| + // Sets a socket option. Note that not all options are |
| + // supported by all transport types. |
| + virtual int SetOption(rtc::Socket::Option opt, int value) = 0; |
| + |
| + // TODO(pthatcher): Once Chrome's MockPacketTransportInterface implments |
| + // this, remove the default implementation. |
| + virtual bool GetOption(rtc::Socket::Option opt, int* value) { return false; } |
| + |
| + // Returns the most recent error that occurred on this channel. |
| + virtual int GetError() = 0; |
| + |
| + sigslot::signal1<PacketTransportInterface*> SignalWritableState; |
|
Taylor Brandstetter
2016/10/17 23:24:51
Would be nice to have a comment here too ("Emitted
johan
2016/10/18 09:17:09
Done.
|
| + |
| + // Emitted when the PacketTransportInterface's ability to send has changed. |
|
Taylor Brandstetter
2016/10/17 23:24:51
Again, not your fault that this comment was vague/
johan
2016/10/18 09:17:08
Done.
|
| + sigslot::signal1<PacketTransportInterface*> SignalReadyToSend; |
| + |
| + // Signalled each time a packet is received on this channel. |
| + sigslot::signal5<PacketTransportInterface*, |
| + const char*, |
| + size_t, |
| + const rtc::PacketTime&, |
| + int> |
| + SignalReadPacket; |
| + |
| + // Signalled each time a packet is sent on this channel. |
| + sigslot::signal2<PacketTransportInterface*, const rtc::SentPacket&> |
| + SignalSentPacket; |
| +}; |
| + |
| +} // namespace rtc |
| + |
| +#endif // WEBRTC_P2P_BASE_PACKETTRANSPORTINTERFACE_H_ |