summaryrefslogtreecommitdiffstats
path: root/webkit/glue/p2p_transport.h
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-27 17:43:30 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-27 17:43:30 +0000
commit12e2975aebaa9e1ac447ac0f443313de72cc306e (patch)
tree1c34f8dee4a1d8badfdf162eaf6ee0e90fceba10 /webkit/glue/p2p_transport.h
parent885b96bcf8937d0bb3e06b2093dbe8cc11583cff (diff)
downloadchromium_src-12e2975aebaa9e1ac447ac0f443313de72cc306e.zip
chromium_src-12e2975aebaa9e1ac447ac0f443313de72cc306e.tar.gz
chromium_src-12e2975aebaa9e1ac447ac0f443313de72cc306e.tar.bz2
Add P2PTransport interface in webkit_glue.
The new interface will be implemented by the renderer, and will provide P2P transport for Pepper and P2P JavaScript APIs. TEST=None BUG=None Review URL: http://codereview.chromium.org/6676101 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79520 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/p2p_transport.h')
-rw-r--r--webkit/glue/p2p_transport.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/webkit/glue/p2p_transport.h b/webkit/glue/p2p_transport.h
new file mode 100644
index 0000000..5cd30c5
--- /dev/null
+++ b/webkit/glue/p2p_transport.h
@@ -0,0 +1,51 @@
+// Copyright (c) 2011 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.
+
+#ifndef WEBKIT_GLUE_P2P_TRANSPORT_H_
+#define WEBKIT_GLUE_P2P_TRANSPORT_H_
+
+#include <string>
+
+namespace webkit_glue {
+
+// Interface for P2P transport.
+class P2PTransport {
+ public:
+ enum State {
+ STATE_NONE = 0,
+ STATE_WRITABLE = 1,
+ STATE_READABLE = 2,
+ };
+
+ class EventHandler {
+ public:
+ virtual ~EventHandler() {}
+
+ // Called for each local candidate.
+ virtual void OnCandidateReady(const std::string& address) = 0;
+
+ // Called when readable of writable state of the stream changes.
+ virtual void OnStateChange(State state) = 0;
+
+ // Called when a message received from the peer. P2PTransport keeps
+ // owneship of |data|.
+ virtual void OnMessageReceived(const char* data, size_t data_size) = 0;
+ };
+
+ virtual ~P2PTransport() {}
+
+ // Initialize transport using specified configuration.
+ virtual void Init(const std::string& config,
+ EventHandler* event_handler) = 0;
+
+ // Add candidate received from the remote peer.
+ virtual void AddRemoteCandidate(const std::string& address) = 0;
+
+ // Send data to the other end. Caller keeps ownership of |data|.
+ virtual void Send(const char* data, int data_size) = 0;
+};
+
+} // namespace webkit_glue
+
+#endif // WEBKIT_GLUE_P2P_TRANSPORT_H_