1a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved. 28bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 38bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// found in the LICENSE file. 48bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 5a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#ifndef EXTENSIONS_BROWSER_API_SOCKETS_TCP_SERVER_SOCKETS_TCP_SERVER_API_H_ 6a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#define EXTENSIONS_BROWSER_API_SOCKETS_TCP_SERVER_SOCKETS_TCP_SERVER_API_H_ 78bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 8a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "extensions/browser/api/socket/socket_api.h" 9a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "extensions/common/api/sockets_tcp_server.h" 108bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 118bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)namespace extensions { 128bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)class ResumableTCPServerSocket; 138bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)} 148bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 158bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)namespace extensions { 16a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)namespace core_api { 178bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 188bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)class TCPServerSocketAsyncApiFunction : public SocketAsyncApiFunction { 198bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) protected: 208bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual ~TCPServerSocketAsyncApiFunction(); 218bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 228bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual scoped_ptr<SocketResourceManagerInterface> 238bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) CreateSocketResourceManager() OVERRIDE; 248bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 258bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) ResumableTCPServerSocket* GetTcpSocket(int socket_id); 268bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}; 278bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 288bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)class SocketsTcpServerCreateFunction : public TCPServerSocketAsyncApiFunction { 298bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) public: 308bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) DECLARE_EXTENSION_FUNCTION("sockets.tcpServer.create", 318bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) SOCKETS_TCP_SERVER_CREATE) 328bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 338bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) SocketsTcpServerCreateFunction(); 348bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 358bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) protected: 368bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual ~SocketsTcpServerCreateFunction(); 378bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 388bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // AsyncApiFunction: 398bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual bool Prepare() OVERRIDE; 408bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void Work() OVERRIDE; 418bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 428bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) private: 438bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) FRIEND_TEST_ALL_PREFIXES(SocketsTcpServerUnitTest, Create); 448bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) scoped_ptr<sockets_tcp_server::Create::Params> params_; 458bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}; 468bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 478bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)class SocketsTcpServerUpdateFunction : public TCPServerSocketAsyncApiFunction { 488bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) public: 498bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) DECLARE_EXTENSION_FUNCTION("sockets.tcpServer.update", 508bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) SOCKETS_TCP_SERVER_UPDATE) 518bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 528bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) SocketsTcpServerUpdateFunction(); 538bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 548bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) protected: 558bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual ~SocketsTcpServerUpdateFunction(); 568bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 578bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // AsyncApiFunction: 588bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual bool Prepare() OVERRIDE; 598bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void Work() OVERRIDE; 608bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 618bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) private: 628bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) scoped_ptr<sockets_tcp_server::Update::Params> params_; 638bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}; 648bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 658bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)class SocketsTcpServerSetPausedFunction 668bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) : public TCPServerSocketAsyncApiFunction { 678bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) public: 688bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) DECLARE_EXTENSION_FUNCTION("sockets.tcpServer.setPaused", 698bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) SOCKETS_TCP_SERVER_SETPAUSED) 708bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 718bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) SocketsTcpServerSetPausedFunction(); 728bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 738bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) protected: 748bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual ~SocketsTcpServerSetPausedFunction(); 758bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 768bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // AsyncApiFunction 778bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual bool Prepare() OVERRIDE; 788bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void Work() OVERRIDE; 798bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 808bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) private: 818bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) scoped_ptr<sockets_tcp_server::SetPaused::Params> params_; 828bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) TCPServerSocketEventDispatcher* socket_event_dispatcher_; 838bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}; 848bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 85a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)class SocketsTcpServerListenFunction : public TCPServerSocketAsyncApiFunction { 868bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) public: 878bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) DECLARE_EXTENSION_FUNCTION("sockets.tcpServer.listen", 888bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) SOCKETS_TCP_SERVER_LISTEN) 898bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 908bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) SocketsTcpServerListenFunction(); 918bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 928bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) protected: 938bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual ~SocketsTcpServerListenFunction(); 948bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 958bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // AsyncApiFunction: 968bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual bool Prepare() OVERRIDE; 978bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void Work() OVERRIDE; 988bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 998bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) private: 1008bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) scoped_ptr<sockets_tcp_server::Listen::Params> params_; 1018bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) TCPServerSocketEventDispatcher* socket_event_dispatcher_; 1028bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}; 1038bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1048bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)class SocketsTcpServerDisconnectFunction 1058bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) : public TCPServerSocketAsyncApiFunction { 1068bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) public: 1078bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) DECLARE_EXTENSION_FUNCTION("sockets.tcpServer.disconnect", 1088bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) SOCKETS_TCP_SERVER_DISCONNECT) 1098bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1108bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) SocketsTcpServerDisconnectFunction(); 1118bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1128bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) protected: 1138bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual ~SocketsTcpServerDisconnectFunction(); 1148bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1158bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // AsyncApiFunction: 1168bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual bool Prepare() OVERRIDE; 1178bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void Work() OVERRIDE; 1188bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1198bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) private: 1208bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) scoped_ptr<sockets_tcp_server::Disconnect::Params> params_; 1218bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}; 1228bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1238bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)class SocketsTcpServerCloseFunction : public TCPServerSocketAsyncApiFunction { 1248bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) public: 1258bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) DECLARE_EXTENSION_FUNCTION("sockets.tcpServer.close", 1268bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) SOCKETS_TCP_SERVER_CLOSE) 1278bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1288bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) SocketsTcpServerCloseFunction(); 1298bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1308bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) protected: 1318bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual ~SocketsTcpServerCloseFunction(); 1328bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1338bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // AsyncApiFunction: 1348bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual bool Prepare() OVERRIDE; 1358bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void Work() OVERRIDE; 1368bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1378bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) private: 1388bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) scoped_ptr<sockets_tcp_server::Close::Params> params_; 1398bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}; 1408bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1418bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)class SocketsTcpServerGetInfoFunction : public TCPServerSocketAsyncApiFunction { 1428bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) public: 1438bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) DECLARE_EXTENSION_FUNCTION("sockets.tcpServer.getInfo", 1448bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) SOCKETS_TCP_SERVER_GETINFO) 1458bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1468bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) SocketsTcpServerGetInfoFunction(); 1478bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1488bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) protected: 1498bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual ~SocketsTcpServerGetInfoFunction(); 1508bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1518bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // AsyncApiFunction: 1528bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual bool Prepare() OVERRIDE; 1538bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void Work() OVERRIDE; 1548bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1558bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) private: 1568bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) scoped_ptr<sockets_tcp_server::GetInfo::Params> params_; 1578bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}; 1588bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1598bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)class SocketsTcpServerGetSocketsFunction 1608bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) : public TCPServerSocketAsyncApiFunction { 1618bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) public: 1628bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) DECLARE_EXTENSION_FUNCTION("sockets.tcpServer.getSockets", 1638bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) SOCKETS_TCP_SERVER_GETSOCKETS) 1648bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1658bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) SocketsTcpServerGetSocketsFunction(); 1668bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1678bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) protected: 1688bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual ~SocketsTcpServerGetSocketsFunction(); 1698bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1708bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // AsyncApiFunction: 1718bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual bool Prepare() OVERRIDE; 1728bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void Work() OVERRIDE; 1738bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}; 1748bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 175a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} // namespace core_api 1768bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)} // namespace extensions 1778bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 178a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#endif // EXTENSIONS_BROWSER_API_SOCKETS_TCP_SERVER_SOCKETS_TCP_SERVER_API_H_ 179