OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_PEPPER_TCP_SERVER_SOCKET_H_ | |
6 #define CONTENT_BROWSER_RENDERER_HOST_PEPPER_TCP_SERVER_SOCKET_H_ | |
7 #pragma once | |
8 | |
9 #include "base/basictypes.h" | |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "ppapi/c/pp_resource.h" | |
12 | |
13 class PepperMessageFilter; | |
14 struct PP_NetAddress_Private; | |
15 | |
16 namespace net { | |
17 class ServerSocket; | |
18 class StreamSocket; | |
19 } | |
20 | |
21 // PepperTCPSocket is used by PepperMessageFilter to handle requests | |
22 // from the Pepper TCP server socket API | |
23 // (PPB_TCPServerSocket_Private). | |
24 class PepperTCPServerSocket { | |
25 public: | |
26 PepperTCPServerSocket(PepperMessageFilter* manager, | |
27 int32 routing_id, | |
28 uint32 plugin_dispatcher_id, | |
29 PP_Resource socket_resource, | |
30 uint32 socket_id); | |
31 ~PepperTCPServerSocket(); | |
32 | |
33 void Listen(const PP_NetAddress_Private& addr, int32 backlog); | |
34 void Accept(int32 tcp_client_socket_routing_id); | |
35 | |
36 private: | |
37 enum State { | |
38 BEFORE_LISTENING, | |
39 LISTEN_IN_PROGRESS, | |
40 LISTENING, | |
41 ACCEPT_IN_PROGRESS, | |
42 }; | |
43 | |
44 void CancelListenRequest(); | |
45 void SendAcceptACKError(); | |
46 | |
47 void OnListenCompleted(int result); | |
48 void OnAcceptCompleted(int32 tcp_client_socket_routing_id, | |
49 int result); | |
50 | |
51 PepperMessageFilter* manager_; | |
52 int32 routing_id_; | |
53 uint32 plugin_dispatcher_id_; | |
54 // socket_resource_ is used only as an ID on the browser side. So we | |
55 // don't hold the ref to this resource and it may become invalid at | |
56 // the renderer/plugin side. | |
57 PP_Resource socket_resource_; | |
58 uint32 socket_id_; | |
59 | |
60 State state_; | |
61 | |
62 scoped_ptr<net::ServerSocket> socket_; | |
63 scoped_ptr<net::StreamSocket> socket_buffer_; | |
64 | |
65 DISALLOW_COPY_AND_ASSIGN(PepperTCPServerSocket); | |
66 }; | |
67 | |
68 #endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_TCP_SERVER_SOCKET_H_ | |
OLD | NEW |