| 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/browser/storage_partition.h" |
| 8 #include "content/public/common/socket_permission_request.h" | 9 #include "content/public/common/socket_permission_request.h" |
| 9 #include "extensions/browser/api/socket/tcp_socket.h" | 10 #include "extensions/browser/api/socket/tcp_socket.h" |
| 10 #include "extensions/browser/api/socket/tls_socket.h" | 11 #include "extensions/browser/api/socket/tls_socket.h" |
| 11 #include "extensions/browser/api/sockets_tcp/tcp_socket_event_dispatcher.h" | 12 #include "extensions/browser/api/sockets_tcp/tcp_socket_event_dispatcher.h" |
| 12 #include "extensions/common/api/sockets/sockets_manifest_data.h" | 13 #include "extensions/common/api/sockets/sockets_manifest_data.h" |
| 13 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
| 14 #include "net/url_request/url_request_context.h" | 15 #include "net/url_request/url_request_context.h" |
| 15 #include "net/url_request/url_request_context_getter.h" | 16 #include "net/url_request/url_request_context_getter.h" |
| 16 | 17 |
| 17 using extensions::ResumableTCPSocket; | 18 using extensions::ResumableTCPSocket; |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 SocketsTcpSecureFunction::SocketsTcpSecureFunction() { | 449 SocketsTcpSecureFunction::SocketsTcpSecureFunction() { |
| 449 } | 450 } |
| 450 | 451 |
| 451 SocketsTcpSecureFunction::~SocketsTcpSecureFunction() { | 452 SocketsTcpSecureFunction::~SocketsTcpSecureFunction() { |
| 452 } | 453 } |
| 453 | 454 |
| 454 bool SocketsTcpSecureFunction::Prepare() { | 455 bool SocketsTcpSecureFunction::Prepare() { |
| 455 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 456 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 456 params_ = api::sockets_tcp::Secure::Params::Create(*args_); | 457 params_ = api::sockets_tcp::Secure::Params::Create(*args_); |
| 457 EXTENSION_FUNCTION_VALIDATE(params_.get()); | 458 EXTENSION_FUNCTION_VALIDATE(params_.get()); |
| 458 url_request_getter_ = browser_context()->GetRequestContext(); | 459 url_request_getter_ = content::BrowserContext::GetDefaultStoragePartition( |
| 460 browser_context())->GetURLRequestContext(); |
| 459 return true; | 461 return true; |
| 460 } | 462 } |
| 461 | 463 |
| 462 // Override the regular implementation, which would call AsyncWorkCompleted | 464 // Override the regular implementation, which would call AsyncWorkCompleted |
| 463 // immediately after Work(). | 465 // immediately after Work(). |
| 464 void SocketsTcpSecureFunction::AsyncWorkStart() { | 466 void SocketsTcpSecureFunction::AsyncWorkStart() { |
| 465 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 467 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 466 | 468 |
| 467 ResumableTCPSocket* socket = GetTcpSocket(params_->socket_id); | 469 ResumableTCPSocket* socket = GetTcpSocket(params_->socket_id); |
| 468 if (!socket) { | 470 if (!socket) { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 RemoveSocket(params_->socket_id); | 535 RemoveSocket(params_->socket_id); |
| 534 error_ = net::ErrorToString(result); | 536 error_ = net::ErrorToString(result); |
| 535 } | 537 } |
| 536 | 538 |
| 537 results_ = api::sockets_tcp::Secure::Results::Create(result); | 539 results_ = api::sockets_tcp::Secure::Results::Create(result); |
| 538 AsyncWorkCompleted(); | 540 AsyncWorkCompleted(); |
| 539 } | 541 } |
| 540 | 542 |
| 541 } // namespace api | 543 } // namespace api |
| 542 } // namespace extensions | 544 } // namespace extensions |
| OLD | NEW |