From 1719f073c1c97c5b421194f9bf710509f4d464d5 Mon Sep 17 00:00:00 2001 From: Jeremy Rose Date: Mon, 13 Jul 2020 09:36:20 -0700 Subject: [PATCH] chore: remove some unused code in the net module (#24488) --- filenames.gni | 1 - lib/browser/api/net.ts | 12 +++------ shell/browser/api/electron_api_net.cc | 31 ------------------------ shell/browser/api/electron_api_net.h | 35 --------------------------- 4 files changed, 3 insertions(+), 76 deletions(-) delete mode 100644 shell/browser/api/electron_api_net.h diff --git a/filenames.gni b/filenames.gni index eb9c8da0121c..b9d729923b87 100644 --- a/filenames.gni +++ b/filenames.gni @@ -81,7 +81,6 @@ filenames = { "shell/browser/api/electron_api_native_theme.h", "shell/browser/api/electron_api_native_theme_mac.mm", "shell/browser/api/electron_api_net.cc", - "shell/browser/api/electron_api_net.h", "shell/browser/api/electron_api_net_log.cc", "shell/browser/api/electron_api_net_log.h", "shell/browser/api/electron_api_notification.cc", diff --git a/lib/browser/api/net.ts b/lib/browser/api/net.ts index 71ad1d6cdbab..6bbc177a44da 100644 --- a/lib/browser/api/net.ts +++ b/lib/browser/api/net.ts @@ -3,8 +3,6 @@ import { Readable, Writable } from 'stream'; import { app } from 'electron'; import { ClientRequestConstructorOptions, UploadProgress } from 'electron/main'; const { - net, - Net, isValidHeaderName, isValidHeaderValue, createURLLoader @@ -272,7 +270,7 @@ function parseOptions (optionsIn: ClientRequestConstructorOptions | string): Nod return urlLoaderOptions; } -class ClientRequest extends Writable implements Electron.ClientRequest { +export class ClientRequest extends Writable implements Electron.ClientRequest { _started: boolean = false; _firstWrite: boolean = false; _aborted: boolean = false; @@ -495,10 +493,6 @@ class ClientRequest extends Writable implements Electron.ClientRequest { } } -Net.prototype.request = function (options: ClientRequestConstructorOptions | string, callback?: (message: IncomingMessage) => void) { +export function request (options: ClientRequestConstructorOptions | string, callback?: (message: IncomingMessage) => void) { return new ClientRequest(options, callback); -}; - -net.ClientRequest = ClientRequest; - -module.exports = net; +} diff --git a/shell/browser/api/electron_api_net.cc b/shell/browser/api/electron_api_net.cc index 4382ebe3c4ff..bc335667be63 100644 --- a/shell/browser/api/electron_api_net.cc +++ b/shell/browser/api/electron_api_net.cc @@ -2,8 +2,6 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. -#include "shell/browser/api/electron_api_net.h" - #include #include "gin/handle.h" @@ -14,31 +12,6 @@ #include "shell/common/node_includes.h" -namespace electron { - -namespace api { - -Net::Net(v8::Isolate* isolate) { - Init(isolate); -} - -Net::~Net() = default; - -// static -v8::Local Net::Create(v8::Isolate* isolate) { - return gin::CreateHandle(isolate, new Net(isolate)).ToV8(); -} - -// static -void Net::BuildPrototype(v8::Isolate* isolate, - v8::Local prototype) { - prototype->SetClassName(gin::StringToV8(isolate, "Net")); -} - -} // namespace api - -} // namespace electron - namespace { bool IsValidHeaderName(std::string header_name) { @@ -49,7 +22,6 @@ bool IsValidHeaderValue(std::string header_value) { return net::HttpUtil::IsValidHeaderValue(header_value); } -using electron::api::Net; using electron::api::SimpleURLLoaderWrapper; void Initialize(v8::Local exports, @@ -59,9 +31,6 @@ void Initialize(v8::Local exports, v8::Isolate* isolate = context->GetIsolate(); gin_helper::Dictionary dict(isolate, exports); - dict.Set("net", Net::Create(isolate)); - dict.Set("Net", - Net::GetConstructor(isolate)->GetFunction(context).ToLocalChecked()); dict.SetMethod("isValidHeaderName", &IsValidHeaderName); dict.SetMethod("isValidHeaderValue", &IsValidHeaderValue); dict.SetMethod("createURLLoader", &SimpleURLLoaderWrapper::Create); diff --git a/shell/browser/api/electron_api_net.h b/shell/browser/api/electron_api_net.h deleted file mode 100644 index 82e09eb8f901..000000000000 --- a/shell/browser/api/electron_api_net.h +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) 2016 GitHub, Inc. -// Use of this source code is governed by the MIT license that can be -// found in the LICENSE file. - -#ifndef SHELL_BROWSER_API_ELECTRON_API_NET_H_ -#define SHELL_BROWSER_API_ELECTRON_API_NET_H_ - -#include "shell/common/gin_helper/wrappable.h" - -namespace electron { - -namespace api { - -class Net : public gin_helper::Wrappable { - public: - static v8::Local Create(v8::Isolate* isolate); - - static void BuildPrototype(v8::Isolate* isolate, - v8::Local prototype); - - v8::Local URLLoader(v8::Isolate* isolate); - - protected: - explicit Net(v8::Isolate* isolate); - ~Net() override; - - private: - DISALLOW_COPY_AND_ASSIGN(Net); -}; - -} // namespace api - -} // namespace electron - -#endif // SHELL_BROWSER_API_ELECTRON_API_NET_H_