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

Unified Diff: remoting/protocol/webrtc_data_stream_adapter.h

Issue 2172423002: Simplify WebrtcDataStreamAdapter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | remoting/protocol/webrtc_data_stream_adapter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/webrtc_data_stream_adapter.h
diff --git a/remoting/protocol/webrtc_data_stream_adapter.h b/remoting/protocol/webrtc_data_stream_adapter.h
index ad1c1b4fbf2434bc15099d690ee9215f1540410b..bb2a2278208d6f8ecc4d7635b74395c7b915b7af 100644
--- a/remoting/protocol/webrtc_data_stream_adapter.h
+++ b/remoting/protocol/webrtc_data_stream_adapter.h
@@ -10,36 +10,44 @@
#include "base/callback.h"
#include "base/macros.h"
-#include "remoting/protocol/errors.h"
-#include "remoting/protocol/message_channel_factory.h"
+#include "remoting/protocol/message_pipe.h"
#include "third_party/webrtc/api/peerconnectioninterface.h"
#include "third_party/webrtc/base/refcount.h"
-namespace rtc {
-class PeerConnectionInterface;
-} // namespace rtc
-
namespace remoting {
namespace protocol {
-// WebrtcDataStreamAdapter wraps MessagePipe for WebRTC data channels.
-class WebrtcDataStreamAdapter {
+// WebrtcDataStreamAdapter implements MessagePipe for WebRTC data channels.
+class WebrtcDataStreamAdapter : public MessagePipe,
+ public webrtc::DataChannelObserver {
public:
- typedef base::Callback<void(ErrorCode)> ErrorCallback;
-
explicit WebrtcDataStreamAdapter(
- rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection);
- ~WebrtcDataStreamAdapter();
+ rtc::scoped_refptr<webrtc::DataChannelInterface> channel);
+ ~WebrtcDataStreamAdapter() override;
- // Creates outgoing data channel.
- std::unique_ptr<MessagePipe> CreateOutgoingChannel(const std::string& name);
+ std::string name() { return channel_->label(); }
- // Creates incoming data channel.
- std::unique_ptr<MessagePipe> WrapIncomingDataChannel(
- rtc::scoped_refptr<webrtc::DataChannelInterface> data_channel);
+ // MessagePipe interface.
+ void Start(EventHandler* event_handler) override;
+ void Send(google::protobuf::MessageLite* message,
+ const base::Closure& done) override;
private:
- rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_;
+ enum class State { CONNECTING, OPEN, CLOSED };
+
+ // webrtc::DataChannelObserver interface.
+ void OnStateChange() override;
+ void OnMessage(const webrtc::DataBuffer& buffer) override;
Jamie 2016/07/25 18:25:59 These are public in the DataChannelObserver interf
Sergey Ulanov 2016/07/25 18:48:19 Putting this interface in private section makes it
+
+ void OnConnected();
+
+ void OnClosed();
+
+ rtc::scoped_refptr<webrtc::DataChannelInterface> channel_;
+
+ EventHandler* event_handler_ = nullptr;
+
+ State state_ = State::CONNECTING;
DISALLOW_COPY_AND_ASSIGN(WebrtcDataStreamAdapter);
};
« no previous file with comments | « no previous file | remoting/protocol/webrtc_data_stream_adapter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698