Chromium Code Reviews| 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/callback.h" | |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 | |
| 13 class PepperMessageFilter; | |
| 14 struct PP_NetAddress_Private; | |
| 15 | |
| 16 namespace net { | |
| 17 class ServerSocket; | |
| 18 class StreamSocket; | |
| 19 } | |
| 20 | |
| 21 using base::Callback; | |
|
yzshen1
2012/02/09 02:31:50
Don't use 'using' in header files.
ygorshenin1
2012/02/09 15:00:10
Done.
| |
| 22 using net::StreamSocket; | |
| 23 | |
| 24 // PepperTCPSocket is used by PepperMessageFilter to handle requests | |
| 25 // from the Pepper TCP server socket API | |
| 26 // (PPB_TCPServerSocket_Private). | |
| 27 class PepperTCPServerSocket { | |
| 28 public: | |
| 29 typedef Callback<void(int32, | |
| 30 uint32, | |
| 31 uint32, | |
| 32 StreamSocket*, | |
| 33 PP_NetAddress_Private, | |
| 34 PP_NetAddress_Private)> AcceptCallback; | |
| 35 | |
| 36 PepperTCPServerSocket(PepperMessageFilter* manager, | |
| 37 int32 routing_id, | |
| 38 uint32 plugin_dispatcher_id, | |
| 39 uint32 socket_id); | |
| 40 ~PepperTCPServerSocket(); | |
| 41 | |
| 42 void SetAcceptCallback(const AcceptCallback& accept_callback); | |
| 43 | |
| 44 void Listen(const PP_NetAddress_Private& addr, int32 backlog); | |
| 45 void Accept(); | |
| 46 | |
| 47 private: | |
| 48 enum State { | |
| 49 BEFORE_LISTENING, | |
| 50 LISTEN_IN_PROGRESS, | |
| 51 LISTENING, | |
| 52 ACCEPT_IN_PROGRESS, | |
| 53 }; | |
| 54 | |
| 55 void SendListenACKError(); | |
| 56 void SendAcceptACKError(); | |
| 57 | |
| 58 void OnListenCompleted(int result); | |
| 59 void OnAcceptCompleted(int result); | |
| 60 | |
| 61 PepperMessageFilter* manager_; | |
| 62 int32 routing_id_; | |
| 63 uint32 plugin_dispatcher_id_; | |
| 64 uint32 socket_id_; | |
| 65 | |
| 66 State state_; | |
| 67 | |
| 68 scoped_ptr<net::ServerSocket> socket_; | |
| 69 scoped_ptr<net::StreamSocket> socket_buffer_; | |
| 70 | |
| 71 AcceptCallback accept_callback_; | |
| 72 | |
| 73 DISALLOW_COPY_AND_ASSIGN(PepperTCPServerSocket); | |
| 74 }; | |
| 75 | |
| 76 #endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_TCP_SERVER_SOCKET_H_ | |
| OLD | NEW |