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 <string> | 8 #include <string> |
9 | 9 |
10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 ~SocketCreateFunction() override; | 169 ~SocketCreateFunction() 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 private: | 175 private: |
176 FRIEND_TEST_ALL_PREFIXES(SocketUnitTest, Create); | 176 FRIEND_TEST_ALL_PREFIXES(SocketUnitTest, Create); |
177 enum SocketType { kSocketTypeInvalid = -1, kSocketTypeTCP, kSocketTypeUDP }; | 177 enum SocketType { kSocketTypeInvalid = -1, kSocketTypeTCP, kSocketTypeUDP }; |
178 | 178 |
179 scoped_ptr<core_api::socket::Create::Params> params_; | 179 scoped_ptr<api::socket::Create::Params> params_; |
180 SocketType socket_type_; | 180 SocketType socket_type_; |
181 }; | 181 }; |
182 | 182 |
183 class SocketDestroyFunction : public SocketAsyncApiFunction { | 183 class SocketDestroyFunction : public SocketAsyncApiFunction { |
184 public: | 184 public: |
185 DECLARE_EXTENSION_FUNCTION("socket.destroy", SOCKET_DESTROY) | 185 DECLARE_EXTENSION_FUNCTION("socket.destroy", SOCKET_DESTROY) |
186 | 186 |
187 protected: | 187 protected: |
188 ~SocketDestroyFunction() override {} | 188 ~SocketDestroyFunction() override {} |
189 | 189 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 SocketListenFunction(); | 259 SocketListenFunction(); |
260 | 260 |
261 protected: | 261 protected: |
262 ~SocketListenFunction() override; | 262 ~SocketListenFunction() override; |
263 | 263 |
264 // AsyncApiFunction: | 264 // AsyncApiFunction: |
265 bool Prepare() override; | 265 bool Prepare() override; |
266 void AsyncWorkStart() override; | 266 void AsyncWorkStart() override; |
267 | 267 |
268 private: | 268 private: |
269 scoped_ptr<core_api::socket::Listen::Params> params_; | 269 scoped_ptr<api::socket::Listen::Params> params_; |
270 }; | 270 }; |
271 | 271 |
272 class SocketAcceptFunction : public SocketAsyncApiFunction { | 272 class SocketAcceptFunction : public SocketAsyncApiFunction { |
273 public: | 273 public: |
274 DECLARE_EXTENSION_FUNCTION("socket.accept", SOCKET_ACCEPT) | 274 DECLARE_EXTENSION_FUNCTION("socket.accept", SOCKET_ACCEPT) |
275 | 275 |
276 SocketAcceptFunction(); | 276 SocketAcceptFunction(); |
277 | 277 |
278 protected: | 278 protected: |
279 ~SocketAcceptFunction() override; | 279 ~SocketAcceptFunction() override; |
280 | 280 |
281 // AsyncApiFunction: | 281 // AsyncApiFunction: |
282 bool Prepare() override; | 282 bool Prepare() override; |
283 void AsyncWorkStart() override; | 283 void AsyncWorkStart() override; |
284 | 284 |
285 private: | 285 private: |
286 void OnAccept(int result_code, net::TCPClientSocket* socket); | 286 void OnAccept(int result_code, net::TCPClientSocket* socket); |
287 | 287 |
288 scoped_ptr<core_api::socket::Accept::Params> params_; | 288 scoped_ptr<api::socket::Accept::Params> params_; |
289 }; | 289 }; |
290 | 290 |
291 class SocketReadFunction : public SocketAsyncApiFunction { | 291 class SocketReadFunction : public SocketAsyncApiFunction { |
292 public: | 292 public: |
293 DECLARE_EXTENSION_FUNCTION("socket.read", SOCKET_READ) | 293 DECLARE_EXTENSION_FUNCTION("socket.read", SOCKET_READ) |
294 | 294 |
295 SocketReadFunction(); | 295 SocketReadFunction(); |
296 | 296 |
297 protected: | 297 protected: |
298 ~SocketReadFunction() override; | 298 ~SocketReadFunction() override; |
299 | 299 |
300 // AsyncApiFunction: | 300 // AsyncApiFunction: |
301 bool Prepare() override; | 301 bool Prepare() override; |
302 void AsyncWorkStart() override; | 302 void AsyncWorkStart() override; |
303 void OnCompleted(int result, scoped_refptr<net::IOBuffer> io_buffer); | 303 void OnCompleted(int result, scoped_refptr<net::IOBuffer> io_buffer); |
304 | 304 |
305 private: | 305 private: |
306 scoped_ptr<core_api::socket::Read::Params> params_; | 306 scoped_ptr<api::socket::Read::Params> params_; |
307 }; | 307 }; |
308 | 308 |
309 class SocketWriteFunction : public SocketAsyncApiFunction { | 309 class SocketWriteFunction : public SocketAsyncApiFunction { |
310 public: | 310 public: |
311 DECLARE_EXTENSION_FUNCTION("socket.write", SOCKET_WRITE) | 311 DECLARE_EXTENSION_FUNCTION("socket.write", SOCKET_WRITE) |
312 | 312 |
313 SocketWriteFunction(); | 313 SocketWriteFunction(); |
314 | 314 |
315 protected: | 315 protected: |
316 ~SocketWriteFunction() override; | 316 ~SocketWriteFunction() override; |
(...skipping 20 matching lines...) Expand all Loading... |
337 | 337 |
338 // AsyncApiFunction | 338 // AsyncApiFunction |
339 bool Prepare() override; | 339 bool Prepare() override; |
340 void AsyncWorkStart() override; | 340 void AsyncWorkStart() override; |
341 void OnCompleted(int result, | 341 void OnCompleted(int result, |
342 scoped_refptr<net::IOBuffer> io_buffer, | 342 scoped_refptr<net::IOBuffer> io_buffer, |
343 const std::string& address, | 343 const std::string& address, |
344 uint16 port); | 344 uint16 port); |
345 | 345 |
346 private: | 346 private: |
347 scoped_ptr<core_api::socket::RecvFrom::Params> params_; | 347 scoped_ptr<api::socket::RecvFrom::Params> params_; |
348 }; | 348 }; |
349 | 349 |
350 class SocketSendToFunction : public SocketExtensionWithDnsLookupFunction { | 350 class SocketSendToFunction : public SocketExtensionWithDnsLookupFunction { |
351 public: | 351 public: |
352 DECLARE_EXTENSION_FUNCTION("socket.sendTo", SOCKET_SENDTO) | 352 DECLARE_EXTENSION_FUNCTION("socket.sendTo", SOCKET_SENDTO) |
353 | 353 |
354 SocketSendToFunction(); | 354 SocketSendToFunction(); |
355 | 355 |
356 protected: | 356 protected: |
357 ~SocketSendToFunction() override; | 357 ~SocketSendToFunction() override; |
(...skipping 23 matching lines...) Expand all Loading... |
381 SocketSetKeepAliveFunction(); | 381 SocketSetKeepAliveFunction(); |
382 | 382 |
383 protected: | 383 protected: |
384 ~SocketSetKeepAliveFunction() override; | 384 ~SocketSetKeepAliveFunction() override; |
385 | 385 |
386 // AsyncApiFunction: | 386 // AsyncApiFunction: |
387 bool Prepare() override; | 387 bool Prepare() override; |
388 void Work() override; | 388 void Work() override; |
389 | 389 |
390 private: | 390 private: |
391 scoped_ptr<core_api::socket::SetKeepAlive::Params> params_; | 391 scoped_ptr<api::socket::SetKeepAlive::Params> params_; |
392 }; | 392 }; |
393 | 393 |
394 class SocketSetNoDelayFunction : public SocketAsyncApiFunction { | 394 class SocketSetNoDelayFunction : public SocketAsyncApiFunction { |
395 public: | 395 public: |
396 DECLARE_EXTENSION_FUNCTION("socket.setNoDelay", SOCKET_SETNODELAY) | 396 DECLARE_EXTENSION_FUNCTION("socket.setNoDelay", SOCKET_SETNODELAY) |
397 | 397 |
398 SocketSetNoDelayFunction(); | 398 SocketSetNoDelayFunction(); |
399 | 399 |
400 protected: | 400 protected: |
401 ~SocketSetNoDelayFunction() override; | 401 ~SocketSetNoDelayFunction() override; |
402 | 402 |
403 // AsyncApiFunction: | 403 // AsyncApiFunction: |
404 bool Prepare() override; | 404 bool Prepare() override; |
405 void Work() override; | 405 void Work() override; |
406 | 406 |
407 private: | 407 private: |
408 scoped_ptr<core_api::socket::SetNoDelay::Params> params_; | 408 scoped_ptr<api::socket::SetNoDelay::Params> params_; |
409 }; | 409 }; |
410 | 410 |
411 class SocketGetInfoFunction : public SocketAsyncApiFunction { | 411 class SocketGetInfoFunction : public SocketAsyncApiFunction { |
412 public: | 412 public: |
413 DECLARE_EXTENSION_FUNCTION("socket.getInfo", SOCKET_GETINFO) | 413 DECLARE_EXTENSION_FUNCTION("socket.getInfo", SOCKET_GETINFO) |
414 | 414 |
415 SocketGetInfoFunction(); | 415 SocketGetInfoFunction(); |
416 | 416 |
417 protected: | 417 protected: |
418 ~SocketGetInfoFunction() override; | 418 ~SocketGetInfoFunction() override; |
419 | 419 |
420 // AsyncApiFunction: | 420 // AsyncApiFunction: |
421 bool Prepare() override; | 421 bool Prepare() override; |
422 void Work() override; | 422 void Work() override; |
423 | 423 |
424 private: | 424 private: |
425 scoped_ptr<core_api::socket::GetInfo::Params> params_; | 425 scoped_ptr<api::socket::GetInfo::Params> params_; |
426 }; | 426 }; |
427 | 427 |
428 class SocketGetNetworkListFunction : public AsyncExtensionFunction { | 428 class SocketGetNetworkListFunction : public AsyncExtensionFunction { |
429 public: | 429 public: |
430 DECLARE_EXTENSION_FUNCTION("socket.getNetworkList", SOCKET_GETNETWORKLIST) | 430 DECLARE_EXTENSION_FUNCTION("socket.getNetworkList", SOCKET_GETNETWORKLIST) |
431 | 431 |
432 protected: | 432 protected: |
433 ~SocketGetNetworkListFunction() override {} | 433 ~SocketGetNetworkListFunction() override {} |
434 bool RunAsync() override; | 434 bool RunAsync() override; |
435 | 435 |
(...skipping 10 matching lines...) Expand all Loading... |
446 SocketJoinGroupFunction(); | 446 SocketJoinGroupFunction(); |
447 | 447 |
448 protected: | 448 protected: |
449 ~SocketJoinGroupFunction() override; | 449 ~SocketJoinGroupFunction() override; |
450 | 450 |
451 // AsyncApiFunction | 451 // AsyncApiFunction |
452 bool Prepare() override; | 452 bool Prepare() override; |
453 void Work() override; | 453 void Work() override; |
454 | 454 |
455 private: | 455 private: |
456 scoped_ptr<core_api::socket::JoinGroup::Params> params_; | 456 scoped_ptr<api::socket::JoinGroup::Params> params_; |
457 }; | 457 }; |
458 | 458 |
459 class SocketLeaveGroupFunction : public SocketAsyncApiFunction { | 459 class SocketLeaveGroupFunction : public SocketAsyncApiFunction { |
460 public: | 460 public: |
461 DECLARE_EXTENSION_FUNCTION("socket.leaveGroup", SOCKET_MULTICAST_LEAVE_GROUP) | 461 DECLARE_EXTENSION_FUNCTION("socket.leaveGroup", SOCKET_MULTICAST_LEAVE_GROUP) |
462 | 462 |
463 SocketLeaveGroupFunction(); | 463 SocketLeaveGroupFunction(); |
464 | 464 |
465 protected: | 465 protected: |
466 ~SocketLeaveGroupFunction() override; | 466 ~SocketLeaveGroupFunction() override; |
467 | 467 |
468 // AsyncApiFunction | 468 // AsyncApiFunction |
469 bool Prepare() override; | 469 bool Prepare() override; |
470 void Work() override; | 470 void Work() override; |
471 | 471 |
472 private: | 472 private: |
473 scoped_ptr<core_api::socket::LeaveGroup::Params> params_; | 473 scoped_ptr<api::socket::LeaveGroup::Params> params_; |
474 }; | 474 }; |
475 | 475 |
476 class SocketSetMulticastTimeToLiveFunction : public SocketAsyncApiFunction { | 476 class SocketSetMulticastTimeToLiveFunction : public SocketAsyncApiFunction { |
477 public: | 477 public: |
478 DECLARE_EXTENSION_FUNCTION("socket.setMulticastTimeToLive", | 478 DECLARE_EXTENSION_FUNCTION("socket.setMulticastTimeToLive", |
479 SOCKET_MULTICAST_SET_TIME_TO_LIVE) | 479 SOCKET_MULTICAST_SET_TIME_TO_LIVE) |
480 | 480 |
481 SocketSetMulticastTimeToLiveFunction(); | 481 SocketSetMulticastTimeToLiveFunction(); |
482 | 482 |
483 protected: | 483 protected: |
484 ~SocketSetMulticastTimeToLiveFunction() override; | 484 ~SocketSetMulticastTimeToLiveFunction() override; |
485 | 485 |
486 // AsyncApiFunction | 486 // AsyncApiFunction |
487 bool Prepare() override; | 487 bool Prepare() override; |
488 void Work() override; | 488 void Work() override; |
489 | 489 |
490 private: | 490 private: |
491 scoped_ptr<core_api::socket::SetMulticastTimeToLive::Params> params_; | 491 scoped_ptr<api::socket::SetMulticastTimeToLive::Params> params_; |
492 }; | 492 }; |
493 | 493 |
494 class SocketSetMulticastLoopbackModeFunction : public SocketAsyncApiFunction { | 494 class SocketSetMulticastLoopbackModeFunction : public SocketAsyncApiFunction { |
495 public: | 495 public: |
496 DECLARE_EXTENSION_FUNCTION("socket.setMulticastLoopbackMode", | 496 DECLARE_EXTENSION_FUNCTION("socket.setMulticastLoopbackMode", |
497 SOCKET_MULTICAST_SET_LOOPBACK_MODE) | 497 SOCKET_MULTICAST_SET_LOOPBACK_MODE) |
498 | 498 |
499 SocketSetMulticastLoopbackModeFunction(); | 499 SocketSetMulticastLoopbackModeFunction(); |
500 | 500 |
501 protected: | 501 protected: |
502 ~SocketSetMulticastLoopbackModeFunction() override; | 502 ~SocketSetMulticastLoopbackModeFunction() override; |
503 | 503 |
504 // AsyncApiFunction | 504 // AsyncApiFunction |
505 bool Prepare() override; | 505 bool Prepare() override; |
506 void Work() override; | 506 void Work() override; |
507 | 507 |
508 private: | 508 private: |
509 scoped_ptr<core_api::socket::SetMulticastLoopbackMode::Params> params_; | 509 scoped_ptr<api::socket::SetMulticastLoopbackMode::Params> params_; |
510 }; | 510 }; |
511 | 511 |
512 class SocketGetJoinedGroupsFunction : public SocketAsyncApiFunction { | 512 class SocketGetJoinedGroupsFunction : public SocketAsyncApiFunction { |
513 public: | 513 public: |
514 DECLARE_EXTENSION_FUNCTION("socket.getJoinedGroups", | 514 DECLARE_EXTENSION_FUNCTION("socket.getJoinedGroups", |
515 SOCKET_MULTICAST_GET_JOINED_GROUPS) | 515 SOCKET_MULTICAST_GET_JOINED_GROUPS) |
516 | 516 |
517 SocketGetJoinedGroupsFunction(); | 517 SocketGetJoinedGroupsFunction(); |
518 | 518 |
519 protected: | 519 protected: |
520 ~SocketGetJoinedGroupsFunction() override; | 520 ~SocketGetJoinedGroupsFunction() override; |
521 | 521 |
522 // AsyncApiFunction | 522 // AsyncApiFunction |
523 bool Prepare() override; | 523 bool Prepare() override; |
524 void Work() override; | 524 void Work() override; |
525 | 525 |
526 private: | 526 private: |
527 scoped_ptr<core_api::socket::GetJoinedGroups::Params> params_; | 527 scoped_ptr<api::socket::GetJoinedGroups::Params> params_; |
528 }; | 528 }; |
529 | 529 |
530 class SocketSecureFunction : public SocketAsyncApiFunction { | 530 class SocketSecureFunction : public SocketAsyncApiFunction { |
531 public: | 531 public: |
532 DECLARE_EXTENSION_FUNCTION("socket.secure", SOCKET_SECURE); | 532 DECLARE_EXTENSION_FUNCTION("socket.secure", SOCKET_SECURE); |
533 SocketSecureFunction(); | 533 SocketSecureFunction(); |
534 | 534 |
535 protected: | 535 protected: |
536 ~SocketSecureFunction() override; | 536 ~SocketSecureFunction() override; |
537 | 537 |
538 // AsyncApiFunction | 538 // AsyncApiFunction |
539 bool Prepare() override; | 539 bool Prepare() override; |
540 void AsyncWorkStart() override; | 540 void AsyncWorkStart() override; |
541 | 541 |
542 private: | 542 private: |
543 // Callback from TLSSocket::UpgradeSocketToTLS(). | 543 // Callback from TLSSocket::UpgradeSocketToTLS(). |
544 void TlsConnectDone(scoped_ptr<TLSSocket> socket, int result); | 544 void TlsConnectDone(scoped_ptr<TLSSocket> socket, int result); |
545 | 545 |
546 scoped_ptr<core_api::socket::Secure::Params> params_; | 546 scoped_ptr<api::socket::Secure::Params> params_; |
547 scoped_refptr<net::URLRequestContextGetter> url_request_getter_; | 547 scoped_refptr<net::URLRequestContextGetter> url_request_getter_; |
548 | 548 |
549 DISALLOW_COPY_AND_ASSIGN(SocketSecureFunction); | 549 DISALLOW_COPY_AND_ASSIGN(SocketSecureFunction); |
550 }; | 550 }; |
551 | 551 |
552 } // namespace extensions | 552 } // namespace extensions |
553 | 553 |
554 #endif // EXTENSIONS_BROWSER_API_SOCKET_SOCKET_API_H_ | 554 #endif // EXTENSIONS_BROWSER_API_SOCKET_SOCKET_API_H_ |
OLD | NEW |