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

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

Issue 9325036: Add abstract interfaces for the transport layer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 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 // This file defins interface for peer-to-peer transport. There are
Wez 2012/02/07 01:17:37 nit: ... defins ... -> ... defines the ...
Sergey Ulanov 2012/02/07 04:41:12 Done.
6 // two type of transport: StreamTransport and DatagramTransport. They
Wez 2012/02/07 01:17:37 nit: two type ... -> two types ...
Sergey Ulanov 2012/02/07 04:41:12 Done.
7 // both must be created using TransportFactory instances and they
Wez 2012/02/07 01:17:37 nit: both must ... -> must both ...
Sergey Ulanov 2012/02/07 04:41:12 Done.
8 // provide the same interface, except that one creates reliable stream
9 // connection and the other one - unreliable datagram
10 // connection. After a new transport is Initialize()'ed the Connect()
11 // method must be called - which starts asynchronous creation and
12 // initializtions of connection socket that can be used later to send
13 // and receive data. The socket is passed to the callback specified in
14 // the Connect() call. Later deletion of the transport socket causes
15 // teardown of the corresponding Transport object.
Wez 2012/02/07 01:17:37 I think this comment needs rewording to make it cl
Sergey Ulanov 2012/02/07 04:41:12 It would not be correct to call them connectors be
16
17 #ifndef REMOTING_PROTOCOL_TRANSPORT_H_
18 #define REMOTING_PROTOCOL_TRANSPORT_H_
19
20 #include <string>
21
22 #include "base/basictypes.h"
23 #include "base/callback_forward.h"
24 #include "base/memory/scoped_ptr.h"
25 #include "base/threading/non_thread_safe.h"
26
27 namespace cricket {
28 class Candidate;
29 } // namespace cricket
30
31 namespace net {
32 class Socket;
33 class StreamSocket;
34 } // namespace net
35
36 namespace remoting {
37 namespace protocol {
38
39 class ChannelAuthenticator;
40 struct TransportConfig;
41
42 class Transport : public base::NonThreadSafe {
43 public:
44 class EventHandler {
45 public:
46 EventHandler() {};
47 virtual ~EventHandler() {};
48
49 // Called when the channel generates new candidate.
Wez 2012/02/07 01:17:37 It's not immediately obvious to a casual reader wh
Sergey Ulanov 2012/02/07 04:41:12 Done.
50 virtual void OnChannelCandidate(Transport* transport,
Wez 2012/02/07 01:17:37 Name OnChannelCandidate consistently with the clas
Sergey Ulanov 2012/02/07 04:41:12 Done.
51 const cricket::Candidate& candidate) = 0;
52
53 // Called when the channel is being deleted.
Wez 2012/02/07 01:17:37 nit: ... is being .. -> ... is about to be ...
Sergey Ulanov 2012/02/07 04:41:12 Done.
54 virtual void OnChannelDeleted(Transport* transport) = 0;
55 };
56
57 Transport() {}
58 virtual ~Transport() {}
59
60 virtual void Initialize(const std::string& name,
61 const TransportConfig& config,
62 Transport::EventHandler* event_handler,
63 scoped_ptr<ChannelAuthenticator> authenticator) = 0;
Wez 2012/02/07 01:17:37 Document the parameters. Specifically, callers sh
Sergey Ulanov 2012/02/07 04:41:12 Done.
64
65 // Adds |candidate| received from the peer.
66 virtual void AddRemoteCandidate(const cricket::Candidate& candidate) = 0;
67
68 // Name of the channel.
Wez 2012/02/07 01:17:37 What does the "name" of the channel actually mean?
Sergey Ulanov 2012/02/07 04:41:12 Done.
69 virtual const std::string& name() const = 0;
70
71 // Returns true if the channel is already connected.
72 virtual bool is_connected() const = 0;
73
74 private:
75 DISALLOW_COPY_AND_ASSIGN(Transport);
76 };
77
78 class StreamTransport : public Transport {
79 public:
80 typedef base::Callback<void(scoped_ptr<net::StreamSocket>)> ConnectedCallback;
81
82 StreamTransport() { }
83 ~StreamTransport() { }
84
85 virtual void Connect(const ConnectedCallback& callback) = 0;
86
87 private:
88 DISALLOW_COPY_AND_ASSIGN(StreamTransport);
89 };
90
91 class DatagramTransport : public Transport {
92 public:
93 typedef base::Callback<void(scoped_ptr<net::Socket>)> ConnectedCallback;
94
95 DatagramTransport() { }
96 ~DatagramTransport() { }
97
98 virtual void Connect(const ConnectedCallback& callback) = 0;
99
100 private:
101 DISALLOW_COPY_AND_ASSIGN(DatagramTransport);
102 };
103
104 class TransportFactory {
105 public:
106 TransportFactory() { }
107 virtual ~TransportFactory() { }
108
109 virtual scoped_ptr<StreamTransport> CreateStreamTransport() = 0;
110 virtual scoped_ptr<DatagramTransport> CreateDatagramTransport() = 0;
111
112 private:
113 DISALLOW_COPY_AND_ASSIGN(TransportFactory);
114 };
115
116 } // namespace protocol
117 } // namespace remoting
118
119 #endif // REMOTING_PROTOCOL_TRANSPORT_H_
Wez 2012/02/07 01:17:37 nit: Should this file be transport_factory.h rathe
Sergey Ulanov 2012/02/07 04:41:12 IMHO it's better to keep it called transport as th
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698