OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_API_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_API_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "chrome/browser/extensions/api/api_function.h" | 9 #include "chrome/browser/extensions/api/api_function.h" |
10 #include "chrome/browser/extensions/api/api_resource_manager.h" | 10 #include "chrome/browser/extensions/api/api_resource_manager.h" |
11 #include "chrome/browser/extensions/extension_function.h" | 11 #include "chrome/browser/extensions/extension_function.h" |
| 12 #include "chrome/common/extensions/api/experimental_socket.h" |
12 #include "chrome/common/extensions/api/socket.h" | 13 #include "chrome/common/extensions/api/socket.h" |
13 #include "net/base/address_list.h" | 14 #include "net/base/address_list.h" |
14 #include "net/base/host_resolver.h" | 15 #include "net/base/host_resolver.h" |
| 16 #include "net/socket/tcp_client_socket.h" |
15 | 17 |
16 #include <string> | 18 #include <string> |
17 | 19 |
18 class IOThread; | 20 class IOThread; |
19 | 21 |
20 namespace net { | 22 namespace net { |
21 class IOBuffer; | 23 class IOBuffer; |
22 } | 24 } |
23 | 25 |
24 namespace extensions { | 26 namespace extensions { |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 // AsyncApiFunction: | 159 // AsyncApiFunction: |
158 virtual bool Prepare() OVERRIDE; | 160 virtual bool Prepare() OVERRIDE; |
159 virtual void Work() OVERRIDE; | 161 virtual void Work() OVERRIDE; |
160 | 162 |
161 private: | 163 private: |
162 int socket_id_; | 164 int socket_id_; |
163 std::string address_; | 165 std::string address_; |
164 int port_; | 166 int port_; |
165 }; | 167 }; |
166 | 168 |
| 169 class SocketListenFunction : public SocketAsyncApiFunction { |
| 170 public: |
| 171 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.listen"); |
| 172 |
| 173 SocketListenFunction(); |
| 174 |
| 175 protected: |
| 176 virtual ~SocketListenFunction(); |
| 177 |
| 178 // AsyncApiFunction: |
| 179 virtual bool Prepare() OVERRIDE; |
| 180 virtual void Work() OVERRIDE; |
| 181 |
| 182 private: |
| 183 scoped_ptr<api::experimental_socket::Listen::Params> params_; |
| 184 }; |
| 185 |
| 186 class SocketAcceptFunction : public SocketAsyncApiFunction { |
| 187 public: |
| 188 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.accept"); |
| 189 |
| 190 SocketAcceptFunction(); |
| 191 |
| 192 protected: |
| 193 virtual ~SocketAcceptFunction(); |
| 194 |
| 195 // AsyncApiFunction: |
| 196 virtual bool Prepare() OVERRIDE; |
| 197 virtual void AsyncWorkStart() OVERRIDE; |
| 198 |
| 199 private: |
| 200 void OnAccept(int result_code, net::TCPClientSocket *socket); |
| 201 scoped_ptr<api::experimental_socket::Accept::Params> params_; |
| 202 }; |
| 203 |
167 class SocketReadFunction : public SocketAsyncApiFunction { | 204 class SocketReadFunction : public SocketAsyncApiFunction { |
168 public: | 205 public: |
169 DECLARE_EXTENSION_FUNCTION_NAME("socket.read") | 206 DECLARE_EXTENSION_FUNCTION_NAME("socket.read") |
170 | 207 |
171 SocketReadFunction(); | 208 SocketReadFunction(); |
172 | 209 |
173 protected: | 210 protected: |
174 virtual ~SocketReadFunction(); | 211 virtual ~SocketReadFunction(); |
175 | 212 |
176 // AsyncApiFunction: | 213 // AsyncApiFunction: |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 | 349 |
313 private: | 350 private: |
314 void GetNetworkListOnFileThread(); | 351 void GetNetworkListOnFileThread(); |
315 void HandleGetNetworkListError(); | 352 void HandleGetNetworkListError(); |
316 void SendResponseOnUIThread(const net::NetworkInterfaceList& interface_list); | 353 void SendResponseOnUIThread(const net::NetworkInterfaceList& interface_list); |
317 }; | 354 }; |
318 | 355 |
319 } // namespace extensions | 356 } // namespace extensions |
320 | 357 |
321 #endif // CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_API_H_ | 358 #endif // CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_API_H_ |
OLD | NEW |