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 "webkit/plugins/ppapi/ppb_transport_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_transport_impl.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "net/base/io_buffer.h" | 9 #include "net/base/io_buffer.h" |
10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
| 11 #include "net/base/net_util.h" |
11 #include "net/socket/socket.h" | 12 #include "net/socket/socket.h" |
12 #include "ppapi/c/dev/ppb_transport_dev.h" | 13 #include "ppapi/c/dev/ppb_transport_dev.h" |
13 #include "ppapi/c/pp_completion_callback.h" | 14 #include "ppapi/c/pp_completion_callback.h" |
14 #include "ppapi/c/pp_errors.h" | 15 #include "ppapi/c/pp_errors.h" |
15 #include "ppapi/shared_impl/var.h" | 16 #include "ppapi/shared_impl/var.h" |
16 #include "webkit/plugins/ppapi/common.h" | 17 #include "webkit/plugins/ppapi/common.h" |
17 #include "webkit/plugins/ppapi/plugin_module.h" | 18 #include "webkit/plugins/ppapi/plugin_module.h" |
18 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 19 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
19 #include "webkit/plugins/ppapi/resource_helper.h" | 20 #include "webkit/plugins/ppapi/resource_helper.h" |
20 | 21 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 PP_Var value) { | 109 PP_Var value) { |
109 // SetProperty() may be called only before Connect(). | 110 // SetProperty() may be called only before Connect(). |
110 if (started_) | 111 if (started_) |
111 return PP_ERROR_FAILED; | 112 return PP_ERROR_FAILED; |
112 | 113 |
113 switch (property) { | 114 switch (property) { |
114 case PP_TRANSPORTPROPERTY_STUN_SERVER: { | 115 case PP_TRANSPORTPROPERTY_STUN_SERVER: { |
115 StringVar* value_str = StringVar::FromPPVar(value); | 116 StringVar* value_str = StringVar::FromPPVar(value); |
116 if (!value_str) | 117 if (!value_str) |
117 return PP_ERROR_BADARGUMENT; | 118 return PP_ERROR_BADARGUMENT; |
118 config_.stun_server = value_str->value(); | 119 |
| 120 if (!net::ParseHostAndPort(value_str->value(), &config_.stun_server, |
| 121 &config_.stun_server_port)) { |
| 122 return PP_ERROR_BADARGUMENT; |
| 123 } |
119 break; | 124 break; |
120 } | 125 } |
121 | 126 |
122 case PP_TRANSPORTPROPERTY_RELAY_SERVER: { | 127 case PP_TRANSPORTPROPERTY_RELAY_SERVER: { |
123 StringVar* value_str = StringVar::FromPPVar(value); | 128 StringVar* value_str = StringVar::FromPPVar(value); |
124 if (!value_str) | 129 if (!value_str) |
125 return PP_ERROR_BADARGUMENT; | 130 return PP_ERROR_BADARGUMENT; |
126 config_.relay_server = value_str->value(); | 131 |
| 132 if (!net::ParseHostAndPort(value_str->value(), &config_.relay_server, |
| 133 &config_.relay_server_port)) { |
| 134 return PP_ERROR_BADARGUMENT; |
| 135 } |
127 break; | 136 break; |
128 } | 137 } |
129 | 138 |
130 case PP_TRANSPORTPROPERTY_RELAY_TOKEN: { | 139 case PP_TRANSPORTPROPERTY_RELAY_TOKEN: { |
131 StringVar* value_str = StringVar::FromPPVar(value); | 140 StringVar* value_str = StringVar::FromPPVar(value); |
132 if (!value_str) | 141 if (!value_str) |
133 return PP_ERROR_BADARGUMENT; | 142 return PP_ERROR_BADARGUMENT; |
134 config_.relay_token = value_str->value(); | 143 config_.relay_token = value_str->value(); |
135 break; | 144 break; |
136 } | 145 } |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 void PPB_Transport_Impl::OnWritten(int result) { | 346 void PPB_Transport_Impl::OnWritten(int result) { |
338 DCHECK(send_callback_.get() && !send_callback_->completed()); | 347 DCHECK(send_callback_.get() && !send_callback_->completed()); |
339 | 348 |
340 scoped_refptr<TrackedCompletionCallback> callback; | 349 scoped_refptr<TrackedCompletionCallback> callback; |
341 callback.swap(send_callback_); | 350 callback.swap(send_callback_); |
342 callback->Run(MapNetError(result)); | 351 callback->Run(MapNetError(result)); |
343 } | 352 } |
344 | 353 |
345 } // namespace ppapi | 354 } // namespace ppapi |
346 } // namespace webkit | 355 } // namespace webkit |
OLD | NEW |