Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Side by Side Diff: extensions/browser/api/socket/socket_api.cc

Issue 1864583006: Simplify BrowserContext by removing redundant methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
15 #include "extensions/browser/api/dns/host_resolver_wrapper.h" 16 #include "extensions/browser/api/dns/host_resolver_wrapper.h"
16 #include "extensions/browser/api/socket/socket.h" 17 #include "extensions/browser/api/socket/socket.h"
17 #include "extensions/browser/api/socket/tcp_socket.h" 18 #include "extensions/browser/api/socket/tcp_socket.h"
18 #include "extensions/browser/api/socket/tls_socket.h" 19 #include "extensions/browser/api/socket/tls_socket.h"
19 #include "extensions/browser/api/socket/udp_socket.h" 20 #include "extensions/browser/api/socket/udp_socket.h"
20 #include "extensions/browser/extension_system.h" 21 #include "extensions/browser/extension_system.h"
21 #include "extensions/common/extension.h" 22 #include "extensions/common/extension.h"
22 #include "extensions/common/permissions/permissions_data.h" 23 #include "extensions/common/permissions/permissions_data.h"
23 #include "extensions/common/permissions/socket_permission.h" 24 #include "extensions/common/permissions/socket_permission.h"
24 #include "net/base/host_port_pair.h" 25 #include "net/base/host_port_pair.h"
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 SocketSecureFunction::SocketSecureFunction() { 1004 SocketSecureFunction::SocketSecureFunction() {
1004 } 1005 }
1005 1006
1006 SocketSecureFunction::~SocketSecureFunction() { 1007 SocketSecureFunction::~SocketSecureFunction() {
1007 } 1008 }
1008 1009
1009 bool SocketSecureFunction::Prepare() { 1010 bool SocketSecureFunction::Prepare() {
1010 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1011 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1011 params_ = api::socket::Secure::Params::Create(*args_); 1012 params_ = api::socket::Secure::Params::Create(*args_);
1012 EXTENSION_FUNCTION_VALIDATE(params_.get()); 1013 EXTENSION_FUNCTION_VALIDATE(params_.get());
1013 url_request_getter_ = browser_context()->GetRequestContext(); 1014 url_request_getter_ = content::BrowserContext::GetDefaultStoragePartition(
1015 browser_context())->GetURLRequestContext();
1014 return true; 1016 return true;
1015 } 1017 }
1016 1018
1017 // Override the regular implementation, which would call AsyncWorkCompleted 1019 // Override the regular implementation, which would call AsyncWorkCompleted
1018 // immediately after Work(). 1020 // immediately after Work().
1019 void SocketSecureFunction::AsyncWorkStart() { 1021 void SocketSecureFunction::AsyncWorkStart() {
1020 DCHECK_CURRENTLY_ON(BrowserThread::IO); 1022 DCHECK_CURRENTLY_ON(BrowserThread::IO);
1021 1023
1022 Socket* socket = GetSocket(params_->socket_id); 1024 Socket* socket = GetSocket(params_->socket_id);
1023 if (!socket) { 1025 if (!socket) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1066 } else { 1068 } else {
1067 RemoveSocket(params_->socket_id); 1069 RemoveSocket(params_->socket_id);
1068 error_ = net::ErrorToString(result); 1070 error_ = net::ErrorToString(result);
1069 } 1071 }
1070 1072
1071 results_ = api::socket::Secure::Results::Create(result); 1073 results_ = api::socket::Secure::Results::Create(result);
1072 AsyncWorkCompleted(); 1074 AsyncWorkCompleted();
1073 } 1075 }
1074 1076
1075 } // namespace extensions 1077 } // namespace extensions
OLDNEW
« no previous file with comments | « content/shell/browser/shell_devtools_frontend.cc ('k') | extensions/browser/api/sockets_tcp/sockets_tcp_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698