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

Side by Side Diff: remoting/protocol/webrtc_data_stream_adapter.h

Issue 2164163002: Simplify data channel creation logic in WebRTC-based protocol (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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #ifndef REMOTING_PROTOCOL_WEBRTC_DATA_STREAM_ADAPTER_H_ 5 #ifndef REMOTING_PROTOCOL_WEBRTC_DATA_STREAM_ADAPTER_H_
6 #define REMOTING_PROTOCOL_WEBRTC_DATA_STREAM_ADAPTER_H_ 6 #define REMOTING_PROTOCOL_WEBRTC_DATA_STREAM_ADAPTER_H_
7 7
8 #include <memory>
8 #include <string> 9 #include <string>
9 10
10 #include "base/callback.h" 11 #include "base/callback.h"
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "remoting/protocol/errors.h" 13 #include "remoting/protocol/errors.h"
13 #include "remoting/protocol/message_channel_factory.h" 14 #include "remoting/protocol/message_channel_factory.h"
14 #include "third_party/webrtc/api/peerconnectioninterface.h" 15 #include "third_party/webrtc/api/peerconnectioninterface.h"
15 #include "third_party/webrtc/base/refcount.h" 16 #include "third_party/webrtc/base/refcount.h"
16 17
17 namespace rtc { 18 namespace rtc {
18 class PeerConnectionInterface; 19 class PeerConnectionInterface;
19 } // namespace rtc 20 } // namespace rtc
20 21
21 namespace remoting { 22 namespace remoting {
22 namespace protocol { 23 namespace protocol {
23 24
24 // WebrtcDataStreamAdapter is a MessageChannelFactory that creates channels that 25 // WebrtcDataStreamAdapter is a MessageChannelFactory that creates channels that
Jamie 2016/07/22 01:10:16 Update the comment.
Sergey Ulanov 2016/07/22 01:20:37 Done.
25 // send and receive messages over PeerConnection data channels. 26 // send and receive messages over PeerConnection data channels.
26 class WebrtcDataStreamAdapter : public MessageChannelFactory { 27 class WebrtcDataStreamAdapter {
27 public: 28 public:
28 typedef base::Callback<void(ErrorCode)> ErrorCallback; 29 typedef base::Callback<void(ErrorCode)> ErrorCallback;
29 30
30 explicit WebrtcDataStreamAdapter(const ErrorCallback& error_callback); 31 WebrtcDataStreamAdapter(
Jamie 2016/07/22 01:10:16 Why not explicit any more?
Sergey Ulanov 2016/07/22 01:20:37 Done.
31 ~WebrtcDataStreamAdapter() override; 32 rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection);
33 ~WebrtcDataStreamAdapter();
32 34
33 // Initializes the adapter for |peer_connection|. If |outgoing| is set to true 35 // Creates outgoing data channel.
34 // all channels will be created as outgoing. Otherwise CreateChannel() will 36 std::unique_ptr<MessagePipe> CreateOutgoingChannel(const std::string& name);
35 // wait for the other end to create connection.
36 void Initialize(
37 rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection);
38 37
39 // Called by WebrtcTransport. 38 // Creates incoming data channel.
40 void WrapIncomingDataChannel( 39 std::unique_ptr<MessagePipe> WrapIncomingDataChannel(
41 rtc::scoped_refptr<webrtc::DataChannelInterface> data_channel, 40 rtc::scoped_refptr<webrtc::DataChannelInterface> data_channel);
42 const ChannelCreatedCallback& callback);
43
44 // MessageChannelFactory interface.
45 void CreateChannel(const std::string& name,
46 const ChannelCreatedCallback& callback) override;
47 void CancelChannelCreation(const std::string& name) override;
48 41
49 private: 42 private:
50 class Channel;
51 friend class Channel;
52
53 struct PendingChannel;
54
55 void AddPendingChannel(
56 rtc::scoped_refptr<webrtc::DataChannelInterface> data_channel,
57 const ChannelCreatedCallback& callback);
58
59 void OnChannelConnected(Channel* channel);
60 void OnChannelError();
61
62 ErrorCallback error_callback_;
63
64 rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_; 43 rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_;
65 44
66 std::map<std::string, PendingChannel> pending_channels_;
67
68 DISALLOW_COPY_AND_ASSIGN(WebrtcDataStreamAdapter); 45 DISALLOW_COPY_AND_ASSIGN(WebrtcDataStreamAdapter);
69 }; 46 };
70 47
71 } // namespace protocol 48 } // namespace protocol
72 } // namespace remoting 49 } // namespace remoting
73 50
74 #endif // REMOTING_PROTOCOL_WEBRTC_DATA_STREAM_ADAPTER_H_ 51 #endif // REMOTING_PROTOCOL_WEBRTC_DATA_STREAM_ADAPTER_H_
OLDNEW
« no previous file with comments | « remoting/protocol/webrtc_connection_to_host.cc ('k') | remoting/protocol/webrtc_data_stream_adapter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698