Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef WEBKIT_GLUE_P2P_TRANSPORT_H_ | |
| 6 #define WEBKIT_GLUE_P2P_TRANSPORT_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 namespace webkit_glue { | |
| 11 | |
| 12 // Interface for P2P transport. | |
| 13 class P2PTransport { | |
| 14 public: | |
| 15 enum State { | |
| 16 STATE_NONE = 0, | |
| 17 STATE_WRITABLE = 1, | |
| 18 STATE_READABLE = 2, | |
| 19 }; | |
| 20 | |
| 21 class EventHandler { | |
| 22 public: | |
| 23 virtual ~EventHandler() {} | |
| 24 | |
| 25 // Called for each local candidate. | |
| 26 virtual void OnCandidateReady(const std::string& address) = 0; | |
|
mallinath
2011/03/29 22:41:44
We might need some additional parameter to this fu
| |
| 27 | |
| 28 // Called when readable of writable state of the stream changes. | |
| 29 virtual void OnStateChange(State state) = 0; | |
| 30 | |
| 31 // Called when a message received from the peer. P2PTransport keeps | |
| 32 // owneship of |data|. | |
| 33 virtual void OnMessageReceived(const char* data, size_t data_size) = 0; | |
| 34 }; | |
| 35 | |
| 36 virtual ~P2PTransport() {} | |
| 37 | |
| 38 // Initialize transport using specified configuration. | |
| 39 virtual void Init(const std::string& config, | |
| 40 EventHandler* event_handler) = 0; | |
| 41 | |
| 42 // Add candidate received from the remote peer. | |
| 43 virtual void AddRemoteCandidate(const std::string& address) = 0; | |
| 44 | |
| 45 // Send data to the other end. Caller keeps ownership of |data|. | |
| 46 virtual void Send(const char* data, int data_size) = 0; | |
| 47 }; | |
| 48 | |
| 49 } // namespace webkit_glue | |
| 50 | |
| 51 #endif // WEBKIT_GLUE_P2P_TRANSPORT_H_ | |
| OLD | NEW |