| 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 #include "remoting/protocol/pepper_stream_channel.h" | 5 #include "remoting/protocol/pepper_stream_channel.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "crypto/hmac.h" | 8 #include "crypto/hmac.h" |
| 9 #include "jingle/glue/utils.h" | 9 #include "jingle/glue/utils.h" |
| 10 #include "net/base/cert_status_flags.h" | 10 #include "net/base/cert_status_flags.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 if (transport->SetProperty(PP_TRANSPORTPROPERTY_TCP_NO_DELAY, | 109 if (transport->SetProperty(PP_TRANSPORTPROPERTY_TCP_NO_DELAY, |
| 110 pp::Var(true)) != PP_OK) { | 110 pp::Var(true)) != PP_OK) { |
| 111 LOG(ERROR) << "Failed to set TCP_NODELAY"; | 111 LOG(ERROR) << "Failed to set TCP_NODELAY"; |
| 112 } | 112 } |
| 113 | 113 |
| 114 if (transport->SetProperty(PP_TRANSPORTPROPERTY_TCP_ACK_DELAY, | 114 if (transport->SetProperty(PP_TRANSPORTPROPERTY_TCP_ACK_DELAY, |
| 115 pp::Var(kTcpAckDelayMilliseconds)) != PP_OK) { | 115 pp::Var(kTcpAckDelayMilliseconds)) != PP_OK) { |
| 116 LOG(ERROR) << "Failed to set TCP ACK delay."; | 116 LOG(ERROR) << "Failed to set TCP ACK delay."; |
| 117 } | 117 } |
| 118 | 118 |
| 119 int32 protocols = PP_TRANSPORTPROTOCOL_UDP; |
| 120 |
| 119 if (transport_config.nat_traversal) { | 121 if (transport_config.nat_traversal) { |
| 120 if (transport->SetProperty( | 122 if (transport->SetProperty( |
| 121 PP_TRANSPORTPROPERTY_STUN_SERVER, | 123 PP_TRANSPORTPROPERTY_STUN_SERVER, |
| 122 pp::Var(transport_config.stun_server)) != PP_OK) { | 124 pp::Var(transport_config.stun_server)) != PP_OK) { |
| 123 LOG(ERROR) << "Failed to set STUN server."; | 125 LOG(ERROR) << "Failed to set STUN server."; |
| 124 } | 126 } |
| 125 | 127 |
| 126 if (transport->SetProperty( | 128 if (transport->SetProperty( |
| 127 PP_TRANSPORTPROPERTY_RELAY_SERVER, | 129 PP_TRANSPORTPROPERTY_RELAY_SERVER, |
| 128 pp::Var(transport_config.relay_server)) != PP_OK) { | 130 pp::Var(transport_config.relay_server)) != PP_OK) { |
| 129 LOG(ERROR) << "Failed to set relay server."; | 131 LOG(ERROR) << "Failed to set relay server."; |
| 130 } | 132 } |
| 131 | 133 |
| 132 if (transport->SetProperty( | 134 if (transport->SetProperty( |
| 133 PP_TRANSPORTPROPERTY_RELAY_PASSWORD, | 135 PP_TRANSPORTPROPERTY_RELAY_PASSWORD, |
| 134 pp::Var(transport_config.relay_token)) != PP_OK) { | 136 pp::Var(transport_config.relay_token)) != PP_OK) { |
| 135 LOG(ERROR) << "Failed to set relay token."; | 137 LOG(ERROR) << "Failed to set relay token."; |
| 136 } | 138 } |
| 137 | 139 |
| 138 if (transport->SetProperty( | 140 if (transport->SetProperty( |
| 139 PP_TRANSPORTPROPERTY_RELAY_MODE, | 141 PP_TRANSPORTPROPERTY_RELAY_MODE, |
| 140 pp::Var(PP_TRANSPORTRELAYMODE_GOOGLE)) != PP_OK) { | 142 pp::Var(PP_TRANSPORTRELAYMODE_GOOGLE)) != PP_OK) { |
| 141 LOG(ERROR) << "Failed to set relay mode."; | 143 LOG(ERROR) << "Failed to set relay mode."; |
| 142 } | 144 } |
| 145 |
| 146 protocols |= PP_TRANSPORTPROTOCOL_STUN | PP_TRANSPORTPROTOCOL_RELAY_UDP; |
| 147 } |
| 148 |
| 149 if (transport->SetProperty(PP_TRANSPORTPROPERTY_PROTOCOLS, |
| 150 pp::Var(protocols)) != PP_OK) { |
| 151 LOG(ERROR) << "Failed to set port types."; |
| 143 } | 152 } |
| 144 | 153 |
| 145 channel_ = new PepperTransportSocketAdapter(transport, name_, this); | 154 channel_ = new PepperTransportSocketAdapter(transport, name_, this); |
| 146 owned_channel_.reset(channel_); | 155 owned_channel_.reset(channel_); |
| 147 | 156 |
| 148 int result = channel_->Connect(&p2p_connect_callback_); | 157 int result = channel_->Connect(&p2p_connect_callback_); |
| 149 if (result != net::ERR_IO_PENDING) | 158 if (result != net::ERR_IO_PENDING) |
| 150 OnP2PConnect(result); | 159 OnP2PConnect(result); |
| 151 } | 160 } |
| 152 | 161 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 void PepperStreamChannel::NotifyConnectFailed() { | 270 void PepperStreamChannel::NotifyConnectFailed() { |
| 262 channel_ = NULL; | 271 channel_ = NULL; |
| 263 owned_channel_.reset(); | 272 owned_channel_.reset(); |
| 264 socket_.reset(); | 273 socket_.reset(); |
| 265 | 274 |
| 266 NotifyConnected(NULL); | 275 NotifyConnected(NULL); |
| 267 } | 276 } |
| 268 | 277 |
| 269 } // namespace protocol | 278 } // namespace protocol |
| 270 } // namespace remoting | 279 } // namespace remoting |
| OLD | NEW |