OLD | NEW |
---|---|
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 BLIMP_NET_BLIMP_TRANSPORT_H_ | 5 #ifndef BLIMP_NET_BLIMP_TRANSPORT_H_ |
6 #define BLIMP_NET_BLIMP_TRANSPORT_H_ | 6 #define BLIMP_NET_BLIMP_TRANSPORT_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "net/base/completion_callback.h" | 11 #include "net/base/completion_callback.h" |
12 #include "net/base/ip_endpoint.h" | |
12 | 13 |
13 namespace blimp { | 14 namespace blimp { |
14 | 15 |
15 class BlimpConnection; | 16 class BlimpConnection; |
16 class MessagePort; | |
17 | 17 |
18 // An interface which encapsulates the transport-specific code for | 18 // An interface which encapsulates the transport-specific code for |
19 // establishing network connections between the client and engine. | 19 // establishing network connections between the client and engine. |
20 // Subclasses of BlimpTransport are responsible for defining their own | 20 // Subclasses of BlimpTransport are responsible for defining their own |
21 // methods for receiving connection arguments. | 21 // methods for receiving connection arguments. |
22 class BlimpTransport { | 22 class BlimpTransport { |
23 public: | 23 public: |
24 virtual ~BlimpTransport() {} | 24 virtual ~BlimpTransport() {} |
25 | 25 |
26 // Initiate or listen for a connection. | 26 // Initiate or listen for a connection. |
27 // | 27 // |
28 // |callback| is passed net::OK if a connection was successfully | 28 // |callback| is passed net::OK if a connection was successfully |
29 // established. The connection's MessagePort can then be taken by calling | 29 // established. |
30 // TakeMessagePort(). | |
31 // All other values indicate a connection error. | 30 // All other values indicate a connection error. |
32 virtual void Connect(const net::CompletionCallback& callback) = 0; | 31 virtual void Connect(const net::CompletionCallback& callback) = 0; |
33 | 32 |
34 // Returns the MessagePort of a successfully established connection. | 33 // Creates a new |BlimpConnection| for the specific |BlimpTransport| |
35 virtual std::unique_ptr<MessagePort> TakeMessagePort() = 0; | 34 // implementation. Call this once the |Connect|'s callback returns net::OK. |
Garrett Casto
2016/10/26 23:43:48
Nit: "Must not be called unless |callback| from Co
perumaal
2016/10/27 00:16:04
Good point.
| |
35 virtual std::unique_ptr<BlimpConnection> MakeConnection() = 0; | |
36 | 36 |
37 // Gets the transport name, e.g. "TCP", "SSL", "mock", etc. | 37 // Gets the transport name, e.g. "TCP", "SSL", "mock", etc. |
38 virtual const char* GetName() const = 0; | 38 virtual const char* GetName() const = 0; |
39 }; | 39 }; |
40 | 40 |
41 // Interface specific to engine transport on top of generic |BlimpTransport|. | |
42 class BlimpEngineTransport : public BlimpTransport { | |
Garrett Casto
2016/10/26 23:43:48
Given the rest of this directory, I would assume t
perumaal
2016/10/27 00:16:05
Done.
| |
43 public: | |
44 ~BlimpEngineTransport() override {} | |
45 | |
46 // Obtains the local listening address. | |
47 virtual void GetLocalAddress(net::IPEndPoint* ip_address) const = 0; | |
48 }; | |
49 | |
41 } // namespace blimp | 50 } // namespace blimp |
42 | 51 |
43 #endif // BLIMP_NET_BLIMP_TRANSPORT_H_ | 52 #endif // BLIMP_NET_BLIMP_TRANSPORT_H_ |
OLD | NEW |