| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef EXTENSIONS_BROWSER_API_SOCKETS_TCP_SERVER_SOCKETS_TCP_SERVER_API_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_SOCKETS_TCP_SERVER_SOCKETS_TCP_SERVER_API_H_ |
| 6 #define EXTENSIONS_BROWSER_API_SOCKETS_TCP_SERVER_SOCKETS_TCP_SERVER_API_H_ | 6 #define EXTENSIONS_BROWSER_API_SOCKETS_TCP_SERVER_SOCKETS_TCP_SERVER_API_H_ |
| 7 | 7 |
| 8 #include "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
| 9 #include "extensions/browser/api/socket/socket_api.h" | 9 #include "extensions/browser/api/socket/socket_api.h" |
| 10 #include "extensions/common/api/sockets_tcp_server.h" | 10 #include "extensions/common/api/sockets_tcp_server.h" |
| 11 | 11 |
| 12 namespace extensions { | 12 namespace extensions { |
| 13 class ResumableTCPServerSocket; | 13 class ResumableTCPServerSocket; |
| 14 } | 14 } |
| 15 | 15 |
| 16 namespace extensions { | 16 namespace extensions { |
| 17 namespace api { | 17 namespace api { |
| 18 | 18 |
| 19 class TCPServerSocketAsyncApiFunction : public SocketAsyncApiFunction { | 19 class TCPServerSocketAsyncApiFunction : public SocketAsyncApiFunction { |
| 20 protected: | 20 protected: |
| 21 ~TCPServerSocketAsyncApiFunction() override; | 21 ~TCPServerSocketAsyncApiFunction() override; |
| 22 | 22 |
| 23 scoped_ptr<SocketResourceManagerInterface> CreateSocketResourceManager() | 23 std::unique_ptr<SocketResourceManagerInterface> CreateSocketResourceManager() |
| 24 override; | 24 override; |
| 25 | 25 |
| 26 ResumableTCPServerSocket* GetTcpSocket(int socket_id); | 26 ResumableTCPServerSocket* GetTcpSocket(int socket_id); |
| 27 }; | 27 }; |
| 28 | 28 |
| 29 class SocketsTcpServerCreateFunction : public TCPServerSocketAsyncApiFunction { | 29 class SocketsTcpServerCreateFunction : public TCPServerSocketAsyncApiFunction { |
| 30 public: | 30 public: |
| 31 DECLARE_EXTENSION_FUNCTION("sockets.tcpServer.create", | 31 DECLARE_EXTENSION_FUNCTION("sockets.tcpServer.create", |
| 32 SOCKETS_TCP_SERVER_CREATE) | 32 SOCKETS_TCP_SERVER_CREATE) |
| 33 | 33 |
| 34 SocketsTcpServerCreateFunction(); | 34 SocketsTcpServerCreateFunction(); |
| 35 | 35 |
| 36 protected: | 36 protected: |
| 37 ~SocketsTcpServerCreateFunction() override; | 37 ~SocketsTcpServerCreateFunction() override; |
| 38 | 38 |
| 39 // AsyncApiFunction: | 39 // AsyncApiFunction: |
| 40 bool Prepare() override; | 40 bool Prepare() override; |
| 41 void Work() override; | 41 void Work() override; |
| 42 | 42 |
| 43 private: | 43 private: |
| 44 FRIEND_TEST_ALL_PREFIXES(SocketsTcpServerUnitTest, Create); | 44 FRIEND_TEST_ALL_PREFIXES(SocketsTcpServerUnitTest, Create); |
| 45 scoped_ptr<sockets_tcp_server::Create::Params> params_; | 45 std::unique_ptr<sockets_tcp_server::Create::Params> params_; |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 class SocketsTcpServerUpdateFunction : public TCPServerSocketAsyncApiFunction { | 48 class SocketsTcpServerUpdateFunction : public TCPServerSocketAsyncApiFunction { |
| 49 public: | 49 public: |
| 50 DECLARE_EXTENSION_FUNCTION("sockets.tcpServer.update", | 50 DECLARE_EXTENSION_FUNCTION("sockets.tcpServer.update", |
| 51 SOCKETS_TCP_SERVER_UPDATE) | 51 SOCKETS_TCP_SERVER_UPDATE) |
| 52 | 52 |
| 53 SocketsTcpServerUpdateFunction(); | 53 SocketsTcpServerUpdateFunction(); |
| 54 | 54 |
| 55 protected: | 55 protected: |
| 56 ~SocketsTcpServerUpdateFunction() override; | 56 ~SocketsTcpServerUpdateFunction() override; |
| 57 | 57 |
| 58 // AsyncApiFunction: | 58 // AsyncApiFunction: |
| 59 bool Prepare() override; | 59 bool Prepare() override; |
| 60 void Work() override; | 60 void Work() override; |
| 61 | 61 |
| 62 private: | 62 private: |
| 63 scoped_ptr<sockets_tcp_server::Update::Params> params_; | 63 std::unique_ptr<sockets_tcp_server::Update::Params> params_; |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 class SocketsTcpServerSetPausedFunction | 66 class SocketsTcpServerSetPausedFunction |
| 67 : public TCPServerSocketAsyncApiFunction { | 67 : public TCPServerSocketAsyncApiFunction { |
| 68 public: | 68 public: |
| 69 DECLARE_EXTENSION_FUNCTION("sockets.tcpServer.setPaused", | 69 DECLARE_EXTENSION_FUNCTION("sockets.tcpServer.setPaused", |
| 70 SOCKETS_TCP_SERVER_SETPAUSED) | 70 SOCKETS_TCP_SERVER_SETPAUSED) |
| 71 | 71 |
| 72 SocketsTcpServerSetPausedFunction(); | 72 SocketsTcpServerSetPausedFunction(); |
| 73 | 73 |
| 74 protected: | 74 protected: |
| 75 ~SocketsTcpServerSetPausedFunction() override; | 75 ~SocketsTcpServerSetPausedFunction() override; |
| 76 | 76 |
| 77 // AsyncApiFunction | 77 // AsyncApiFunction |
| 78 bool Prepare() override; | 78 bool Prepare() override; |
| 79 void Work() override; | 79 void Work() override; |
| 80 | 80 |
| 81 private: | 81 private: |
| 82 scoped_ptr<sockets_tcp_server::SetPaused::Params> params_; | 82 std::unique_ptr<sockets_tcp_server::SetPaused::Params> params_; |
| 83 TCPServerSocketEventDispatcher* socket_event_dispatcher_; | 83 TCPServerSocketEventDispatcher* socket_event_dispatcher_; |
| 84 }; | 84 }; |
| 85 | 85 |
| 86 class SocketsTcpServerListenFunction : public TCPServerSocketAsyncApiFunction { | 86 class SocketsTcpServerListenFunction : public TCPServerSocketAsyncApiFunction { |
| 87 public: | 87 public: |
| 88 DECLARE_EXTENSION_FUNCTION("sockets.tcpServer.listen", | 88 DECLARE_EXTENSION_FUNCTION("sockets.tcpServer.listen", |
| 89 SOCKETS_TCP_SERVER_LISTEN) | 89 SOCKETS_TCP_SERVER_LISTEN) |
| 90 | 90 |
| 91 SocketsTcpServerListenFunction(); | 91 SocketsTcpServerListenFunction(); |
| 92 | 92 |
| 93 protected: | 93 protected: |
| 94 ~SocketsTcpServerListenFunction() override; | 94 ~SocketsTcpServerListenFunction() override; |
| 95 | 95 |
| 96 // AsyncApiFunction: | 96 // AsyncApiFunction: |
| 97 bool Prepare() override; | 97 bool Prepare() override; |
| 98 void AsyncWorkStart() override; | 98 void AsyncWorkStart() override; |
| 99 | 99 |
| 100 private: | 100 private: |
| 101 scoped_ptr<sockets_tcp_server::Listen::Params> params_; | 101 std::unique_ptr<sockets_tcp_server::Listen::Params> params_; |
| 102 TCPServerSocketEventDispatcher* socket_event_dispatcher_; | 102 TCPServerSocketEventDispatcher* socket_event_dispatcher_; |
| 103 }; | 103 }; |
| 104 | 104 |
| 105 class SocketsTcpServerDisconnectFunction | 105 class SocketsTcpServerDisconnectFunction |
| 106 : public TCPServerSocketAsyncApiFunction { | 106 : public TCPServerSocketAsyncApiFunction { |
| 107 public: | 107 public: |
| 108 DECLARE_EXTENSION_FUNCTION("sockets.tcpServer.disconnect", | 108 DECLARE_EXTENSION_FUNCTION("sockets.tcpServer.disconnect", |
| 109 SOCKETS_TCP_SERVER_DISCONNECT) | 109 SOCKETS_TCP_SERVER_DISCONNECT) |
| 110 | 110 |
| 111 SocketsTcpServerDisconnectFunction(); | 111 SocketsTcpServerDisconnectFunction(); |
| 112 | 112 |
| 113 protected: | 113 protected: |
| 114 ~SocketsTcpServerDisconnectFunction() override; | 114 ~SocketsTcpServerDisconnectFunction() override; |
| 115 | 115 |
| 116 // AsyncApiFunction: | 116 // AsyncApiFunction: |
| 117 bool Prepare() override; | 117 bool Prepare() override; |
| 118 void Work() override; | 118 void Work() override; |
| 119 | 119 |
| 120 private: | 120 private: |
| 121 scoped_ptr<sockets_tcp_server::Disconnect::Params> params_; | 121 std::unique_ptr<sockets_tcp_server::Disconnect::Params> params_; |
| 122 }; | 122 }; |
| 123 | 123 |
| 124 class SocketsTcpServerCloseFunction : public TCPServerSocketAsyncApiFunction { | 124 class SocketsTcpServerCloseFunction : public TCPServerSocketAsyncApiFunction { |
| 125 public: | 125 public: |
| 126 DECLARE_EXTENSION_FUNCTION("sockets.tcpServer.close", | 126 DECLARE_EXTENSION_FUNCTION("sockets.tcpServer.close", |
| 127 SOCKETS_TCP_SERVER_CLOSE) | 127 SOCKETS_TCP_SERVER_CLOSE) |
| 128 | 128 |
| 129 SocketsTcpServerCloseFunction(); | 129 SocketsTcpServerCloseFunction(); |
| 130 | 130 |
| 131 protected: | 131 protected: |
| 132 ~SocketsTcpServerCloseFunction() override; | 132 ~SocketsTcpServerCloseFunction() override; |
| 133 | 133 |
| 134 // AsyncApiFunction: | 134 // AsyncApiFunction: |
| 135 bool Prepare() override; | 135 bool Prepare() override; |
| 136 void Work() override; | 136 void Work() override; |
| 137 | 137 |
| 138 private: | 138 private: |
| 139 scoped_ptr<sockets_tcp_server::Close::Params> params_; | 139 std::unique_ptr<sockets_tcp_server::Close::Params> params_; |
| 140 }; | 140 }; |
| 141 | 141 |
| 142 class SocketsTcpServerGetInfoFunction : public TCPServerSocketAsyncApiFunction { | 142 class SocketsTcpServerGetInfoFunction : public TCPServerSocketAsyncApiFunction { |
| 143 public: | 143 public: |
| 144 DECLARE_EXTENSION_FUNCTION("sockets.tcpServer.getInfo", | 144 DECLARE_EXTENSION_FUNCTION("sockets.tcpServer.getInfo", |
| 145 SOCKETS_TCP_SERVER_GETINFO) | 145 SOCKETS_TCP_SERVER_GETINFO) |
| 146 | 146 |
| 147 SocketsTcpServerGetInfoFunction(); | 147 SocketsTcpServerGetInfoFunction(); |
| 148 | 148 |
| 149 protected: | 149 protected: |
| 150 ~SocketsTcpServerGetInfoFunction() override; | 150 ~SocketsTcpServerGetInfoFunction() override; |
| 151 | 151 |
| 152 // AsyncApiFunction: | 152 // AsyncApiFunction: |
| 153 bool Prepare() override; | 153 bool Prepare() override; |
| 154 void Work() override; | 154 void Work() override; |
| 155 | 155 |
| 156 private: | 156 private: |
| 157 scoped_ptr<sockets_tcp_server::GetInfo::Params> params_; | 157 std::unique_ptr<sockets_tcp_server::GetInfo::Params> params_; |
| 158 }; | 158 }; |
| 159 | 159 |
| 160 class SocketsTcpServerGetSocketsFunction | 160 class SocketsTcpServerGetSocketsFunction |
| 161 : public TCPServerSocketAsyncApiFunction { | 161 : public TCPServerSocketAsyncApiFunction { |
| 162 public: | 162 public: |
| 163 DECLARE_EXTENSION_FUNCTION("sockets.tcpServer.getSockets", | 163 DECLARE_EXTENSION_FUNCTION("sockets.tcpServer.getSockets", |
| 164 SOCKETS_TCP_SERVER_GETSOCKETS) | 164 SOCKETS_TCP_SERVER_GETSOCKETS) |
| 165 | 165 |
| 166 SocketsTcpServerGetSocketsFunction(); | 166 SocketsTcpServerGetSocketsFunction(); |
| 167 | 167 |
| 168 protected: | 168 protected: |
| 169 ~SocketsTcpServerGetSocketsFunction() override; | 169 ~SocketsTcpServerGetSocketsFunction() override; |
| 170 | 170 |
| 171 // AsyncApiFunction: | 171 // AsyncApiFunction: |
| 172 bool Prepare() override; | 172 bool Prepare() override; |
| 173 void Work() override; | 173 void Work() override; |
| 174 }; | 174 }; |
| 175 | 175 |
| 176 } // namespace api | 176 } // namespace api |
| 177 } // namespace extensions | 177 } // namespace extensions |
| 178 | 178 |
| 179 #endif // EXTENSIONS_BROWSER_API_SOCKETS_TCP_SERVER_SOCKETS_TCP_SERVER_API_H_ | 179 #endif // EXTENSIONS_BROWSER_API_SOCKETS_TCP_SERVER_SOCKETS_TCP_SERVER_API_H_ |
| OLD | NEW |