Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/renderer/p2p/socket_client_impl.h" | 5 #include "content/renderer/p2p/socket_client_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop_proxy.h" | 8 #include "base/message_loop/message_loop_proxy.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "content/common/p2p_messages.h" | 10 #include "content/common/p2p_messages.h" |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 | 136 |
| 137 int P2PSocketClientImpl::GetSocketID() const { | 137 int P2PSocketClientImpl::GetSocketID() const { |
| 138 return socket_id_; | 138 return socket_id_; |
| 139 } | 139 } |
| 140 | 140 |
| 141 void P2PSocketClientImpl::SetDelegate(P2PSocketClientDelegate* delegate) { | 141 void P2PSocketClientImpl::SetDelegate(P2PSocketClientDelegate* delegate) { |
| 142 DCHECK(delegate_message_loop_->BelongsToCurrentThread()); | 142 DCHECK(delegate_message_loop_->BelongsToCurrentThread()); |
| 143 delegate_ = delegate; | 143 delegate_ = delegate; |
| 144 } | 144 } |
| 145 | 145 |
| 146 void P2PSocketClientImpl::OnSocketCreated(const net::IPEndPoint& address) { | 146 void P2PSocketClientImpl::OnSocketCreated( |
| 147 const net::IPEndPoint& address, const net::IPEndPoint& remote_address) { | |
|
Sergey Ulanov
2014/07/03 03:31:06
nit: one argument per line, local_address
Mallinath (Gone from Chromium)
2014/07/07 17:56:44
Done.
| |
| 147 DCHECK(ipc_message_loop_->BelongsToCurrentThread()); | 148 DCHECK(ipc_message_loop_->BelongsToCurrentThread()); |
| 148 DCHECK_EQ(state_, STATE_OPENING); | 149 DCHECK_EQ(state_, STATE_OPENING); |
| 149 state_ = STATE_OPEN; | 150 state_ = STATE_OPEN; |
| 150 | 151 |
| 151 delegate_message_loop_->PostTask( | 152 delegate_message_loop_->PostTask( |
| 152 FROM_HERE, | 153 FROM_HERE, |
| 153 base::Bind(&P2PSocketClientImpl::DeliverOnSocketCreated, this, address)); | 154 base::Bind(&P2PSocketClientImpl::DeliverOnSocketCreated, this, address, |
| 155 remote_address)); | |
| 154 } | 156 } |
| 155 | 157 |
| 156 void P2PSocketClientImpl::DeliverOnSocketCreated( | 158 void P2PSocketClientImpl::DeliverOnSocketCreated( |
| 157 const net::IPEndPoint& address) { | 159 const net::IPEndPoint& address, const net::IPEndPoint& remote_address) { |
| 158 DCHECK(delegate_message_loop_->BelongsToCurrentThread()); | 160 DCHECK(delegate_message_loop_->BelongsToCurrentThread()); |
| 159 if (delegate_) | 161 if (delegate_) |
| 160 delegate_->OnOpen(address); | 162 delegate_->OnOpen(address, remote_address); |
| 161 } | 163 } |
| 162 | 164 |
| 163 void P2PSocketClientImpl::OnIncomingTcpConnection( | 165 void P2PSocketClientImpl::OnIncomingTcpConnection( |
| 164 const net::IPEndPoint& address) { | 166 const net::IPEndPoint& address) { |
| 165 DCHECK(ipc_message_loop_->BelongsToCurrentThread()); | 167 DCHECK(ipc_message_loop_->BelongsToCurrentThread()); |
| 166 DCHECK_EQ(state_, STATE_OPEN); | 168 DCHECK_EQ(state_, STATE_OPEN); |
| 167 | 169 |
| 168 scoped_refptr<P2PSocketClientImpl> new_client = | 170 scoped_refptr<P2PSocketClientImpl> new_client = |
| 169 new P2PSocketClientImpl(dispatcher_); | 171 new P2PSocketClientImpl(dispatcher_); |
| 170 new_client->socket_id_ = dispatcher_->RegisterClient(new_client.get()); | 172 new_client->socket_id_ = dispatcher_->RegisterClient(new_client.get()); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 241 delegate_->OnDataReceived(address, data, timestamp); | 243 delegate_->OnDataReceived(address, data, timestamp); |
| 242 } | 244 } |
| 243 | 245 |
| 244 void P2PSocketClientImpl::Detach() { | 246 void P2PSocketClientImpl::Detach() { |
| 245 DCHECK(ipc_message_loop_->BelongsToCurrentThread()); | 247 DCHECK(ipc_message_loop_->BelongsToCurrentThread()); |
| 246 dispatcher_ = NULL; | 248 dispatcher_ = NULL; |
| 247 OnError(); | 249 OnError(); |
| 248 } | 250 } |
| 249 | 251 |
| 250 } // namespace content | 252 } // namespace content |
| OLD | NEW |