chore: remove some unused code in the net module (#24488)
This commit is contained in:
parent
91cdedfea9
commit
1719f073c1
4 changed files with 3 additions and 76 deletions
|
@ -81,7 +81,6 @@ filenames = {
|
||||||
"shell/browser/api/electron_api_native_theme.h",
|
"shell/browser/api/electron_api_native_theme.h",
|
||||||
"shell/browser/api/electron_api_native_theme_mac.mm",
|
"shell/browser/api/electron_api_native_theme_mac.mm",
|
||||||
"shell/browser/api/electron_api_net.cc",
|
"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.cc",
|
||||||
"shell/browser/api/electron_api_net_log.h",
|
"shell/browser/api/electron_api_net_log.h",
|
||||||
"shell/browser/api/electron_api_notification.cc",
|
"shell/browser/api/electron_api_notification.cc",
|
||||||
|
|
|
@ -3,8 +3,6 @@ import { Readable, Writable } from 'stream';
|
||||||
import { app } from 'electron';
|
import { app } from 'electron';
|
||||||
import { ClientRequestConstructorOptions, UploadProgress } from 'electron/main';
|
import { ClientRequestConstructorOptions, UploadProgress } from 'electron/main';
|
||||||
const {
|
const {
|
||||||
net,
|
|
||||||
Net,
|
|
||||||
isValidHeaderName,
|
isValidHeaderName,
|
||||||
isValidHeaderValue,
|
isValidHeaderValue,
|
||||||
createURLLoader
|
createURLLoader
|
||||||
|
@ -272,7 +270,7 @@ function parseOptions (optionsIn: ClientRequestConstructorOptions | string): Nod
|
||||||
return urlLoaderOptions;
|
return urlLoaderOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ClientRequest extends Writable implements Electron.ClientRequest {
|
export class ClientRequest extends Writable implements Electron.ClientRequest {
|
||||||
_started: boolean = false;
|
_started: boolean = false;
|
||||||
_firstWrite: boolean = false;
|
_firstWrite: boolean = false;
|
||||||
_aborted: 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);
|
return new ClientRequest(options, callback);
|
||||||
};
|
}
|
||||||
|
|
||||||
net.ClientRequest = ClientRequest;
|
|
||||||
|
|
||||||
module.exports = net;
|
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
// Use of this source code is governed by the MIT license that can be
|
// Use of this source code is governed by the MIT license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#include "shell/browser/api/electron_api_net.h"
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "gin/handle.h"
|
#include "gin/handle.h"
|
||||||
|
@ -14,31 +12,6 @@
|
||||||
|
|
||||||
#include "shell/common/node_includes.h"
|
#include "shell/common/node_includes.h"
|
||||||
|
|
||||||
namespace electron {
|
|
||||||
|
|
||||||
namespace api {
|
|
||||||
|
|
||||||
Net::Net(v8::Isolate* isolate) {
|
|
||||||
Init(isolate);
|
|
||||||
}
|
|
||||||
|
|
||||||
Net::~Net() = default;
|
|
||||||
|
|
||||||
// static
|
|
||||||
v8::Local<v8::Value> Net::Create(v8::Isolate* isolate) {
|
|
||||||
return gin::CreateHandle(isolate, new Net(isolate)).ToV8();
|
|
||||||
}
|
|
||||||
|
|
||||||
// static
|
|
||||||
void Net::BuildPrototype(v8::Isolate* isolate,
|
|
||||||
v8::Local<v8::FunctionTemplate> prototype) {
|
|
||||||
prototype->SetClassName(gin::StringToV8(isolate, "Net"));
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace api
|
|
||||||
|
|
||||||
} // namespace electron
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
bool IsValidHeaderName(std::string header_name) {
|
bool IsValidHeaderName(std::string header_name) {
|
||||||
|
@ -49,7 +22,6 @@ bool IsValidHeaderValue(std::string header_value) {
|
||||||
return net::HttpUtil::IsValidHeaderValue(header_value);
|
return net::HttpUtil::IsValidHeaderValue(header_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
using electron::api::Net;
|
|
||||||
using electron::api::SimpleURLLoaderWrapper;
|
using electron::api::SimpleURLLoaderWrapper;
|
||||||
|
|
||||||
void Initialize(v8::Local<v8::Object> exports,
|
void Initialize(v8::Local<v8::Object> exports,
|
||||||
|
@ -59,9 +31,6 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||||
v8::Isolate* isolate = context->GetIsolate();
|
v8::Isolate* isolate = context->GetIsolate();
|
||||||
|
|
||||||
gin_helper::Dictionary dict(isolate, exports);
|
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("isValidHeaderName", &IsValidHeaderName);
|
||||||
dict.SetMethod("isValidHeaderValue", &IsValidHeaderValue);
|
dict.SetMethod("isValidHeaderValue", &IsValidHeaderValue);
|
||||||
dict.SetMethod("createURLLoader", &SimpleURLLoaderWrapper::Create);
|
dict.SetMethod("createURLLoader", &SimpleURLLoaderWrapper::Create);
|
||||||
|
|
|
@ -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<Net> {
|
|
||||||
public:
|
|
||||||
static v8::Local<v8::Value> Create(v8::Isolate* isolate);
|
|
||||||
|
|
||||||
static void BuildPrototype(v8::Isolate* isolate,
|
|
||||||
v8::Local<v8::FunctionTemplate> prototype);
|
|
||||||
|
|
||||||
v8::Local<v8::Value> 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_
|
|
Loading…
Reference in a new issue