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 "ppapi/proxy/ppb_tcp_socket_proxy.h" | 5 #include "ppapi/proxy/ppb_tcp_socket_proxy.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "ppapi/proxy/plugin_dispatcher.h" | 10 #include "ppapi/proxy/plugin_dispatcher.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 scoped_refptr<TrackedCallback> callback) OVERRIDE; | 44 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
45 virtual PP_Resource GetLocalAddress() OVERRIDE; | 45 virtual PP_Resource GetLocalAddress() OVERRIDE; |
46 virtual PP_Resource GetRemoteAddress() OVERRIDE; | 46 virtual PP_Resource GetRemoteAddress() OVERRIDE; |
47 virtual int32_t Read(char* buffer, | 47 virtual int32_t Read(char* buffer, |
48 int32_t bytes_to_read, | 48 int32_t bytes_to_read, |
49 scoped_refptr<TrackedCallback> callback) OVERRIDE; | 49 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
50 virtual int32_t Write(const char* buffer, | 50 virtual int32_t Write(const char* buffer, |
51 int32_t bytes_to_write, | 51 int32_t bytes_to_write, |
52 scoped_refptr<TrackedCallback> callback) OVERRIDE; | 52 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
53 virtual void Close() OVERRIDE; | 53 virtual void Close() OVERRIDE; |
54 virtual int32_t SetOption(PP_TCPSocket_Option_Dev name, | 54 virtual int32_t SetOption(PP_TCPSocket_Option name, |
55 const PP_Var& value, | 55 const PP_Var& value, |
56 scoped_refptr<TrackedCallback> callback) OVERRIDE; | 56 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
57 | 57 |
58 // TCPSocketShared implementation. | 58 // TCPSocketShared implementation. |
59 virtual void SendConnect(const std::string& host, uint16_t port) OVERRIDE; | 59 virtual void SendConnect(const std::string& host, uint16_t port) OVERRIDE; |
60 virtual void SendConnectWithNetAddress( | 60 virtual void SendConnectWithNetAddress( |
61 const PP_NetAddress_Private& addr) OVERRIDE; | 61 const PP_NetAddress_Private& addr) OVERRIDE; |
62 virtual void SendSSLHandshake( | 62 virtual void SendSSLHandshake( |
63 const std::string& server_name, | 63 const std::string& server_name, |
64 uint16_t server_port, | 64 uint16_t server_port, |
65 const std::vector<std::vector<char> >& trusted_certs, | 65 const std::vector<std::vector<char> >& trusted_certs, |
66 const std::vector<std::vector<char> >& untrusted_certs) OVERRIDE; | 66 const std::vector<std::vector<char> >& untrusted_certs) OVERRIDE; |
67 virtual void SendRead(int32_t bytes_to_read) OVERRIDE; | 67 virtual void SendRead(int32_t bytes_to_read) OVERRIDE; |
68 virtual void SendWrite(const std::string& buffer) OVERRIDE; | 68 virtual void SendWrite(const std::string& buffer) OVERRIDE; |
69 virtual void SendDisconnect() OVERRIDE; | 69 virtual void SendDisconnect() OVERRIDE; |
70 virtual void SendSetOption(PP_TCPSocket_Option_Dev name, | 70 virtual void SendSetOption(PP_TCPSocket_Option name, |
71 const SocketOptionData& value) OVERRIDE; | 71 const SocketOptionData& value) OVERRIDE; |
72 virtual Resource* GetOwnerResource() OVERRIDE; | 72 virtual Resource* GetOwnerResource() OVERRIDE; |
73 | 73 |
74 private: | 74 private: |
75 void SendToBrowser(IPC::Message* msg); | 75 void SendToBrowser(IPC::Message* msg); |
76 | 76 |
77 DISALLOW_COPY_AND_ASSIGN(TCPSocket); | 77 DISALLOW_COPY_AND_ASSIGN(TCPSocket); |
78 }; | 78 }; |
79 | 79 |
80 TCPSocket::TCPSocket(const HostResource& resource, uint32 socket_id) | 80 TCPSocket::TCPSocket(const HostResource& resource, uint32 socket_id) |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 int32_t TCPSocket::Write(const char* buffer, | 137 int32_t TCPSocket::Write(const char* buffer, |
138 int32_t bytes_to_write, | 138 int32_t bytes_to_write, |
139 scoped_refptr<TrackedCallback> callback) { | 139 scoped_refptr<TrackedCallback> callback) { |
140 return WriteImpl(buffer, bytes_to_write, callback); | 140 return WriteImpl(buffer, bytes_to_write, callback); |
141 } | 141 } |
142 | 142 |
143 void TCPSocket::Close() { | 143 void TCPSocket::Close() { |
144 DisconnectImpl(); | 144 DisconnectImpl(); |
145 } | 145 } |
146 | 146 |
147 int32_t TCPSocket::SetOption(PP_TCPSocket_Option_Dev name, | 147 int32_t TCPSocket::SetOption(PP_TCPSocket_Option name, |
148 const PP_Var& value, | 148 const PP_Var& value, |
149 scoped_refptr<TrackedCallback> callback) { | 149 scoped_refptr<TrackedCallback> callback) { |
150 return SetOptionImpl(name, value, callback); | 150 return SetOptionImpl(name, value, callback); |
151 } | 151 } |
152 | 152 |
153 void TCPSocket::SendConnect(const std::string& host, uint16_t port) { | 153 void TCPSocket::SendConnect(const std::string& host, uint16_t port) { |
154 NOTREACHED(); | 154 NOTREACHED(); |
155 } | 155 } |
156 | 156 |
157 void TCPSocket::SendConnectWithNetAddress(const PP_NetAddress_Private& addr) { | 157 void TCPSocket::SendConnectWithNetAddress(const PP_NetAddress_Private& addr) { |
(...skipping 18 matching lines...) Expand all Loading... |
176 } | 176 } |
177 | 177 |
178 void TCPSocket::SendDisconnect() { | 178 void TCPSocket::SendDisconnect() { |
179 // After removed from the mapping, this object won't receive any notifications | 179 // After removed from the mapping, this object won't receive any notifications |
180 // from the proxy. | 180 // from the proxy. |
181 DCHECK(g_id_to_socket->find(socket_id_) != g_id_to_socket->end()); | 181 DCHECK(g_id_to_socket->find(socket_id_) != g_id_to_socket->end()); |
182 g_id_to_socket->erase(socket_id_); | 182 g_id_to_socket->erase(socket_id_); |
183 SendToBrowser(new PpapiHostMsg_PPBTCPSocket_Disconnect(socket_id_)); | 183 SendToBrowser(new PpapiHostMsg_PPBTCPSocket_Disconnect(socket_id_)); |
184 } | 184 } |
185 | 185 |
186 void TCPSocket::SendSetOption(PP_TCPSocket_Option_Dev name, | 186 void TCPSocket::SendSetOption(PP_TCPSocket_Option name, |
187 const SocketOptionData& value) { | 187 const SocketOptionData& value) { |
188 SendToBrowser( | 188 SendToBrowser( |
189 new PpapiHostMsg_PPBTCPSocket_SetOption(socket_id_, name, value)); | 189 new PpapiHostMsg_PPBTCPSocket_SetOption(socket_id_, name, value)); |
190 } | 190 } |
191 | 191 |
192 Resource* TCPSocket::GetOwnerResource() { | 192 Resource* TCPSocket::GetOwnerResource() { |
193 return this; | 193 return this; |
194 } | 194 } |
195 | 195 |
196 void TCPSocket::SendToBrowser(IPC::Message* msg) { | 196 void TCPSocket::SendToBrowser(IPC::Message* msg) { |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 return; | 290 return; |
291 } | 291 } |
292 IDToSocketMap::iterator iter = g_id_to_socket->find(socket_id); | 292 IDToSocketMap::iterator iter = g_id_to_socket->find(socket_id); |
293 if (iter == g_id_to_socket->end()) | 293 if (iter == g_id_to_socket->end()) |
294 return; | 294 return; |
295 iter->second->OnSetOptionCompleted(result); | 295 iter->second->OnSetOptionCompleted(result); |
296 } | 296 } |
297 | 297 |
298 } // namespace proxy | 298 } // namespace proxy |
299 } // namespace ppapi | 299 } // namespace ppapi |
OLD | NEW |