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 #include "extensions/browser/api/sockets_tcp/sockets_tcp_api.h" | 5 #include "extensions/browser/api/sockets_tcp/sockets_tcp_api.h" |
6 | 6 |
7 #include "content/public/browser/browser_context.h" | 7 #include "content/public/browser/browser_context.h" |
8 #include "content/public/common/socket_permission_request.h" | 8 #include "content/public/common/socket_permission_request.h" |
9 #include "extensions/browser/api/socket/tcp_socket.h" | 9 #include "extensions/browser/api/socket/tcp_socket.h" |
10 #include "extensions/browser/api/socket/tls_socket.h" | 10 #include "extensions/browser/api/socket/tls_socket.h" |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 results_ = sockets_tcp::GetSockets::Results::Create(socket_infos); | 450 results_ = sockets_tcp::GetSockets::Results::Create(socket_infos); |
451 } | 451 } |
452 | 452 |
453 SocketsTcpSecureFunction::SocketsTcpSecureFunction() { | 453 SocketsTcpSecureFunction::SocketsTcpSecureFunction() { |
454 } | 454 } |
455 | 455 |
456 SocketsTcpSecureFunction::~SocketsTcpSecureFunction() { | 456 SocketsTcpSecureFunction::~SocketsTcpSecureFunction() { |
457 } | 457 } |
458 | 458 |
459 bool SocketsTcpSecureFunction::Prepare() { | 459 bool SocketsTcpSecureFunction::Prepare() { |
460 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 460 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
461 params_ = core_api::sockets_tcp::Secure::Params::Create(*args_); | 461 params_ = core_api::sockets_tcp::Secure::Params::Create(*args_); |
462 EXTENSION_FUNCTION_VALIDATE(params_.get()); | 462 EXTENSION_FUNCTION_VALIDATE(params_.get()); |
463 url_request_getter_ = browser_context()->GetRequestContext(); | 463 url_request_getter_ = browser_context()->GetRequestContext(); |
464 return true; | 464 return true; |
465 } | 465 } |
466 | 466 |
467 // Override the regular implementation, which would call AsyncWorkCompleted | 467 // Override the regular implementation, which would call AsyncWorkCompleted |
468 // immediately after Work(). | 468 // immediately after Work(). |
469 void SocketsTcpSecureFunction::AsyncWorkStart() { | 469 void SocketsTcpSecureFunction::AsyncWorkStart() { |
470 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 470 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
471 | 471 |
472 ResumableTCPSocket* socket = GetTcpSocket(params_->socket_id); | 472 ResumableTCPSocket* socket = GetTcpSocket(params_->socket_id); |
473 if (!socket) { | 473 if (!socket) { |
474 SetResult(new base::FundamentalValue(net::ERR_INVALID_ARGUMENT)); | 474 SetResult(new base::FundamentalValue(net::ERR_INVALID_ARGUMENT)); |
475 error_ = kSocketNotFoundError; | 475 error_ = kSocketNotFoundError; |
476 AsyncWorkCompleted(); | 476 AsyncWorkCompleted(); |
477 return; | 477 return; |
478 } | 478 } |
479 | 479 |
480 paused_ = socket->paused(); | 480 paused_ = socket->paused(); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 RemoveSocket(params_->socket_id); | 539 RemoveSocket(params_->socket_id); |
540 error_ = net::ErrorToString(result); | 540 error_ = net::ErrorToString(result); |
541 } | 541 } |
542 | 542 |
543 results_ = core_api::sockets_tcp::Secure::Results::Create(result); | 543 results_ = core_api::sockets_tcp::Secure::Results::Create(result); |
544 AsyncWorkCompleted(); | 544 AsyncWorkCompleted(); |
545 } | 545 } |
546 | 546 |
547 } // namespace api | 547 } // namespace api |
548 } // namespace extensions | 548 } // namespace extensions |
OLD | NEW |