| 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 // Addresses of STUN servers. Must be in form of |
| 52 // "server_name:<port>". |
| 53 std::vector<std::string> stun_servers; |
| 54 |
| 55 // Names of Relay servers. |
| 56 std::vector<std::string> relay_servers; |
| 57 |
| 58 // Relay token to use for relay servers. |
| 59 std::string relay_token; |
| 60 |
| 61 // TCP window sizes. Default size is used when set to 0. |
| 62 int tcp_receive_window; |
| 63 int tcp_send_window; |
| 64 }; |
| 65 |
| 46 virtual ~P2PTransport() {} | 66 virtual ~P2PTransport() {} |
| 47 | 67 |
| 48 // Initialize transport using specified configuration. Returns true | 68 // Initialize transport using specified configuration. Returns true |
| 49 // if initialization succeeded. | 69 // if initialization succeeded. |
| 50 virtual bool Init(const std::string& name, | 70 virtual bool Init(const std::string& name, |
| 51 Protocol protocol, | 71 Protocol protocol, |
| 52 const std::string& config, | 72 const Config& config, |
| 53 EventHandler* event_handler) = 0; | 73 EventHandler* event_handler) = 0; |
| 54 | 74 |
| 55 // Add candidate received from the remote peer. Returns false if the | 75 // Add candidate received from the remote peer. Returns false if the |
| 56 // provided address is not in a valid format. | 76 // provided address is not in a valid format. |
| 57 virtual bool AddRemoteCandidate(const std::string& address) = 0; | 77 virtual bool AddRemoteCandidate(const std::string& address) = 0; |
| 58 | 78 |
| 59 // Returns socket interface that can be used to send/receive | 79 // Returns socket interface that can be used to send/receive |
| 60 // data. Returned object is owned by the transport. Pending calls on | 80 // data. Returned object is owned by the transport. Pending calls on |
| 61 // the socket are canceled when the transport is destroyed. | 81 // the socket are canceled when the transport is destroyed. |
| 62 virtual net::Socket* GetChannel() = 0; | 82 virtual net::Socket* GetChannel() = 0; |
| 63 }; | 83 }; |
| 64 | 84 |
| 65 } // namespace webkit_glue | 85 } // namespace webkit_glue |
| 66 | 86 |
| 67 #endif // WEBKIT_GLUE_P2P_TRANSPORT_H_ | 87 #endif // WEBKIT_GLUE_P2P_TRANSPORT_H_ |
| OLD | NEW |