Chromium Code Reviews| Index: content/browser/renderer_host/pepper_udp_socket.cc |
| diff --git a/content/browser/renderer_host/pepper_udp_socket.cc b/content/browser/renderer_host/pepper_udp_socket.cc |
| index 33f2c7f0c17199eef6e047f4680cc5ea250c975b..836398d18db706712e799993bdd7676226da3cb8 100644 |
| --- a/content/browser/renderer_host/pepper_udp_socket.cc |
| +++ b/content/browser/renderer_host/pepper_udp_socket.cc |
| @@ -1,4 +1,4 @@ |
| -// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Copyright (c) 2012 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. |
| @@ -43,13 +43,19 @@ void PepperUDPSocket::Bind(const PP_NetAddress_Private& addr) { |
| net::IPEndPoint address; |
| if (!socket_.get() || |
| !NetAddressPrivateImpl::NetAddressToIPEndPoint(addr, &address)) { |
| - SendBindACK(false); |
| + SendBindACKError(); |
| return; |
| } |
| int result = socket_->Listen(address); |
|
viettrungluu
2012/02/16 18:47:10
Probably you want to reset the socket in the failu
mtilburg1
2012/02/17 12:14:23
Trung - I'm not sure this is necessary, since the
|
| - SendBindACK(result == net::OK); |
| + if (result == net::OK && |
|
viettrungluu
2012/02/16 18:47:10
(See comment below. I guess you'll need to modify
mtilburg1
2012/02/17 12:14:23
Trung-
While this method will also work, I don't
|
| + socket_->GetLocalAddress(&bound_address_) != net::OK) { |
| + SendBindACKError(); |
| + return; |
| + } |
| + |
| + OnBindCompleted(result); |
| } |
| void PepperUDPSocket::RecvFrom(int32_t num_bytes) { |
| @@ -105,9 +111,22 @@ void PepperUDPSocket::SendSendToACKError() { |
| routing_id_, plugin_dispatcher_id_, socket_id_, false, 0)); |
| } |
| -void PepperUDPSocket::SendBindACK(bool result) { |
| +void PepperUDPSocket::SendBindACKError() { |
|
viettrungluu
2012/02/16 18:47:10
This is now needlessly redundant and convoluted. I
mtilburg1
2012/02/17 12:14:23
I don't agree... we need an Error case (as we have
|
| + PP_NetAddress_Private addr = NetAddressPrivateImpl::kInvalidNetAddress; |
| manager_->Send(new PpapiMsg_PPBUDPSocket_BindACK( |
| - routing_id_, plugin_dispatcher_id_, socket_id_, result)); |
| + routing_id_, plugin_dispatcher_id_, socket_id_, false, addr)); |
| +} |
| + |
| +void PepperUDPSocket::OnBindCompleted(int result) { |
| + PP_NetAddress_Private addr = NetAddressPrivateImpl::kInvalidNetAddress; |
| + if (result < 0 || |
| + !NetAddressPrivateImpl::IPEndPointToNetAddress(bound_address_, |
| + &addr)) { |
| + SendBindACKError(); |
| + } else { |
| + manager_->Send(new PpapiMsg_PPBUDPSocket_BindACK( |
| + routing_id_, plugin_dispatcher_id_, socket_id_, true, addr)); |
| + } |
| } |
| void PepperUDPSocket::OnRecvFromCompleted(int result) { |