diff options
-rw-r--r-- | content/renderer/p2p/p2p_transport_impl.cc | 9 | ||||
-rw-r--r-- | jingle/glue/pseudotcp_adapter.h | 2 | ||||
-rw-r--r-- | ppapi/c/dev/ppb_transport_dev.h | 11 | ||||
-rw-r--r-- | ppapi/tests/test_transport.cc | 8 | ||||
-rw-r--r-- | webkit/glue/p2p_transport.cc | 4 | ||||
-rw-r--r-- | webkit/glue/p2p_transport.h | 6 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_transport_impl.cc | 26 |
7 files changed, 62 insertions, 4 deletions
diff --git a/content/renderer/p2p/p2p_transport_impl.cc b/content/renderer/p2p/p2p_transport_impl.cc index aa9377a..29266e2 100644 --- a/content/renderer/p2p/p2p_transport_impl.cc +++ b/content/renderer/p2p/p2p_transport_impl.cc @@ -91,6 +91,15 @@ bool P2PTransportImpl::Init(const std::string& name, if (protocol == PROTOCOL_TCP) { pseudo_tcp_adapter_.reset(new jingle_glue::PseudoTcpAdapter( channel_adapter_.release())); + + if (config.tcp_receive_window > 0) + pseudo_tcp_adapter_->SetReceiveBufferSize(config.tcp_receive_window); + if (config.tcp_send_window > 0) + pseudo_tcp_adapter_->SetReceiveBufferSize(config.tcp_receive_window); + pseudo_tcp_adapter_->SetNoDelay(config.tcp_no_delay); + if (config.tcp_ack_delay_ms > 0) + pseudo_tcp_adapter_->SetAckDelay(config.tcp_ack_delay_ms); + int result = pseudo_tcp_adapter_->Connect(&connect_callback_); if (result != net::ERR_IO_PENDING) OnTcpConnected(result); diff --git a/jingle/glue/pseudotcp_adapter.h b/jingle/glue/pseudotcp_adapter.h index 643af3f..a764182 100644 --- a/jingle/glue/pseudotcp_adapter.h +++ b/jingle/glue/pseudotcp_adapter.h @@ -56,7 +56,7 @@ class PseudoTcpAdapter : public net::StreamSocket, base::NonThreadSafe { void SetAckDelay(int delay_ms); // Set whether Nagle's algorithm is enabled. - void SetNoDelay(bool nagling); + void SetNoDelay(bool no_delay); private: class Core; diff --git a/ppapi/c/dev/ppb_transport_dev.h b/ppapi/c/dev/ppb_transport_dev.h index b1716e3..89e214f 100644 --- a/ppapi/c/dev/ppb_transport_dev.h +++ b/ppapi/c/dev/ppb_transport_dev.h @@ -32,7 +32,16 @@ typedef enum { // TCP send window in bytes. Takes effect only for PseudoTCP // connections. - PP_TRANSPORTPROPERTY_TCP_SEND_WINDOW = 4 + PP_TRANSPORTPROPERTY_TCP_SEND_WINDOW = 4, + + // Boolean value that disables Neagle's algorithm when set to + // true. When Neagle's algorithm is disabled, all outgoing packets + // are sent as soon as possible. When set to false (by default) data + // may be buffered until there is a sufficient amount to send. + PP_TRANSPORTPROPERTY_TCP_NO_DELAY = 5, + + // Delay for ACK packets in milliseconds. By default set to 100ms. + PP_TRANSPORTPROPERTY_TCP_ACK_DELAY = 6 } PP_TransportProperty; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_TransportProperty, 4); diff --git a/ppapi/tests/test_transport.cc b/ppapi/tests/test_transport.cc index 0df56cf..8e06f85 100644 --- a/ppapi/tests/test_transport.cc +++ b/ppapi/tests/test_transport.cc @@ -195,6 +195,14 @@ std::string TestTransport::TestSetProperty() { ASSERT_EQ(transport1_->SetProperty(PP_TRANSPORTPROPERTY_TCP_SEND_WINDOW, pp::Var(10000000)), PP_ERROR_BADARGUMENT); + ASSERT_EQ(transport1_->SetProperty(PP_TRANSPORTPROPERTY_TCP_NO_DELAY, + pp::Var(true)), PP_OK); + + ASSERT_EQ(transport1_->SetProperty(PP_TRANSPORTPROPERTY_TCP_ACK_DELAY, + pp::Var(10)), PP_OK); + ASSERT_EQ(transport1_->SetProperty(PP_TRANSPORTPROPERTY_TCP_SEND_WINDOW, + pp::Var(10000)), PP_ERROR_BADARGUMENT); + TestCompletionCallback connect_cb(instance_->pp_instance()); ASSERT_EQ(transport1_->Connect(connect_cb), PP_OK_COMPLETIONPENDING); diff --git a/webkit/glue/p2p_transport.cc b/webkit/glue/p2p_transport.cc index 33d824f..a4c518b 100644 --- a/webkit/glue/p2p_transport.cc +++ b/webkit/glue/p2p_transport.cc @@ -10,7 +10,9 @@ P2PTransport::Config::Config() : stun_server_port(0), relay_server_port(0), tcp_receive_window(0), - tcp_send_window(0) { + tcp_send_window(0), + tcp_no_delay(false), + tcp_ack_delay_ms(0) { } P2PTransport::Config::~Config() { diff --git a/webkit/glue/p2p_transport.h b/webkit/glue/p2p_transport.h index 652117e..7795344 100644 --- a/webkit/glue/p2p_transport.h +++ b/webkit/glue/p2p_transport.h @@ -62,6 +62,12 @@ class P2PTransport { // TCP window sizes. Default size is used when set to 0. int tcp_receive_window; int tcp_send_window; + + // Disables Neagle's algorithm when set to true. + bool tcp_no_delay; + + // TCP ACK delay. + int tcp_ack_delay_ms; }; virtual ~P2PTransport() {} diff --git a/webkit/plugins/ppapi/ppb_transport_impl.cc b/webkit/plugins/ppapi/ppb_transport_impl.cc index f9d9cc1..e7779aa 100644 --- a/webkit/plugins/ppapi/ppb_transport_impl.cc +++ b/webkit/plugins/ppapi/ppb_transport_impl.cc @@ -33,6 +33,8 @@ const char kTcpProtocolName[] = "tcp"; const int kMinBufferSize = 1024; const int kMaxBufferSize = 1024 * 1024; +const int kMinAckDelay = 10; +const int kMaxAckDelay = 1000; int MapNetError(int result) { if (result > 0) @@ -170,6 +172,29 @@ int32_t PPB_Transport_Impl::SetProperty(PP_TransportProperty property, break; } + case PP_TRANSPORTPROPERTY_TCP_NO_DELAY: { + if (!use_tcp_) + return PP_ERROR_BADARGUMENT; + + if (value.type != PP_VARTYPE_BOOL) + return PP_ERROR_BADARGUMENT; + config_.tcp_no_delay = PP_ToBool(value.value.as_bool); + break; + } + + case PP_TRANSPORTPROPERTY_TCP_ACK_DELAY: { + if (!use_tcp_) + return PP_ERROR_BADARGUMENT; + + int32_t int_value = value.value.as_int; + if (value.type != PP_VARTYPE_INT32 || int_value < kMinAckDelay || + int_value > kMaxAckDelay) { + return PP_ERROR_BADARGUMENT; + } + config_.tcp_ack_delay_ms = int_value; + break; + } + default: return PP_ERROR_BADARGUMENT; } @@ -299,7 +324,6 @@ int32_t PPB_Transport_Impl::Close() { p2p_transport_.reset(); - PluginModule* plugin_module = ResourceHelper::GetPluginModule(this); if (plugin_module) plugin_module->GetCallbackTracker()->AbortAll(); |