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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/protocol/pepper_transport_factory.cc ('k') | remoting/remoting.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/transport.h
diff --git a/remoting/protocol/transport.h b/remoting/protocol/transport.h
new file mode 100644
index 0000000000000000000000000000000000000000..f6f4381a6feb11f8e48f856f8e4d2c8d7da1a7fb
--- /dev/null
+++ b/remoting/protocol/transport.h
@@ -0,0 +1,131 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+// This file defines the interface for peer-to-peer transport. There
+// are two types of transport: StreamTransport and DatagramTransport.
+// They must both be created using TransportFactory instances and they
+// provide the same interface, except that one should be used for
+// reliable stream connection and the other one - for unreliable
simonmorris 2012/02/08 19:45:16 Remove "- ".
Sergey Ulanov 2012/02/08 20:20:30 Done.
+// datagram connection. Transport interface itself doesn't provide
simonmorris 2012/02/08 19:45:16 "The transport interface..."
Sergey Ulanov 2012/02/08 20:20:30 Done.
+// methods to send/receive data. Instead it creates an instance of
+// net::Socket or net::SocketStream interface which provides access to
simonmorris 2012/02/08 19:45:16 Remove "interface", or add "the" before "net::Sock
Sergey Ulanov 2012/02/08 20:20:30 Done.
+// the data channel. After a new transport is Initialize()'ed the
+// Connect() method must be called. Connect() starts asynchronous
+// creation and initializations of connection socket that can be used
simonmorris 2012/02/08 19:45:16 "initialization"? "of the connection socket".
Sergey Ulanov 2012/02/08 20:20:30 Done.
+// later to send and receive data. The socket is passed to the
+// callback specified in the Connect() call. Transport object must
simonmorris 2012/02/08 19:45:16 "The Transport object".
Sergey Ulanov 2012/02/08 20:20:30 Done.
+// exist during whole lifetime of the connection socket. Later
simonmorris 2012/02/08 19:45:16 "during the whole"
Sergey Ulanov 2012/02/08 20:20:30 Done.
+// deletion of the transport socket causes teardown of the
simonmorris 2012/02/08 19:45:16 This is the first mention of a transport socket. I
Sergey Ulanov 2012/02/08 20:20:30 Done.
+// corresponding Transport object.
+
+#ifndef REMOTING_PROTOCOL_TRANSPORT_H_
+#define REMOTING_PROTOCOL_TRANSPORT_H_
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/callback_forward.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/threading/non_thread_safe.h"
+
+namespace cricket {
+class Candidate;
+} // namespace cricket
+
+namespace net {
+class Socket;
+class StreamSocket;
+} // namespace net
+
+namespace remoting {
+namespace protocol {
+
+class ChannelAuthenticator;
+struct TransportConfig;
+
+class Transport : public base::NonThreadSafe {
+ public:
+ class EventHandler {
+ public:
+ EventHandler() {};
+ virtual ~EventHandler() {};
+
+ // Called when the transport generates a new candidate that needs
+ // to be passed to the AddRemoteCandidate() method on the remote
+ // end of the connection.
+ virtual void OnTransportCandidate(Transport* transport,
+ const cricket::Candidate& candidate) = 0;
+
+ // Called when the transport is about to be deleted.
+ virtual void OnTransportDeleted(Transport* transport) = 0;
+ };
+
+ Transport() {}
+ virtual ~Transport() {}
+
+ // Intialize the transport with the specified
+ // paramters. |authenticator| is used to secure and authenticate the
simonmorris 2012/02/08 19:45:16 "parameters".
Sergey Ulanov 2012/02/08 20:20:30 Done.
+ // connection.
+ virtual void Initialize(const std::string& name,
+ const TransportConfig& config,
+ Transport::EventHandler* event_handler,
+ scoped_ptr<ChannelAuthenticator> authenticator) = 0;
+
+ // Adds |candidate| received from the peer.
+ virtual void AddRemoteCandidate(const cricket::Candidate& candidate) = 0;
+
+ // Name of the channel. It is used to identify the channel and
+ // disambiguate candidates it generates from candidates generated by
+ // parallel connections.
+ virtual const std::string& name() const = 0;
+
+ // Returns true if the channel is already connected.
+ virtual bool is_connected() const = 0;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(Transport);
+};
+
+class StreamTransport : public Transport {
+ public:
+ typedef base::Callback<void(scoped_ptr<net::StreamSocket>)> ConnectedCallback;
+
+ StreamTransport() { }
+ ~StreamTransport() { }
+
+ virtual void Connect(const ConnectedCallback& callback) = 0;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(StreamTransport);
+};
+
+class DatagramTransport : public Transport {
+ public:
+ typedef base::Callback<void(scoped_ptr<net::Socket>)> ConnectedCallback;
+
+ DatagramTransport() { }
+ ~DatagramTransport() { }
+
+ virtual void Connect(const ConnectedCallback& callback) = 0;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(DatagramTransport);
+};
+
+class TransportFactory {
+ public:
+ TransportFactory() { }
+ virtual ~TransportFactory() { }
+
+ virtual scoped_ptr<StreamTransport> CreateStreamTransport() = 0;
+ virtual scoped_ptr<DatagramTransport> CreateDatagramTransport() = 0;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(TransportFactory);
+};
+
+} // namespace protocol
+} // namespace remoting
+
+#endif // REMOTING_PROTOCOL_TRANSPORT_H_
« no previous file with comments | « remoting/protocol/pepper_transport_factory.cc ('k') | remoting/remoting.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698