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/renderer/p2p/socket_dispatcher.h" | 5 #include "content/renderer/p2p/socket_dispatcher.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
10 #include "content/common/child_process.h" | 10 #include "content/common/child_process.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 channel_->Send(message); | 56 channel_->Send(message); |
57 } | 57 } |
58 | 58 |
59 bool P2PSocketDispatcher::OnMessageReceived(const IPC::Message& message) { | 59 bool P2PSocketDispatcher::OnMessageReceived(const IPC::Message& message) { |
60 bool handled = true; | 60 bool handled = true; |
61 IPC_BEGIN_MESSAGE_MAP(P2PSocketDispatcher, message) | 61 IPC_BEGIN_MESSAGE_MAP(P2PSocketDispatcher, message) |
62 IPC_MESSAGE_HANDLER(P2PMsg_NetworkListChanged, OnNetworkListChanged) | 62 IPC_MESSAGE_HANDLER(P2PMsg_NetworkListChanged, OnNetworkListChanged) |
63 IPC_MESSAGE_HANDLER(P2PMsg_GetHostAddressResult, OnGetHostAddressResult) | 63 IPC_MESSAGE_HANDLER(P2PMsg_GetHostAddressResult, OnGetHostAddressResult) |
64 IPC_MESSAGE_HANDLER(P2PMsg_OnSocketCreated, OnSocketCreated) | 64 IPC_MESSAGE_HANDLER(P2PMsg_OnSocketCreated, OnSocketCreated) |
65 IPC_MESSAGE_HANDLER(P2PMsg_OnIncomingTcpConnection, OnIncomingTcpConnection) | 65 IPC_MESSAGE_HANDLER(P2PMsg_OnIncomingTcpConnection, OnIncomingTcpConnection) |
| 66 IPC_MESSAGE_HANDLER(P2PMsg_OnSendComplete, OnSendComplete) |
66 IPC_MESSAGE_HANDLER(P2PMsg_OnError, OnError) | 67 IPC_MESSAGE_HANDLER(P2PMsg_OnError, OnError) |
67 IPC_MESSAGE_HANDLER(P2PMsg_OnDataReceived, OnDataReceived) | 68 IPC_MESSAGE_HANDLER(P2PMsg_OnDataReceived, OnDataReceived) |
68 IPC_MESSAGE_UNHANDLED(handled = false) | 69 IPC_MESSAGE_UNHANDLED(handled = false) |
69 IPC_END_MESSAGE_MAP() | 70 IPC_END_MESSAGE_MAP() |
70 return handled; | 71 return handled; |
71 } | 72 } |
72 | 73 |
73 void P2PSocketDispatcher::OnFilterAdded(IPC::Channel* channel) { | 74 void P2PSocketDispatcher::OnFilterAdded(IPC::Channel* channel) { |
74 DVLOG(1) << "P2PSocketDispatcher::OnFilterAdded()"; | 75 DVLOG(1) << "P2PSocketDispatcher::OnFilterAdded()"; |
75 channel_ = channel; | 76 channel_ = channel; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 } | 146 } |
146 | 147 |
147 void P2PSocketDispatcher::OnIncomingTcpConnection( | 148 void P2PSocketDispatcher::OnIncomingTcpConnection( |
148 int socket_id, const net::IPEndPoint& address) { | 149 int socket_id, const net::IPEndPoint& address) { |
149 P2PSocketClient* client = GetClient(socket_id); | 150 P2PSocketClient* client = GetClient(socket_id); |
150 if (client) { | 151 if (client) { |
151 client->OnIncomingTcpConnection(address); | 152 client->OnIncomingTcpConnection(address); |
152 } | 153 } |
153 } | 154 } |
154 | 155 |
| 156 void P2PSocketDispatcher::OnSendComplete(int socket_id) { |
| 157 P2PSocketClient* client = GetClient(socket_id); |
| 158 if (client) { |
| 159 client->OnSendComplete(); |
| 160 } |
| 161 } |
| 162 |
155 void P2PSocketDispatcher::OnError(int socket_id) { | 163 void P2PSocketDispatcher::OnError(int socket_id) { |
156 P2PSocketClient* client = GetClient(socket_id); | 164 P2PSocketClient* client = GetClient(socket_id); |
157 if (client) { | 165 if (client) { |
158 client->OnError(); | 166 client->OnError(); |
159 } | 167 } |
160 } | 168 } |
161 | 169 |
162 void P2PSocketDispatcher::OnDataReceived( | 170 void P2PSocketDispatcher::OnDataReceived( |
163 int socket_id, const net::IPEndPoint& address, | 171 int socket_id, const net::IPEndPoint& address, |
164 const std::vector<char>& data) { | 172 const std::vector<char>& data) { |
(...skipping 10 matching lines...) Expand all Loading... |
175 // hasn't processed the close message by the time it sends the | 183 // hasn't processed the close message by the time it sends the |
176 // message to the renderer. | 184 // message to the renderer. |
177 VLOG(1) << "Received P2P message for socket that doesn't exist."; | 185 VLOG(1) << "Received P2P message for socket that doesn't exist."; |
178 return NULL; | 186 return NULL; |
179 } | 187 } |
180 | 188 |
181 return client; | 189 return client; |
182 } | 190 } |
183 | 191 |
184 } // namespace content | 192 } // namespace content |
OLD | NEW |