OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 WEBKIT_GLUE_P2P_TRANSPORT_H_ | 5 #ifndef WEBKIT_GLUE_P2P_TRANSPORT_H_ |
6 #define WEBKIT_GLUE_P2P_TRANSPORT_H_ | 6 #define WEBKIT_GLUE_P2P_TRANSPORT_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
| 9 #include <vector> |
9 | 10 |
10 namespace net { | 11 namespace net { |
11 class Socket; | 12 class Socket; |
12 } // namespace net | 13 } // namespace net |
13 | 14 |
14 namespace webkit_glue { | 15 namespace webkit_glue { |
15 | 16 |
16 // Interface for P2P transport. | 17 // Interface for P2P transport. |
17 class P2PTransport { | 18 class P2PTransport { |
18 public: | 19 public: |
(...skipping 17 matching lines...) Expand all Loading... |
36 | 37 |
37 // Called when readable of writable state of the stream changes. | 38 // Called when readable of writable state of the stream changes. |
38 virtual void OnStateChange(State state) = 0; | 39 virtual void OnStateChange(State state) = 0; |
39 | 40 |
40 // Called when an error occures (e.g. TCP handshake | 41 // Called when an error occures (e.g. TCP handshake |
41 // failed). P2PTransport object is not usable after that and | 42 // failed). P2PTransport object is not usable after that and |
42 // should be destroyed. | 43 // should be destroyed. |
43 virtual void OnError(int error) = 0; | 44 virtual void OnError(int error) = 0; |
44 }; | 45 }; |
45 | 46 |
| 47 struct Config { |
| 48 Config(); |
| 49 ~Config(); |
| 50 |
| 51 // STUN server address and port, e.g. "stun.example.com:23542". |
| 52 std::string stun_server; |
| 53 |
| 54 // Relay server name, e.g. "relay.example.com". |
| 55 std::string relay_server; |
| 56 |
| 57 // Relay token to use for relay servers. |
| 58 std::string relay_token; |
| 59 |
| 60 // TCP window sizes. Default size is used when set to 0. |
| 61 int tcp_receive_window; |
| 62 int tcp_send_window; |
| 63 }; |
| 64 |
46 virtual ~P2PTransport() {} | 65 virtual ~P2PTransport() {} |
47 | 66 |
48 // Initialize transport using specified configuration. Returns true | 67 // Initialize transport using specified configuration. Returns true |
49 // if initialization succeeded. | 68 // if initialization succeeded. |
50 virtual bool Init(const std::string& name, | 69 virtual bool Init(const std::string& name, |
51 Protocol protocol, | 70 Protocol protocol, |
52 const std::string& config, | 71 const Config& config, |
53 EventHandler* event_handler) = 0; | 72 EventHandler* event_handler) = 0; |
54 | 73 |
55 // Add candidate received from the remote peer. Returns false if the | 74 // Add candidate received from the remote peer. Returns false if the |
56 // provided address is not in a valid format. | 75 // provided address is not in a valid format. |
57 virtual bool AddRemoteCandidate(const std::string& address) = 0; | 76 virtual bool AddRemoteCandidate(const std::string& address) = 0; |
58 | 77 |
59 // Returns socket interface that can be used to send/receive | 78 // Returns socket interface that can be used to send/receive |
60 // data. Returned object is owned by the transport. Pending calls on | 79 // data. Returned object is owned by the transport. Pending calls on |
61 // the socket are canceled when the transport is destroyed. | 80 // the socket are canceled when the transport is destroyed. |
62 virtual net::Socket* GetChannel() = 0; | 81 virtual net::Socket* GetChannel() = 0; |
63 }; | 82 }; |
64 | 83 |
65 } // namespace webkit_glue | 84 } // namespace webkit_glue |
66 | 85 |
67 #endif // WEBKIT_GLUE_P2P_TRANSPORT_H_ | 86 #endif // WEBKIT_GLUE_P2P_TRANSPORT_H_ |
OLD | NEW |