| 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/socket/socket_api.h" | 5 #include "extensions/browser/api/socket/socket_api.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/containers/hash_tables.h" | 11 #include "base/containers/hash_tables.h" |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "content/public/browser/browser_context.h" | 13 #include "content/public/browser/browser_context.h" |
| 14 #include "content/public/browser/resource_context.h" | 14 #include "content/public/browser/resource_context.h" |
| 15 #include "content/public/browser/storage_partition.h" | |
| 16 #include "extensions/browser/api/dns/host_resolver_wrapper.h" | 15 #include "extensions/browser/api/dns/host_resolver_wrapper.h" |
| 17 #include "extensions/browser/api/socket/socket.h" | 16 #include "extensions/browser/api/socket/socket.h" |
| 18 #include "extensions/browser/api/socket/tcp_socket.h" | 17 #include "extensions/browser/api/socket/tcp_socket.h" |
| 19 #include "extensions/browser/api/socket/tls_socket.h" | 18 #include "extensions/browser/api/socket/tls_socket.h" |
| 20 #include "extensions/browser/api/socket/udp_socket.h" | 19 #include "extensions/browser/api/socket/udp_socket.h" |
| 21 #include "extensions/browser/extension_system.h" | 20 #include "extensions/browser/extension_system.h" |
| 22 #include "extensions/common/extension.h" | 21 #include "extensions/common/extension.h" |
| 23 #include "extensions/common/permissions/permissions_data.h" | 22 #include "extensions/common/permissions/permissions_data.h" |
| 24 #include "extensions/common/permissions/socket_permission.h" | 23 #include "extensions/common/permissions/socket_permission.h" |
| 25 #include "net/base/host_port_pair.h" | 24 #include "net/base/host_port_pair.h" |
| (...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1004 SocketSecureFunction::SocketSecureFunction() { | 1003 SocketSecureFunction::SocketSecureFunction() { |
| 1005 } | 1004 } |
| 1006 | 1005 |
| 1007 SocketSecureFunction::~SocketSecureFunction() { | 1006 SocketSecureFunction::~SocketSecureFunction() { |
| 1008 } | 1007 } |
| 1009 | 1008 |
| 1010 bool SocketSecureFunction::Prepare() { | 1009 bool SocketSecureFunction::Prepare() { |
| 1011 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1010 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1012 params_ = api::socket::Secure::Params::Create(*args_); | 1011 params_ = api::socket::Secure::Params::Create(*args_); |
| 1013 EXTENSION_FUNCTION_VALIDATE(params_.get()); | 1012 EXTENSION_FUNCTION_VALIDATE(params_.get()); |
| 1014 url_request_getter_ = content::BrowserContext::GetDefaultStoragePartition( | 1013 url_request_getter_ = browser_context()->GetRequestContext(); |
| 1015 browser_context())->GetURLRequestContext(); | |
| 1016 return true; | 1014 return true; |
| 1017 } | 1015 } |
| 1018 | 1016 |
| 1019 // Override the regular implementation, which would call AsyncWorkCompleted | 1017 // Override the regular implementation, which would call AsyncWorkCompleted |
| 1020 // immediately after Work(). | 1018 // immediately after Work(). |
| 1021 void SocketSecureFunction::AsyncWorkStart() { | 1019 void SocketSecureFunction::AsyncWorkStart() { |
| 1022 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 1020 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 1023 | 1021 |
| 1024 Socket* socket = GetSocket(params_->socket_id); | 1022 Socket* socket = GetSocket(params_->socket_id); |
| 1025 if (!socket) { | 1023 if (!socket) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1068 } else { | 1066 } else { |
| 1069 RemoveSocket(params_->socket_id); | 1067 RemoveSocket(params_->socket_id); |
| 1070 error_ = net::ErrorToString(result); | 1068 error_ = net::ErrorToString(result); |
| 1071 } | 1069 } |
| 1072 | 1070 |
| 1073 results_ = api::socket::Secure::Results::Create(result); | 1071 results_ = api::socket::Secure::Results::Create(result); |
| 1074 AsyncWorkCompleted(); | 1072 AsyncWorkCompleted(); |
| 1075 } | 1073 } |
| 1076 | 1074 |
| 1077 } // namespace extensions | 1075 } // namespace extensions |
| OLD | NEW |