Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove pre network service classes from shell/browser/net #19644

Merged
merged 5 commits into from
Aug 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 2 additions & 14 deletions filenames.gni
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,6 @@ filenames = {
"shell/browser/common_web_contents_delegate.h",
"shell/browser/cookie_change_notifier.cc",
"shell/browser/cookie_change_notifier.h",
"shell/browser/io_thread.cc",
"shell/browser/io_thread.h",
"shell/browser/javascript_environment.cc",
"shell/browser/javascript_environment.h",
"shell/browser/lib/bluetooth_chooser.cc",
Expand Down Expand Up @@ -215,28 +213,18 @@ filenames = {
"shell/browser/media/media_stream_devices_controller.h",
"shell/browser/net/asar/asar_url_loader.cc",
"shell/browser/net/asar/asar_url_loader.h",
"shell/browser/net/asar/url_request_asar_job.cc",
"shell/browser/net/asar/url_request_asar_job.h",
"shell/browser/net/atom_cert_verifier.cc",
"shell/browser/net/atom_cert_verifier.h",
"shell/browser/net/atom_network_delegate.cc",
"shell/browser/net/atom_network_delegate.h",
"shell/browser/net/atom_url_loader_factory.cc",
"shell/browser/net/atom_url_loader_factory.h",
"shell/browser/net/atom_url_request_job_factory.cc",
"shell/browser/net/atom_url_request_job_factory.h",
"shell/browser/net/cert_verifier_client.cc",
"shell/browser/net/cert_verifier_client.h",
"shell/browser/net/proxying_url_loader_factory.cc",
"shell/browser/net/proxying_url_loader_factory.h",
"shell/browser/net/js_asker.cc",
"shell/browser/net/js_asker.h",
"shell/browser/net/network_context_service_factory.cc",
"shell/browser/net/network_context_service_factory.h",
"shell/browser/net/network_context_service.cc",
"shell/browser/net/network_context_service.h",
"shell/browser/net/node_stream_loader.cc",
"shell/browser/net/node_stream_loader.h",
"shell/browser/net/require_ct_delegate.cc",
"shell/browser/net/require_ct_delegate.h",
"shell/browser/net/resolve_proxy_helper.cc",
"shell/browser/net/resolve_proxy_helper.h",
"shell/browser/net/system_network_context_manager.cc",
Expand Down
1 change: 0 additions & 1 deletion patches/chromium/.patches
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ allow_nested_error_trackers.patch
blink_initialization_order.patch
ssl_security_state_tab_helper.patch
exclude-a-few-test-files-from-build.patch
expose-net-observer-api.patch
desktop_media_list.patch
proxy_config_monitor.patch
gritsettings_resource_ids.patch
Expand Down
29 changes: 0 additions & 29 deletions patches/chromium/expose-net-observer-api.patch

This file was deleted.

2 changes: 0 additions & 2 deletions shell/browser/api/atom_api_cookies.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
#include "net/cookies/canonical_cookie.h"
#include "net/cookies/cookie_store.h"
#include "net/cookies/cookie_util.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_getter.h"
#include "shell/browser/atom_browser_context.h"
#include "shell/browser/cookie_change_notifier.h"
#include "shell/common/native_mate_converters/callback.h"
Expand Down
2 changes: 0 additions & 2 deletions shell/browser/api/atom_api_net.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ void Initialize(v8::Local<v8::Object> exports,
dict.Set("net", Net::Create(isolate));
dict.Set("Net",
Net::GetConstructor(isolate)->GetFunction(context).ToLocalChecked());
dict.Set("isNetworkServiceEnabled",
base::FeatureList::IsEnabled(network::features::kNetworkService));
}

} // namespace
Expand Down
1 change: 0 additions & 1 deletion shell/browser/api/atom_api_net_log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "native_mate/converter.h"
#include "native_mate/dictionary.h"
#include "native_mate/handle.h"
#include "net/url_request/url_request_context_getter.h"
#include "shell/browser/atom_browser_context.h"
#include "shell/browser/net/system_network_context_manager.h"
#include "shell/common/native_mate_converters/callback.h"
Expand Down
74 changes: 8 additions & 66 deletions shell/browser/api/atom_api_session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@
#include "net/http/http_auth_handler_factory.h"
#include "net/http/http_auth_preferences.h"
#include "net/http/http_cache.h"
#include "net/http/http_transaction_factory.h"
#include "net/url_request/static_http_user_agent_settings.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_getter.h"
#include "services/network/network_service.h"
#include "services/network/public/cpp/features.h"
#include "shell/browser/api/atom_api_cookies.h"
Expand All @@ -52,8 +48,7 @@
#include "shell/browser/atom_permission_manager.h"
#include "shell/browser/browser.h"
#include "shell/browser/media/media_device_id_salt.h"
#include "shell/browser/net/atom_cert_verifier.h"
#include "shell/browser/net/system_network_context_manager.h"
#include "shell/browser/net/cert_verifier_client.h"
#include "shell/browser/session_preferences.h"
#include "shell/common/native_mate_converters/callback.h"
#include "shell/common/native_mate_converters/content_converter.h"
Expand Down Expand Up @@ -142,19 +137,6 @@ struct Converter<ClearStorageDataOptions> {
}
};

template <>
struct Converter<electron::VerifyRequestParams> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
electron::VerifyRequestParams val) {
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
dict.Set("hostname", val.hostname);
dict.Set("certificate", val.certificate);
dict.Set("verificationResult", val.default_result);
dict.Set("errorCode", val.error_code);
return dict.GetHandle();
}
};

} // namespace mate

namespace electron {
Expand Down Expand Up @@ -403,59 +385,17 @@ void Session::DisableNetworkEmulation() {
network_emulation_token_, network::mojom::NetworkConditions::New());
}

class ElectronCertVerifierClient : public network::mojom::CertVerifierClient {
public:
using CertVerifyProc =
base::RepeatingCallback<void(const VerifyRequestParams& request,
base::RepeatingCallback<void(int)>)>;
explicit ElectronCertVerifierClient(CertVerifyProc proc)
: cert_verify_proc_(proc) {}
~ElectronCertVerifierClient() override = default;

// network::mojom::CertVerifierClient
void Verify(int default_error,
const net::CertVerifyResult& default_result,
const scoped_refptr<net::X509Certificate>& certificate,
const std::string& hostname,
int flags,
const base::Optional<std::string>& ocsp_response,
VerifyCallback callback) override {
VerifyRequestParams params;
params.hostname = hostname;
params.default_result = net::ErrorToString(default_error);
params.error_code = default_error;
params.certificate = certificate;
cert_verify_proc_.Run(
params,
base::AdaptCallbackForRepeating(base::BindOnce(
[](VerifyCallback callback, const net::CertVerifyResult& result,
int err) { std::move(callback).Run(err, result); },
std::move(callback), default_result)));
}

private:
CertVerifyProc cert_verify_proc_;
};

void WrapVerifyProc(
base::RepeatingCallback<void(const VerifyRequestParams& request,
base::RepeatingCallback<void(int)>)> proc,
const VerifyRequestParams& request,
base::OnceCallback<void(int)> cb) {
proc.Run(request, base::AdaptCallbackForRepeating(std::move(cb)));
}

void Session::SetCertVerifyProc(v8::Local<v8::Value> val,
mate::Arguments* args) {
ElectronCertVerifierClient::CertVerifyProc proc;
CertVerifierClient::CertVerifyProc proc;
if (!(val->IsNull() || mate::ConvertFromV8(args->isolate(), val, &proc))) {
args->ThrowError("Must pass null or function");
return;
}

network::mojom::CertVerifierClientPtr cert_verifier_client;
if (proc) {
mojo::MakeStrongBinding(std::make_unique<ElectronCertVerifierClient>(proc),
mojo::MakeStrongBinding(std::make_unique<CertVerifierClient>(proc),
mojo::MakeRequest(&cert_verifier_client));
}
content::BrowserContext::GetDefaultStoragePartition(browser_context_.get())
Expand Down Expand Up @@ -534,9 +474,11 @@ v8::Local<v8::Promise> Session::ClearAuthCache() {
}

void Session::AllowNTLMCredentialsForDomains(const std::string& domains) {
auto auth_params = CreateHttpAuthDynamicParams();
auth_params->server_allowlist = domains;
content::GetNetworkService()->ConfigureHttpAuthPrefs(std::move(auth_params));
network::mojom::HttpAuthDynamicParamsPtr auth_dynamic_params =
network::mojom::HttpAuthDynamicParams::New();
auth_dynamic_params->server_allowlist = domains;
content::GetNetworkService()->ConfigureHttpAuthPrefs(
std::move(auth_dynamic_params));
}

void Session::SetUserAgent(const std::string& user_agent,
Expand Down
2 changes: 0 additions & 2 deletions shell/browser/api/atom_api_web_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
#include "native_mate/converter.h"
#include "native_mate/dictionary.h"
#include "native_mate/object_template_builder.h"
#include "net/url_request/url_request_context.h"
#include "shell/browser/api/atom_api_browser_window.h"
#include "shell/browser/api/atom_api_debugger.h"
#include "shell/browser/api/atom_api_session.h"
Expand All @@ -60,7 +59,6 @@
#include "shell/browser/child_web_contents_tracker.h"
#include "shell/browser/lib/bluetooth_chooser.h"
#include "shell/browser/native_window.h"
#include "shell/browser/net/atom_network_delegate.h"
#include "shell/browser/session_preferences.h"
#include "shell/browser/ui/drag_util.h"
#include "shell/browser/ui/inspectable_web_contents.h"
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/atom_browser_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@
#include "shell/browser/atom_speech_recognition_manager_delegate.h"
#include "shell/browser/child_web_contents_tracker.h"
#include "shell/browser/font_defaults.h"
#include "shell/browser/io_thread.h"
#include "shell/browser/media/media_capture_devices_dispatcher.h"
#include "shell/browser/native_window.h"
#include "shell/browser/net/network_context_service.h"
#include "shell/browser/net/network_context_service_factory.h"
#include "shell/browser/net/proxying_url_loader_factory.h"
#include "shell/browser/net/system_network_context_manager.h"
#include "shell/browser/notifications/notification_presenter.h"
#include "shell/browser/notifications/platform_notification_service.h"
#include "shell/browser/session_preferences.h"
Expand Down
8 changes: 0 additions & 8 deletions shell/browser/browser_process_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,6 @@ void BrowserProcessImpl::PreCreateThreads() {
// this can be created on first use.
if (!SystemNetworkContextManager::GetInstance())
SystemNetworkContextManager::CreateInstance(local_state_.get());

// Manage global state of net and other IO thread related.
io_thread_ =
std::make_unique<IOThread>(SystemNetworkContextManager::GetInstance());
}

void BrowserProcessImpl::PostDestroyThreads() {
io_thread_.reset();
}

void BrowserProcessImpl::PostMainMessageLoopRun() {
Expand Down
6 changes: 1 addition & 5 deletions shell/browser/browser_process_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include "components/prefs/value_map_pref_store.h"
#include "printing/buildflags/buildflags.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "shell/browser/io_thread.h"
#include "shell/browser/net/system_network_context_manager.h"

namespace printing {
Expand All @@ -41,7 +40,7 @@ class BrowserProcessImpl : public BrowserProcess {

void PostEarlyInitialization();
void PreCreateThreads();
void PostDestroyThreads();
void PostDestroyThreads() {}
void PostMainMessageLoopRun();

void EndSession() override {}
Expand Down Expand Up @@ -106,14 +105,11 @@ class BrowserProcessImpl : public BrowserProcess {
printing::PrintJobManager* print_job_manager() override;
StartupData* startup_data() override;

IOThread* io_thread() const { return io_thread_.get(); }

private:
#if BUILDFLAG(ENABLE_PRINTING)
std::unique_ptr<printing::PrintJobManager> print_job_manager_;
#endif
std::unique_ptr<PrefService> local_state_;
std::unique_ptr<IOThread> io_thread_;
std::string locale_;

DISALLOW_COPY_AND_ASSIGN(BrowserProcessImpl);
Expand Down
42 changes: 0 additions & 42 deletions shell/browser/io_thread.cc

This file was deleted.