summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-15 22:16:02 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-15 22:16:02 +0000
commit6d3ad505c8e8173e98045d845a910f77fab9ffcf (patch)
treee996bba53b108dabdcb9b0af89eab2e4664a0bf5 /webkit
parentb0f146ff51b2b37a2e3549c875fb42365ded7a21 (diff)
downloadchromium_src-6d3ad505c8e8173e98045d845a910f77fab9ffcf.zip
chromium_src-6d3ad505c8e8173e98045d845a910f77fab9ffcf.tar.gz
chromium_src-6d3ad505c8e8173e98045d845a910f77fab9ffcf.tar.bz2
Relay server support for P2P Transport API.
BUG=41776 TEST=None Review URL: http://codereview.chromium.org/7791008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@101396 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/glue/p2p_transport.cc1
-rw-r--r--webkit/glue/p2p_transport.h25
-rw-r--r--webkit/plugins/ppapi/ppb_transport_impl.cc43
3 files changed, 58 insertions, 11 deletions
diff --git a/webkit/glue/p2p_transport.cc b/webkit/glue/p2p_transport.cc
index a4c518b..f79c21f 100644
--- a/webkit/glue/p2p_transport.cc
+++ b/webkit/glue/p2p_transport.cc
@@ -9,6 +9,7 @@ namespace webkit_glue {
P2PTransport::Config::Config()
: stun_server_port(0),
relay_server_port(0),
+ legacy_relay(false),
tcp_receive_window(0),
tcp_send_window(0),
tcp_no_delay(false),
diff --git a/webkit/glue/p2p_transport.h b/webkit/glue/p2p_transport.h
index 7795344..8e77d28 100644
--- a/webkit/glue/p2p_transport.h
+++ b/webkit/glue/p2p_transport.h
@@ -12,6 +12,10 @@ namespace net {
class Socket;
} // namespace net
+namespace WebKit {
+class WebFrame;
+} // namespace WebKit
+
namespace webkit_glue {
// Interface for P2P transport.
@@ -48,16 +52,23 @@ class P2PTransport {
Config();
~Config();
- // STUN server address and port, e.g. "stun.example.com:23542".
+ // STUN server address and port.
std::string stun_server;
int stun_server_port;
- // Relay server address and port, e.g. "relay.example.com:4234".
+ // Relay server address and port.
std::string relay_server;
int relay_server_port;
- // Relay token to use for relay servers.
- std::string relay_token;
+ // Relay server username.
+ std::string relay_username;
+
+ // Relay server password.
+ std::string relay_password;
+
+ // When set to true relay is a legacy Google relay (not TURN
+ // compliant).
+ bool legacy_relay;
// TCP window sizes. Default size is used when set to 0.
int tcp_receive_window;
@@ -72,9 +83,11 @@ class P2PTransport {
virtual ~P2PTransport() {}
- // Initialize transport using specified configuration. Returns true
+ // Initialize transport using specified configuration. |web_frame|
+ // is used to make HTTP requests to relay servers. Returns true
// if initialization succeeded.
- virtual bool Init(const std::string& name,
+ virtual bool Init(WebKit::WebFrame* web_frame,
+ const std::string& name,
Protocol protocol,
const Config& config,
EventHandler* event_handler) = 0;
diff --git a/webkit/plugins/ppapi/ppb_transport_impl.cc b/webkit/plugins/ppapi/ppb_transport_impl.cc
index d097354..1e121e2 100644
--- a/webkit/plugins/ppapi/ppb_transport_impl.cc
+++ b/webkit/plugins/ppapi/ppb_transport_impl.cc
@@ -14,6 +14,9 @@
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/shared_impl/var.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h"
#include "webkit/plugins/ppapi/common.h"
#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
@@ -52,6 +55,14 @@ int MapNetError(int result) {
}
}
+WebKit::WebFrame* GetFrameForResource(const ::ppapi::Resource* resource) {
+ PluginInstance* plugin_instance =
+ ResourceHelper::GetPluginInstance(resource);
+ if (!plugin_instance)
+ return NULL;
+ return plugin_instance->container()->element().document().frame();
+}
+
} // namespace
PPB_Transport_Impl::PPB_Transport_Impl(PP_Instance instance)
@@ -115,7 +126,6 @@ int32_t PPB_Transport_Impl::SetProperty(PP_TransportProperty property,
StringVar* value_str = StringVar::FromPPVar(value);
if (!value_str)
return PP_ERROR_BADARGUMENT;
-
if (!net::ParseHostAndPort(value_str->value(), &config_.stun_server,
&config_.stun_server_port)) {
return PP_ERROR_BADARGUMENT;
@@ -127,7 +137,6 @@ int32_t PPB_Transport_Impl::SetProperty(PP_TransportProperty property,
StringVar* value_str = StringVar::FromPPVar(value);
if (!value_str)
return PP_ERROR_BADARGUMENT;
-
if (!net::ParseHostAndPort(value_str->value(), &config_.relay_server,
&config_.relay_server_port)) {
return PP_ERROR_BADARGUMENT;
@@ -135,11 +144,33 @@ int32_t PPB_Transport_Impl::SetProperty(PP_TransportProperty property,
break;
}
- case PP_TRANSPORTPROPERTY_RELAY_TOKEN: {
+ case PP_TRANSPORTPROPERTY_RELAY_USERNAME: {
StringVar* value_str = StringVar::FromPPVar(value);
if (!value_str)
return PP_ERROR_BADARGUMENT;
- config_.relay_token = value_str->value();
+ config_.relay_username = value_str->value();
+ break;
+ }
+
+ case PP_TRANSPORTPROPERTY_RELAY_PASSWORD: {
+ StringVar* value_str = StringVar::FromPPVar(value);
+ if (!value_str)
+ return PP_ERROR_BADARGUMENT;
+ config_.relay_password = value_str->value();
+ break;
+ }
+
+ case PP_TRANSPORTPROPERTY_RELAY_MODE: {
+ switch (value.value.as_int) {
+ case PP_TRANSPORTRELAYMODE_TURN:
+ config_.legacy_relay = false;
+ break;
+ case PP_TRANSPORTRELAYMODE_GOOGLE:
+ config_.legacy_relay = true;
+ break;
+ default:
+ return PP_ERROR_BADARGUMENT;
+ }
break;
}
@@ -210,8 +241,10 @@ int32_t PPB_Transport_Impl::Connect(PP_CompletionCallback callback) {
P2PTransport::Protocol protocol = (type_ == PP_TRANSPORTTYPE_STREAM) ?
P2PTransport::PROTOCOL_TCP : P2PTransport::PROTOCOL_UDP;
- if (!p2p_transport_->Init(name_, protocol, config_, this))
+ if (!p2p_transport_->Init(
+ GetFrameForResource(this), name_, protocol, config_, this)) {
return PP_ERROR_FAILED;
+ }
started_ = true;