| 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_SOCKET_SOCKET_API_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_SOCKET_SOCKET_API_H_ |
| 6 #define EXTENSIONS_BROWSER_API_SOCKET_SOCKET_API_H_ | 6 #define EXTENSIONS_BROWSER_API_SOCKET_SOCKET_API_H_ |
| 7 | 7 |
| 8 #include <stddef.h> |
| 9 #include <stdint.h> |
| 10 |
| 8 #include <string> | 11 #include <string> |
| 9 | 12 |
| 10 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
| 14 #include "base/macros.h" |
| 11 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 16 #include "build/build_config.h" |
| 12 #include "extensions/browser/api/api_resource_manager.h" | 17 #include "extensions/browser/api/api_resource_manager.h" |
| 13 #include "extensions/browser/api/async_api_function.h" | 18 #include "extensions/browser/api/async_api_function.h" |
| 14 #include "extensions/browser/extension_function.h" | 19 #include "extensions/browser/extension_function.h" |
| 15 #include "extensions/common/api/socket.h" | 20 #include "extensions/common/api/socket.h" |
| 16 #include "net/base/address_list.h" | 21 #include "net/base/address_list.h" |
| 17 #include "net/base/network_change_notifier.h" | 22 #include "net/base/network_change_notifier.h" |
| 18 #include "net/dns/host_resolver.h" | 23 #include "net/dns/host_resolver.h" |
| 19 #include "net/socket/tcp_client_socket.h" | 24 #include "net/socket/tcp_client_socket.h" |
| 20 | 25 |
| 21 #if defined(OS_CHROMEOS) | 26 #if defined(OS_CHROMEOS) |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 | 216 |
| 212 // SocketExtensionWithDnsLookupFunction: | 217 // SocketExtensionWithDnsLookupFunction: |
| 213 void AfterDnsLookup(int lookup_result) override; | 218 void AfterDnsLookup(int lookup_result) override; |
| 214 | 219 |
| 215 private: | 220 private: |
| 216 void StartConnect(); | 221 void StartConnect(); |
| 217 void OnConnect(int result); | 222 void OnConnect(int result); |
| 218 | 223 |
| 219 int socket_id_; | 224 int socket_id_; |
| 220 std::string hostname_; | 225 std::string hostname_; |
| 221 uint16 port_; | 226 uint16_t port_; |
| 222 }; | 227 }; |
| 223 | 228 |
| 224 class SocketDisconnectFunction : public SocketAsyncApiFunction { | 229 class SocketDisconnectFunction : public SocketAsyncApiFunction { |
| 225 public: | 230 public: |
| 226 DECLARE_EXTENSION_FUNCTION("socket.disconnect", SOCKET_DISCONNECT) | 231 DECLARE_EXTENSION_FUNCTION("socket.disconnect", SOCKET_DISCONNECT) |
| 227 | 232 |
| 228 protected: | 233 protected: |
| 229 ~SocketDisconnectFunction() override {} | 234 ~SocketDisconnectFunction() override {} |
| 230 | 235 |
| 231 // AsyncApiFunction: | 236 // AsyncApiFunction: |
| (...skipping 11 matching lines...) Expand all Loading... |
| 243 protected: | 248 protected: |
| 244 ~SocketBindFunction() override {} | 249 ~SocketBindFunction() override {} |
| 245 | 250 |
| 246 // AsyncApiFunction: | 251 // AsyncApiFunction: |
| 247 bool Prepare() override; | 252 bool Prepare() override; |
| 248 void AsyncWorkStart() override; | 253 void AsyncWorkStart() override; |
| 249 | 254 |
| 250 private: | 255 private: |
| 251 int socket_id_; | 256 int socket_id_; |
| 252 std::string address_; | 257 std::string address_; |
| 253 uint16 port_; | 258 uint16_t port_; |
| 254 }; | 259 }; |
| 255 | 260 |
| 256 class SocketListenFunction : public SocketAsyncApiFunction { | 261 class SocketListenFunction : public SocketAsyncApiFunction { |
| 257 public: | 262 public: |
| 258 DECLARE_EXTENSION_FUNCTION("socket.listen", SOCKET_LISTEN) | 263 DECLARE_EXTENSION_FUNCTION("socket.listen", SOCKET_LISTEN) |
| 259 | 264 |
| 260 SocketListenFunction(); | 265 SocketListenFunction(); |
| 261 | 266 |
| 262 protected: | 267 protected: |
| 263 ~SocketListenFunction() override; | 268 ~SocketListenFunction() override; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 | 340 |
| 336 protected: | 341 protected: |
| 337 ~SocketRecvFromFunction() override; | 342 ~SocketRecvFromFunction() override; |
| 338 | 343 |
| 339 // AsyncApiFunction | 344 // AsyncApiFunction |
| 340 bool Prepare() override; | 345 bool Prepare() override; |
| 341 void AsyncWorkStart() override; | 346 void AsyncWorkStart() override; |
| 342 void OnCompleted(int result, | 347 void OnCompleted(int result, |
| 343 scoped_refptr<net::IOBuffer> io_buffer, | 348 scoped_refptr<net::IOBuffer> io_buffer, |
| 344 const std::string& address, | 349 const std::string& address, |
| 345 uint16 port); | 350 uint16_t port); |
| 346 | 351 |
| 347 private: | 352 private: |
| 348 scoped_ptr<api::socket::RecvFrom::Params> params_; | 353 scoped_ptr<api::socket::RecvFrom::Params> params_; |
| 349 }; | 354 }; |
| 350 | 355 |
| 351 class SocketSendToFunction : public SocketExtensionWithDnsLookupFunction { | 356 class SocketSendToFunction : public SocketExtensionWithDnsLookupFunction { |
| 352 public: | 357 public: |
| 353 DECLARE_EXTENSION_FUNCTION("socket.sendTo", SOCKET_SENDTO) | 358 DECLARE_EXTENSION_FUNCTION("socket.sendTo", SOCKET_SENDTO) |
| 354 | 359 |
| 355 SocketSendToFunction(); | 360 SocketSendToFunction(); |
| 356 | 361 |
| 357 protected: | 362 protected: |
| 358 ~SocketSendToFunction() override; | 363 ~SocketSendToFunction() override; |
| 359 | 364 |
| 360 // AsyncApiFunction: | 365 // AsyncApiFunction: |
| 361 bool Prepare() override; | 366 bool Prepare() override; |
| 362 void AsyncWorkStart() override; | 367 void AsyncWorkStart() override; |
| 363 void OnCompleted(int result); | 368 void OnCompleted(int result); |
| 364 | 369 |
| 365 // SocketExtensionWithDnsLookupFunction: | 370 // SocketExtensionWithDnsLookupFunction: |
| 366 void AfterDnsLookup(int lookup_result) override; | 371 void AfterDnsLookup(int lookup_result) override; |
| 367 | 372 |
| 368 private: | 373 private: |
| 369 void StartSendTo(); | 374 void StartSendTo(); |
| 370 | 375 |
| 371 int socket_id_; | 376 int socket_id_; |
| 372 scoped_refptr<net::IOBuffer> io_buffer_; | 377 scoped_refptr<net::IOBuffer> io_buffer_; |
| 373 size_t io_buffer_size_; | 378 size_t io_buffer_size_; |
| 374 std::string hostname_; | 379 std::string hostname_; |
| 375 uint16 port_; | 380 uint16_t port_; |
| 376 }; | 381 }; |
| 377 | 382 |
| 378 class SocketSetKeepAliveFunction : public SocketAsyncApiFunction { | 383 class SocketSetKeepAliveFunction : public SocketAsyncApiFunction { |
| 379 public: | 384 public: |
| 380 DECLARE_EXTENSION_FUNCTION("socket.setKeepAlive", SOCKET_SETKEEPALIVE) | 385 DECLARE_EXTENSION_FUNCTION("socket.setKeepAlive", SOCKET_SETKEEPALIVE) |
| 381 | 386 |
| 382 SocketSetKeepAliveFunction(); | 387 SocketSetKeepAliveFunction(); |
| 383 | 388 |
| 384 protected: | 389 protected: |
| 385 ~SocketSetKeepAliveFunction() override; | 390 ~SocketSetKeepAliveFunction() override; |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 | 551 |
| 547 scoped_ptr<api::socket::Secure::Params> params_; | 552 scoped_ptr<api::socket::Secure::Params> params_; |
| 548 scoped_refptr<net::URLRequestContextGetter> url_request_getter_; | 553 scoped_refptr<net::URLRequestContextGetter> url_request_getter_; |
| 549 | 554 |
| 550 DISALLOW_COPY_AND_ASSIGN(SocketSecureFunction); | 555 DISALLOW_COPY_AND_ASSIGN(SocketSecureFunction); |
| 551 }; | 556 }; |
| 552 | 557 |
| 553 } // namespace extensions | 558 } // namespace extensions |
| 554 | 559 |
| 555 #endif // EXTENSIONS_BROWSER_API_SOCKET_SOCKET_API_H_ | 560 #endif // EXTENSIONS_BROWSER_API_SOCKET_SOCKET_API_H_ |
| OLD | NEW |