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 "content/renderer/p2p/socket_client.h" | 5 #include "content/renderer/p2p/socket_client.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 "content/common/p2p_messages.h" | 9 #include "content/common/p2p_messages.h" |
10 #include "content/renderer/p2p/socket_dispatcher.h" | 10 #include "content/renderer/p2p/socket_dispatcher.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 if (state_ == STATE_OPEN || state_ == STATE_OPENING || | 104 if (state_ == STATE_OPEN || state_ == STATE_OPENING || |
105 state_ == STATE_ERROR) { | 105 state_ == STATE_ERROR) { |
106 dispatcher_->SendP2PMessage(new P2PHostMsg_DestroySocket(socket_id_)); | 106 dispatcher_->SendP2PMessage(new P2PHostMsg_DestroySocket(socket_id_)); |
107 } | 107 } |
108 dispatcher_->UnregisterClient(socket_id_); | 108 dispatcher_->UnregisterClient(socket_id_); |
109 } | 109 } |
110 | 110 |
111 state_ = STATE_CLOSED; | 111 state_ = STATE_CLOSED; |
112 } | 112 } |
113 | 113 |
| 114 int P2PSocketClient::socket_id() const { |
| 115 return socket_id_; |
| 116 } |
| 117 |
114 void P2PSocketClient::set_delegate(Delegate* delegate) { | 118 void P2PSocketClient::set_delegate(Delegate* delegate) { |
115 DCHECK(delegate_message_loop_->BelongsToCurrentThread()); | 119 DCHECK(delegate_message_loop_->BelongsToCurrentThread()); |
116 delegate_ = delegate; | 120 delegate_ = delegate; |
117 } | 121 } |
118 | 122 |
119 void P2PSocketClient::OnSocketCreated(const net::IPEndPoint& address) { | 123 void P2PSocketClient::OnSocketCreated(const net::IPEndPoint& address) { |
120 DCHECK(ipc_message_loop_->BelongsToCurrentThread()); | 124 DCHECK(ipc_message_loop_->BelongsToCurrentThread()); |
121 DCHECK_EQ(state_, STATE_OPENING); | 125 DCHECK_EQ(state_, STATE_OPENING); |
122 state_ = STATE_OPEN; | 126 state_ = STATE_OPEN; |
123 | 127 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 delegate_->OnDataReceived(address, data); | 207 delegate_->OnDataReceived(address, data); |
204 } | 208 } |
205 | 209 |
206 void P2PSocketClient::Detach() { | 210 void P2PSocketClient::Detach() { |
207 DCHECK(ipc_message_loop_->BelongsToCurrentThread()); | 211 DCHECK(ipc_message_loop_->BelongsToCurrentThread()); |
208 dispatcher_ = NULL; | 212 dispatcher_ = NULL; |
209 OnError(); | 213 OnError(); |
210 } | 214 } |
211 | 215 |
212 } // namespace content | 216 } // namespace content |
OLD | NEW |