OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/renderer_host/p2p/socket_host_tcp_server.h" | 5 #include "content/browser/renderer_host/p2p/socket_host_tcp_server.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "content/browser/renderer_host/p2p/socket_host_tcp.h" | 10 #include "content/browser/renderer_host/p2p/socket_host_tcp.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 result = socket_->GetLocalAddress(&local_address_); | 54 result = socket_->GetLocalAddress(&local_address_); |
55 if (result < 0) { | 55 if (result < 0) { |
56 LOG(ERROR) << "P2PSocketHostTcpServer::Init(): can't to get local address: " | 56 LOG(ERROR) << "P2PSocketHostTcpServer::Init(): can't to get local address: " |
57 << result; | 57 << result; |
58 OnError(); | 58 OnError(); |
59 return false; | 59 return false; |
60 } | 60 } |
61 VLOG(1) << "Local address: " << local_address_.ToString(); | 61 VLOG(1) << "Local address: " << local_address_.ToString(); |
62 | 62 |
63 state_ = STATE_OPEN; | 63 state_ = STATE_OPEN; |
64 message_sender_->Send(new P2PMsg_OnSocketCreated(id_, local_address_)); | 64 // NOTE: Remote address can be empty as socket is just listening |
| 65 // in this state. |
| 66 message_sender_->Send(new P2PMsg_OnSocketCreated( |
| 67 id_, local_address_, remote_address.ip_address)); |
65 DoAccept(); | 68 DoAccept(); |
66 return true; | 69 return true; |
67 } | 70 } |
68 | 71 |
69 void P2PSocketHostTcpServer::OnError() { | 72 void P2PSocketHostTcpServer::OnError() { |
70 socket_.reset(); | 73 socket_.reset(); |
71 | 74 |
72 if (state_ == STATE_UNINITIALIZED || state_ == STATE_OPEN) | 75 if (state_ == STATE_UNINITIALIZED || state_ == STATE_OPEN) |
73 message_sender_->Send(new P2PMsg_OnError(id_)); | 76 message_sender_->Send(new P2PMsg_OnError(id_)); |
74 | 77 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 return result.release(); | 146 return result.release(); |
144 } | 147 } |
145 | 148 |
146 bool P2PSocketHostTcpServer::SetOption(P2PSocketOption option, | 149 bool P2PSocketHostTcpServer::SetOption(P2PSocketOption option, |
147 int value) { | 150 int value) { |
148 // Currently we don't have use case tcp server sockets are used for p2p. | 151 // Currently we don't have use case tcp server sockets are used for p2p. |
149 return false; | 152 return false; |
150 } | 153 } |
151 | 154 |
152 } // namespace content | 155 } // namespace content |
OLD | NEW |