* chore: remove _ns suffixes

* lint
This commit is contained in:
Jeremy Apthorp 2019-10-23 17:51:06 -07:00 коммит произвёл Cheng Zhao
Родитель cc278cea00
Коммит 77414813b4
11 изменённых файлов: 237 добавлений и 240 удалений

Просмотреть файл

@ -79,8 +79,8 @@ filenames = {
"shell/browser/api/atom_api_power_monitor.h",
"shell/browser/api/atom_api_power_save_blocker.cc",
"shell/browser/api/atom_api_power_save_blocker.h",
"shell/browser/api/atom_api_protocol_ns.cc",
"shell/browser/api/atom_api_protocol_ns.h",
"shell/browser/api/atom_api_protocol.cc",
"shell/browser/api/atom_api_protocol.h",
"shell/browser/api/atom_api_screen.cc",
"shell/browser/api/atom_api_screen.h",
"shell/browser/api/atom_api_session.cc",
@ -93,8 +93,8 @@ filenames = {
"shell/browser/api/atom_api_top_level_window.h",
"shell/browser/api/atom_api_tray.cc",
"shell/browser/api/atom_api_tray.h",
"shell/browser/api/atom_api_url_request_ns.cc",
"shell/browser/api/atom_api_url_request_ns.h",
"shell/browser/api/atom_api_url_request.cc",
"shell/browser/api/atom_api_url_request.h",
"shell/browser/api/atom_api_view.cc",
"shell/browser/api/atom_api_view.h",
"shell/browser/api/atom_api_web_contents.cc",
@ -103,8 +103,8 @@ filenames = {
"shell/browser/api/atom_api_web_contents_mac.mm",
"shell/browser/api/atom_api_web_contents_view.cc",
"shell/browser/api/atom_api_web_contents_view.h",
"shell/browser/api/atom_api_web_request_ns.cc",
"shell/browser/api/atom_api_web_request_ns.h",
"shell/browser/api/atom_api_web_request.cc",
"shell/browser/api/atom_api_web_request.h",
"shell/browser/api/atom_api_web_view_manager.cc",
"shell/browser/api/atom_api_browser_window.cc",
"shell/browser/api/atom_api_browser_window.h",

Просмотреть файл

@ -7,7 +7,7 @@
#include "native_mate/dictionary.h"
#include "native_mate/handle.h"
#include "services/network/public/cpp/features.h"
#include "shell/browser/api/atom_api_url_request_ns.h"
#include "shell/browser/api/atom_api_url_request.h"
#include "shell/common/node_includes.h"
@ -36,7 +36,7 @@ void Net::BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::Value> Net::URLRequest(v8::Isolate* isolate) {
v8::Local<v8::FunctionTemplate> constructor;
constructor = URLRequestNS::GetConstructor(isolate);
constructor = URLRequest::GetConstructor(isolate);
return constructor->GetFunction(isolate->GetCurrentContext())
.ToLocalChecked();
}
@ -48,7 +48,7 @@ v8::Local<v8::Value> Net::URLRequest(v8::Isolate* isolate) {
namespace {
using electron::api::Net;
using electron::api::URLRequestNS;
using electron::api::URLRequest;
void Initialize(v8::Local<v8::Object> exports,
v8::Local<v8::Value> unused,
@ -56,7 +56,7 @@ void Initialize(v8::Local<v8::Object> exports,
void* priv) {
v8::Isolate* isolate = context->GetIsolate();
URLRequestNS::SetConstructor(isolate, base::BindRepeating(URLRequestNS::New));
URLRequest::SetConstructor(isolate, base::BindRepeating(URLRequest::New));
mate::Dictionary dict(isolate, exports);
dict.Set("net", Net::Create(isolate));

Просмотреть файл

@ -2,7 +2,7 @@
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "shell/browser/api/atom_api_protocol_ns.h"
#include "shell/browser/api/atom_api_protocol.h"
#include <memory>
#include <utility>
@ -159,15 +159,14 @@ std::string ErrorCodeToString(ProtocolError error) {
} // namespace
ProtocolNS::ProtocolNS(v8::Isolate* isolate,
AtomBrowserContext* browser_context) {
Protocol::Protocol(v8::Isolate* isolate, AtomBrowserContext* browser_context) {
Init(isolate);
AttachAsUserData(browser_context);
}
ProtocolNS::~ProtocolNS() = default;
Protocol::~Protocol() = default;
void ProtocolNS::RegisterURLLoaderFactories(
void Protocol::RegisterURLLoaderFactories(
content::ContentBrowserClient::NonNetworkURLLoaderFactoryMap* factories) {
for (const auto& it : handlers_) {
factories->emplace(it.first, std::make_unique<AtomURLLoaderFactory>(
@ -175,47 +174,47 @@ void ProtocolNS::RegisterURLLoaderFactories(
}
}
ProtocolError ProtocolNS::RegisterProtocol(ProtocolType type,
const std::string& scheme,
const ProtocolHandler& handler) {
ProtocolError Protocol::RegisterProtocol(ProtocolType type,
const std::string& scheme,
const ProtocolHandler& handler) {
const bool added = base::TryEmplace(handlers_, scheme, type, handler).second;
return added ? ProtocolError::OK : ProtocolError::REGISTERED;
}
void ProtocolNS::UnregisterProtocol(const std::string& scheme,
gin::Arguments* args) {
void Protocol::UnregisterProtocol(const std::string& scheme,
gin::Arguments* args) {
const bool removed = handlers_.erase(scheme) != 0;
const auto error =
removed ? ProtocolError::OK : ProtocolError::NOT_REGISTERED;
HandleOptionalCallback(args, error);
}
bool ProtocolNS::IsProtocolRegistered(const std::string& scheme) {
bool Protocol::IsProtocolRegistered(const std::string& scheme) {
return base::Contains(handlers_, scheme);
}
ProtocolError ProtocolNS::InterceptProtocol(ProtocolType type,
const std::string& scheme,
const ProtocolHandler& handler) {
ProtocolError Protocol::InterceptProtocol(ProtocolType type,
const std::string& scheme,
const ProtocolHandler& handler) {
const bool added =
base::TryEmplace(intercept_handlers_, scheme, type, handler).second;
return added ? ProtocolError::OK : ProtocolError::INTERCEPTED;
}
void ProtocolNS::UninterceptProtocol(const std::string& scheme,
gin::Arguments* args) {
void Protocol::UninterceptProtocol(const std::string& scheme,
gin::Arguments* args) {
const bool removed = intercept_handlers_.erase(scheme) != 0;
const auto error =
removed ? ProtocolError::OK : ProtocolError::NOT_INTERCEPTED;
HandleOptionalCallback(args, error);
}
bool ProtocolNS::IsProtocolIntercepted(const std::string& scheme) {
bool Protocol::IsProtocolIntercepted(const std::string& scheme) {
return base::Contains(intercept_handlers_, scheme);
}
v8::Local<v8::Promise> ProtocolNS::IsProtocolHandled(const std::string& scheme,
gin::Arguments* args) {
v8::Local<v8::Promise> Protocol::IsProtocolHandled(const std::string& scheme,
gin::Arguments* args) {
node::Environment* env = node::Environment::GetCurrent(args->isolate());
EmitDeprecationWarning(
env,
@ -236,8 +235,8 @@ v8::Local<v8::Promise> ProtocolNS::IsProtocolHandled(const std::string& scheme,
base::Contains(kBuiltinSchemes, scheme));
}
void ProtocolNS::HandleOptionalCallback(gin::Arguments* args,
ProtocolError error) {
void Protocol::HandleOptionalCallback(gin::Arguments* args,
ProtocolError error) {
CompletionCallback callback;
if (args->GetNext(&callback)) {
node::Environment* env = node::Environment::GetCurrent(args->isolate());
@ -254,46 +253,45 @@ void ProtocolNS::HandleOptionalCallback(gin::Arguments* args,
}
// static
gin::Handle<ProtocolNS> ProtocolNS::Create(
v8::Isolate* isolate,
AtomBrowserContext* browser_context) {
return gin::CreateHandle(isolate, new ProtocolNS(isolate, browser_context));
gin::Handle<Protocol> Protocol::Create(v8::Isolate* isolate,
AtomBrowserContext* browser_context) {
return gin::CreateHandle(isolate, new Protocol(isolate, browser_context));
}
// static
void ProtocolNS::BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype) {
void Protocol::BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype) {
prototype->SetClassName(gin::StringToV8(isolate, "Protocol"));
gin_helper::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
.SetMethod("registerStringProtocol",
&ProtocolNS::RegisterProtocolFor<ProtocolType::kString>)
&Protocol::RegisterProtocolFor<ProtocolType::kString>)
.SetMethod("registerBufferProtocol",
&ProtocolNS::RegisterProtocolFor<ProtocolType::kBuffer>)
&Protocol::RegisterProtocolFor<ProtocolType::kBuffer>)
.SetMethod("registerFileProtocol",
&ProtocolNS::RegisterProtocolFor<ProtocolType::kFile>)
&Protocol::RegisterProtocolFor<ProtocolType::kFile>)
.SetMethod("registerHttpProtocol",
&ProtocolNS::RegisterProtocolFor<ProtocolType::kHttp>)
&Protocol::RegisterProtocolFor<ProtocolType::kHttp>)
.SetMethod("registerStreamProtocol",
&ProtocolNS::RegisterProtocolFor<ProtocolType::kStream>)
&Protocol::RegisterProtocolFor<ProtocolType::kStream>)
.SetMethod("registerProtocol",
&ProtocolNS::RegisterProtocolFor<ProtocolType::kFree>)
.SetMethod("unregisterProtocol", &ProtocolNS::UnregisterProtocol)
.SetMethod("isProtocolRegistered", &ProtocolNS::IsProtocolRegistered)
.SetMethod("isProtocolHandled", &ProtocolNS::IsProtocolHandled)
&Protocol::RegisterProtocolFor<ProtocolType::kFree>)
.SetMethod("unregisterProtocol", &Protocol::UnregisterProtocol)
.SetMethod("isProtocolRegistered", &Protocol::IsProtocolRegistered)
.SetMethod("isProtocolHandled", &Protocol::IsProtocolHandled)
.SetMethod("interceptStringProtocol",
&ProtocolNS::InterceptProtocolFor<ProtocolType::kString>)
&Protocol::InterceptProtocolFor<ProtocolType::kString>)
.SetMethod("interceptBufferProtocol",
&ProtocolNS::InterceptProtocolFor<ProtocolType::kBuffer>)
&Protocol::InterceptProtocolFor<ProtocolType::kBuffer>)
.SetMethod("interceptFileProtocol",
&ProtocolNS::InterceptProtocolFor<ProtocolType::kFile>)
&Protocol::InterceptProtocolFor<ProtocolType::kFile>)
.SetMethod("interceptHttpProtocol",
&ProtocolNS::InterceptProtocolFor<ProtocolType::kHttp>)
&Protocol::InterceptProtocolFor<ProtocolType::kHttp>)
.SetMethod("interceptStreamProtocol",
&ProtocolNS::InterceptProtocolFor<ProtocolType::kStream>)
&Protocol::InterceptProtocolFor<ProtocolType::kStream>)
.SetMethod("interceptProtocol",
&ProtocolNS::InterceptProtocolFor<ProtocolType::kFree>)
.SetMethod("uninterceptProtocol", &ProtocolNS::UninterceptProtocol)
.SetMethod("isProtocolIntercepted", &ProtocolNS::IsProtocolIntercepted);
&Protocol::InterceptProtocolFor<ProtocolType::kFree>)
.SetMethod("uninterceptProtocol", &Protocol::UninterceptProtocol)
.SetMethod("isProtocolIntercepted", &Protocol::IsProtocolIntercepted);
}
} // namespace api

Просмотреть файл

@ -2,8 +2,8 @@
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef SHELL_BROWSER_API_ATOM_API_PROTOCOL_NS_H_
#define SHELL_BROWSER_API_ATOM_API_PROTOCOL_NS_H_
#ifndef SHELL_BROWSER_API_ATOM_API_PROTOCOL_H_
#define SHELL_BROWSER_API_ATOM_API_PROTOCOL_H_
#include <string>
#include <vector>
@ -35,10 +35,10 @@ enum class ProtocolError {
};
// Protocol implementation based on network services.
class ProtocolNS : public mate::TrackableObject<ProtocolNS> {
class Protocol : public mate::TrackableObject<Protocol> {
public:
static gin::Handle<ProtocolNS> Create(v8::Isolate* isolate,
AtomBrowserContext* browser_context);
static gin::Handle<Protocol> Create(v8::Isolate* isolate,
AtomBrowserContext* browser_context);
static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype);
@ -50,8 +50,8 @@ class ProtocolNS : public mate::TrackableObject<ProtocolNS> {
const HandlersMap& intercept_handlers() const { return intercept_handlers_; }
private:
ProtocolNS(v8::Isolate* isolate, AtomBrowserContext* browser_context);
~ProtocolNS() override;
Protocol(v8::Isolate* isolate, AtomBrowserContext* browser_context);
~Protocol() override;
// Callback types.
using CompletionCallback =
@ -99,4 +99,4 @@ class ProtocolNS : public mate::TrackableObject<ProtocolNS> {
} // namespace electron
#endif // SHELL_BROWSER_API_ATOM_API_PROTOCOL_NS_H_
#endif // SHELL_BROWSER_API_ATOM_API_PROTOCOL_H_

Просмотреть файл

@ -45,8 +45,8 @@
#include "shell/browser/api/atom_api_data_pipe_holder.h"
#include "shell/browser/api/atom_api_download_item.h"
#include "shell/browser/api/atom_api_net_log.h"
#include "shell/browser/api/atom_api_protocol_ns.h"
#include "shell/browser/api/atom_api_web_request_ns.h"
#include "shell/browser/api/atom_api_protocol.h"
#include "shell/browser/api/atom_api_web_request.h"
#include "shell/browser/atom_browser_context.h"
#include "shell/browser/atom_browser_main_parts.h"
#include "shell/browser/atom_permission_manager.h"
@ -588,7 +588,7 @@ v8::Local<v8::Value> Session::Cookies(v8::Isolate* isolate) {
v8::Local<v8::Value> Session::Protocol(v8::Isolate* isolate) {
if (protocol_.IsEmpty()) {
v8::Local<v8::Value> handle;
handle = ProtocolNS::Create(isolate, browser_context()).ToV8();
handle = Protocol::Create(isolate, browser_context()).ToV8();
protocol_.Reset(isolate, handle);
}
return v8::Local<v8::Value>::New(isolate, protocol_);
@ -596,7 +596,7 @@ v8::Local<v8::Value> Session::Protocol(v8::Isolate* isolate) {
v8::Local<v8::Value> Session::WebRequest(v8::Isolate* isolate) {
if (web_request_.IsEmpty()) {
auto handle = WebRequestNS::Create(isolate, browser_context());
auto handle = WebRequest::Create(isolate, browser_context());
web_request_.Reset(isolate, handle.ToV8());
}
return v8::Local<v8::Value>::New(isolate, web_request_);
@ -732,7 +732,7 @@ namespace {
using electron::api::Cookies;
using electron::api::NetLog;
using electron::api::ProtocolNS;
using electron::api::Protocol;
using electron::api::Session;
v8::Local<v8::Value> FromPartition(const std::string& partition,
@ -761,9 +761,9 @@ void Initialize(v8::Local<v8::Object> exports,
dict.Set(
"NetLog",
NetLog::GetConstructor(isolate)->GetFunction(context).ToLocalChecked());
dict.Set("Protocol", ProtocolNS::GetConstructor(isolate)
->GetFunction(context)
.ToLocalChecked());
dict.Set(
"Protocol",
Protocol::GetConstructor(isolate)->GetFunction(context).ToLocalChecked());
dict.SetMethod("fromPartition", &FromPartition);
}

Просмотреть файл

@ -2,7 +2,7 @@
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "shell/browser/api/atom_api_url_request_ns.h"
#include "shell/browser/api/atom_api_url_request.h"
#include <utility>
@ -84,7 +84,7 @@ const net::NetworkTrafficAnnotationTag kTrafficAnnotation =
// Common class for streaming data.
class UploadDataPipeGetter {
public:
explicit UploadDataPipeGetter(URLRequestNS* request) : request_(request) {}
explicit UploadDataPipeGetter(URLRequest* request) : request_(request) {}
virtual ~UploadDataPipeGetter() = default;
virtual void AttachToRequestBody(network::ResourceRequestBody* body) = 0;
@ -101,7 +101,7 @@ class UploadDataPipeGetter {
}
private:
URLRequestNS* request_;
URLRequest* request_;
DISALLOW_COPY_AND_ASSIGN(UploadDataPipeGetter);
};
@ -110,7 +110,7 @@ class UploadDataPipeGetter {
class MultipartDataPipeGetter : public UploadDataPipeGetter,
public network::mojom::DataPipeGetter {
public:
explicit MultipartDataPipeGetter(URLRequestNS* request)
explicit MultipartDataPipeGetter(URLRequest* request)
: UploadDataPipeGetter(request) {}
~MultipartDataPipeGetter() override = default;
@ -141,7 +141,7 @@ class MultipartDataPipeGetter : public UploadDataPipeGetter,
class ChunkedDataPipeGetter : public UploadDataPipeGetter,
public network::mojom::ChunkedDataPipeGetter {
public:
explicit ChunkedDataPipeGetter(URLRequestNS* request)
explicit ChunkedDataPipeGetter(URLRequest* request)
: UploadDataPipeGetter(request) {}
~ChunkedDataPipeGetter() override = default;
@ -166,7 +166,7 @@ class ChunkedDataPipeGetter : public UploadDataPipeGetter,
mojo::ReceiverSet<network::mojom::ChunkedDataPipeGetter> receiver_set_;
};
URLRequestNS::URLRequestNS(gin::Arguments* args) : weak_factory_(this) {
URLRequest::URLRequest(gin::Arguments* args) : weak_factory_(this) {
request_ = std::make_unique<network::ResourceRequest>();
gin_helper::Dictionary dict;
if (args->GetNext(&dict)) {
@ -190,17 +190,17 @@ URLRequestNS::URLRequestNS(gin::Arguments* args) : weak_factory_(this) {
InitWithArgs(args);
}
URLRequestNS::~URLRequestNS() = default;
URLRequest::~URLRequest() = default;
bool URLRequestNS::NotStarted() const {
bool URLRequest::NotStarted() const {
return request_state_ == 0;
}
bool URLRequestNS::Finished() const {
bool URLRequest::Finished() const {
return request_state_ & STATE_FINISHED;
}
void URLRequestNS::Cancel() {
void URLRequest::Cancel() {
// Cancel only once.
if (request_state_ & (STATE_CANCELED | STATE_CLOSED))
return;
@ -215,7 +215,7 @@ void URLRequestNS::Cancel() {
Close();
}
void URLRequestNS::Close() {
void URLRequest::Close() {
if (!(request_state_ & STATE_CLOSED)) {
request_state_ |= STATE_CLOSED;
if (response_state_ & STATE_STARTED) {
@ -228,7 +228,7 @@ void URLRequestNS::Close() {
loader_.reset();
}
bool URLRequestNS::Write(v8::Local<v8::Value> data, bool is_last) {
bool URLRequest::Write(v8::Local<v8::Value> data, bool is_last) {
if (request_state_ & (STATE_FINISHED | STATE_ERROR))
return false;
@ -243,12 +243,12 @@ bool URLRequestNS::Write(v8::Local<v8::Value> data, bool is_last) {
network::ResourceRequest* request_ref = request_.get();
loader_ = network::SimpleURLLoader::Create(std::move(request_),
kTrafficAnnotation);
loader_->SetOnResponseStartedCallback(base::Bind(
&URLRequestNS::OnResponseStarted, weak_factory_.GetWeakPtr()));
loader_->SetOnResponseStartedCallback(
base::Bind(&URLRequest::OnResponseStarted, weak_factory_.GetWeakPtr()));
loader_->SetOnRedirectCallback(
base::Bind(&URLRequestNS::OnRedirect, weak_factory_.GetWeakPtr()));
loader_->SetOnUploadProgressCallback(base::Bind(
&URLRequestNS::OnUploadProgress, weak_factory_.GetWeakPtr()));
base::Bind(&URLRequest::OnRedirect, weak_factory_.GetWeakPtr()));
loader_->SetOnUploadProgressCallback(
base::Bind(&URLRequest::OnUploadProgress, weak_factory_.GetWeakPtr()));
// Create upload data pipe if we have data to write.
if (length > 0) {
@ -286,14 +286,14 @@ bool URLRequestNS::Write(v8::Local<v8::Value> data, bool is_last) {
return true;
}
void URLRequestNS::FollowRedirect() {
void URLRequest::FollowRedirect() {
if (request_state_ & (STATE_CANCELED | STATE_CLOSED))
return;
follow_redirect_ = true;
}
bool URLRequestNS::SetExtraHeader(const std::string& name,
const std::string& value) {
bool URLRequest::SetExtraHeader(const std::string& name,
const std::string& value) {
if (!request_)
return false;
if (!net::HttpUtil::IsValidHeaderName(name))
@ -304,17 +304,17 @@ bool URLRequestNS::SetExtraHeader(const std::string& name,
return true;
}
void URLRequestNS::RemoveExtraHeader(const std::string& name) {
void URLRequest::RemoveExtraHeader(const std::string& name) {
if (request_)
request_->headers.RemoveHeader(name);
}
void URLRequestNS::SetChunkedUpload(bool is_chunked_upload) {
void URLRequest::SetChunkedUpload(bool is_chunked_upload) {
if (request_)
is_chunked_upload_ = is_chunked_upload;
}
gin::Dictionary URLRequestNS::GetUploadProgress() {
gin::Dictionary URLRequest::GetUploadProgress() {
gin::Dictionary progress = gin::Dictionary::CreateEmpty(isolate());
if (loader_) {
if (request_)
@ -330,36 +330,36 @@ gin::Dictionary URLRequestNS::GetUploadProgress() {
return progress;
}
int URLRequestNS::StatusCode() const {
int URLRequest::StatusCode() const {
if (response_headers_)
return response_headers_->response_code();
return -1;
}
std::string URLRequestNS::StatusMessage() const {
std::string URLRequest::StatusMessage() const {
if (response_headers_)
return response_headers_->GetStatusText();
return "";
}
net::HttpResponseHeaders* URLRequestNS::RawResponseHeaders() const {
net::HttpResponseHeaders* URLRequest::RawResponseHeaders() const {
return response_headers_.get();
}
uint32_t URLRequestNS::ResponseHttpVersionMajor() const {
uint32_t URLRequest::ResponseHttpVersionMajor() const {
if (response_headers_)
return response_headers_->GetHttpVersion().major_value();
return 0;
}
uint32_t URLRequestNS::ResponseHttpVersionMinor() const {
uint32_t URLRequest::ResponseHttpVersionMinor() const {
if (response_headers_)
return response_headers_->GetHttpVersion().minor_value();
return 0;
}
void URLRequestNS::OnDataReceived(base::StringPiece data,
base::OnceClosure resume) {
void URLRequest::OnDataReceived(base::StringPiece data,
base::OnceClosure resume) {
// In case we received an unexpected event from Chromium net, don't emit any
// data event after request cancel/error/close.
if (!(request_state_ & STATE_ERROR) && !(response_state_ & STATE_ERROR)) {
@ -372,9 +372,9 @@ void URLRequestNS::OnDataReceived(base::StringPiece data,
std::move(resume).Run();
}
void URLRequestNS::OnRetry(base::OnceClosure start_retry) {}
void URLRequest::OnRetry(base::OnceClosure start_retry) {}
void URLRequestNS::OnComplete(bool success) {
void URLRequest::OnComplete(bool success) {
if (success) {
// In case we received an unexpected event from Chromium net, don't emit any
// data event after request cancel/error/close.
@ -400,7 +400,7 @@ void URLRequestNS::OnComplete(bool success) {
Close();
}
void URLRequestNS::OnResponseStarted(
void URLRequest::OnResponseStarted(
const GURL& final_url,
const network::mojom::URLResponseHead& response_head) {
// Don't emit any event after request cancel.
@ -412,7 +412,7 @@ void URLRequestNS::OnResponseStarted(
Emit("response");
}
void URLRequestNS::OnRedirect(
void URLRequest::OnRedirect(
const net::RedirectInfo& redirect_info,
const network::mojom::URLResponseHead& response_head,
std::vector<std::string>* to_be_removed_headers) {
@ -455,12 +455,12 @@ void URLRequestNS::OnRedirect(
}
}
void URLRequestNS::OnUploadProgress(uint64_t position, uint64_t total) {
void URLRequest::OnUploadProgress(uint64_t position, uint64_t total) {
upload_position_ = position;
upload_total_ = total;
}
void URLRequestNS::OnWrite(MojoResult result) {
void URLRequest::OnWrite(MojoResult result) {
if (result != MOJO_RESULT_OK)
return;
@ -470,17 +470,17 @@ void URLRequestNS::OnWrite(MojoResult result) {
DoWrite();
}
void URLRequestNS::DoWrite() {
void URLRequest::DoWrite() {
DCHECK(producer_);
DCHECK(!pending_writes_.empty());
producer_->Write(
std::make_unique<mojo::StringDataSource>(
pending_writes_.front(), mojo::StringDataSource::AsyncWritingMode::
STRING_STAYS_VALID_UNTIL_COMPLETION),
base::BindOnce(&URLRequestNS::OnWrite, weak_factory_.GetWeakPtr()));
base::BindOnce(&URLRequest::OnWrite, weak_factory_.GetWeakPtr()));
}
void URLRequestNS::StartWriting() {
void URLRequest::StartWriting() {
if (!last_chunk_written_ || size_callback_.is_null())
return;
@ -491,17 +491,17 @@ void URLRequestNS::StartWriting() {
DoWrite();
}
void URLRequestNS::Pin() {
void URLRequest::Pin() {
if (wrapper_.IsEmpty()) {
wrapper_.Reset(isolate(), GetWrapper());
}
}
void URLRequestNS::Unpin() {
void URLRequest::Unpin() {
wrapper_.Reset();
}
void URLRequestNS::EmitError(EventType type, base::StringPiece message) {
void URLRequest::EmitError(EventType type, base::StringPiece message) {
if (type == EventType::kRequest)
request_state_ |= STATE_FAILED;
else
@ -512,7 +512,7 @@ void URLRequestNS::EmitError(EventType type, base::StringPiece message) {
}
template <typename... Args>
void URLRequestNS::EmitEvent(EventType type, Args... args) {
void URLRequest::EmitEvent(EventType type, Args... args) {
const char* method =
type == EventType::kRequest ? "_emitRequestEvent" : "_emitResponseEvent";
v8::HandleScope handle_scope(isolate());
@ -520,30 +520,30 @@ void URLRequestNS::EmitEvent(EventType type, Args... args) {
}
// static
mate::WrappableBase* URLRequestNS::New(gin::Arguments* args) {
return new URLRequestNS(args);
mate::WrappableBase* URLRequest::New(gin::Arguments* args) {
return new URLRequest(args);
}
// static
void URLRequestNS::BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype) {
void URLRequest::BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype) {
prototype->SetClassName(gin::StringToV8(isolate, "URLRequest"));
gin_helper::Destroyable::MakeDestroyable(isolate, prototype);
gin_helper::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
.SetMethod("write", &URLRequestNS::Write)
.SetMethod("cancel", &URLRequestNS::Cancel)
.SetMethod("setExtraHeader", &URLRequestNS::SetExtraHeader)
.SetMethod("removeExtraHeader", &URLRequestNS::RemoveExtraHeader)
.SetMethod("setChunkedUpload", &URLRequestNS::SetChunkedUpload)
.SetMethod("followRedirect", &URLRequestNS::FollowRedirect)
.SetMethod("getUploadProgress", &URLRequestNS::GetUploadProgress)
.SetProperty("notStarted", &URLRequestNS::NotStarted)
.SetProperty("finished", &URLRequestNS::Finished)
.SetProperty("statusCode", &URLRequestNS::StatusCode)
.SetProperty("statusMessage", &URLRequestNS::StatusMessage)
.SetProperty("rawResponseHeaders", &URLRequestNS::RawResponseHeaders)
.SetProperty("httpVersionMajor", &URLRequestNS::ResponseHttpVersionMajor)
.SetProperty("httpVersionMinor", &URLRequestNS::ResponseHttpVersionMinor);
.SetMethod("write", &URLRequest::Write)
.SetMethod("cancel", &URLRequest::Cancel)
.SetMethod("setExtraHeader", &URLRequest::SetExtraHeader)
.SetMethod("removeExtraHeader", &URLRequest::RemoveExtraHeader)
.SetMethod("setChunkedUpload", &URLRequest::SetChunkedUpload)
.SetMethod("followRedirect", &URLRequest::FollowRedirect)
.SetMethod("getUploadProgress", &URLRequest::GetUploadProgress)
.SetProperty("notStarted", &URLRequest::NotStarted)
.SetProperty("finished", &URLRequest::Finished)
.SetProperty("statusCode", &URLRequest::StatusCode)
.SetProperty("statusMessage", &URLRequest::StatusMessage)
.SetProperty("rawResponseHeaders", &URLRequest::RawResponseHeaders)
.SetProperty("httpVersionMajor", &URLRequest::ResponseHttpVersionMajor)
.SetProperty("httpVersionMinor", &URLRequest::ResponseHttpVersionMinor);
}
} // namespace api

Просмотреть файл

@ -2,8 +2,8 @@
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef SHELL_BROWSER_API_ATOM_API_URL_REQUEST_NS_H_
#define SHELL_BROWSER_API_ATOM_API_URL_REQUEST_NS_H_
#ifndef SHELL_BROWSER_API_ATOM_API_URL_REQUEST_H_
#define SHELL_BROWSER_API_ATOM_API_URL_REQUEST_H_
#include <list>
#include <memory>
@ -25,8 +25,8 @@ namespace api {
class UploadDataPipeGetter;
class URLRequestNS : public mate::EventEmitter<URLRequestNS>,
public network::SimpleURLLoaderStreamConsumer {
class URLRequest : public mate::EventEmitter<URLRequest>,
public network::SimpleURLLoaderStreamConsumer {
public:
static mate::WrappableBase* New(gin::Arguments* args);
@ -34,8 +34,8 @@ class URLRequestNS : public mate::EventEmitter<URLRequestNS>,
v8::Local<v8::FunctionTemplate> prototype);
protected:
explicit URLRequestNS(gin::Arguments* args);
~URLRequestNS() override;
explicit URLRequest(gin::Arguments* args);
~URLRequest() override;
bool NotStarted() const;
bool Finished() const;
@ -132,13 +132,13 @@ class URLRequestNS : public mate::EventEmitter<URLRequestNS>,
// Used by pin/unpin to manage lifetime.
v8::Global<v8::Object> wrapper_;
base::WeakPtrFactory<URLRequestNS> weak_factory_;
base::WeakPtrFactory<URLRequest> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(URLRequestNS);
DISALLOW_COPY_AND_ASSIGN(URLRequest);
};
} // namespace api
} // namespace electron
#endif // SHELL_BROWSER_API_ATOM_API_URL_REQUEST_NS_H_
#endif // SHELL_BROWSER_API_ATOM_API_URL_REQUEST_H_

Просмотреть файл

@ -2,7 +2,7 @@
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "shell/browser/api/atom_api_web_request_ns.h"
#include "shell/browser/api/atom_api_web_request.h"
#include <memory>
#include <string>
@ -79,12 +79,12 @@ namespace api {
namespace {
const char* kUserDataKey = "WebRequestNS";
const char* kUserDataKey = "WebRequest";
// BrowserContext <=> WebRequestNS relationship.
// BrowserContext <=> WebRequest relationship.
struct UserData : public base::SupportsUserData::Data {
explicit UserData(WebRequestNS* data) : data(data) {}
WebRequestNS* data;
explicit UserData(WebRequest* data) : data(data) {}
WebRequest* data;
};
// Test whether the URL of |request| matches |patterns|.
@ -212,72 +212,72 @@ void ReadFromResponse(v8::Isolate* isolate,
} // namespace
gin::WrapperInfo WebRequestNS::kWrapperInfo = {gin::kEmbedderNativeGin};
gin::WrapperInfo WebRequest::kWrapperInfo = {gin::kEmbedderNativeGin};
WebRequestNS::SimpleListenerInfo::SimpleListenerInfo(
WebRequest::SimpleListenerInfo::SimpleListenerInfo(
std::set<URLPattern> patterns_,
SimpleListener listener_)
: url_patterns(std::move(patterns_)), listener(listener_) {}
WebRequestNS::SimpleListenerInfo::SimpleListenerInfo() = default;
WebRequestNS::SimpleListenerInfo::~SimpleListenerInfo() = default;
WebRequest::SimpleListenerInfo::SimpleListenerInfo() = default;
WebRequest::SimpleListenerInfo::~SimpleListenerInfo() = default;
WebRequestNS::ResponseListenerInfo::ResponseListenerInfo(
WebRequest::ResponseListenerInfo::ResponseListenerInfo(
std::set<URLPattern> patterns_,
ResponseListener listener_)
: url_patterns(std::move(patterns_)), listener(listener_) {}
WebRequestNS::ResponseListenerInfo::ResponseListenerInfo() = default;
WebRequestNS::ResponseListenerInfo::~ResponseListenerInfo() = default;
WebRequest::ResponseListenerInfo::ResponseListenerInfo() = default;
WebRequest::ResponseListenerInfo::~ResponseListenerInfo() = default;
WebRequestNS::WebRequestNS(v8::Isolate* isolate,
content::BrowserContext* browser_context)
WebRequest::WebRequest(v8::Isolate* isolate,
content::BrowserContext* browser_context)
: browser_context_(browser_context) {
browser_context_->SetUserData(kUserDataKey, std::make_unique<UserData>(this));
}
WebRequestNS::~WebRequestNS() {
WebRequest::~WebRequest() {
browser_context_->RemoveUserData(kUserDataKey);
}
gin::ObjectTemplateBuilder WebRequestNS::GetObjectTemplateBuilder(
gin::ObjectTemplateBuilder WebRequest::GetObjectTemplateBuilder(
v8::Isolate* isolate) {
return gin::Wrappable<WebRequestNS>::GetObjectTemplateBuilder(isolate)
return gin::Wrappable<WebRequest>::GetObjectTemplateBuilder(isolate)
.SetMethod("onBeforeRequest",
&WebRequestNS::SetResponseListener<kOnBeforeRequest>)
&WebRequest::SetResponseListener<kOnBeforeRequest>)
.SetMethod("onBeforeSendHeaders",
&WebRequestNS::SetResponseListener<kOnBeforeSendHeaders>)
&WebRequest::SetResponseListener<kOnBeforeSendHeaders>)
.SetMethod("onHeadersReceived",
&WebRequestNS::SetResponseListener<kOnHeadersReceived>)
&WebRequest::SetResponseListener<kOnHeadersReceived>)
.SetMethod("onSendHeaders",
&WebRequestNS::SetSimpleListener<kOnSendHeaders>)
&WebRequest::SetSimpleListener<kOnSendHeaders>)
.SetMethod("onBeforeRedirect",
&WebRequestNS::SetSimpleListener<kOnBeforeRedirect>)
&WebRequest::SetSimpleListener<kOnBeforeRedirect>)
.SetMethod("onResponseStarted",
&WebRequestNS::SetSimpleListener<kOnResponseStarted>)
&WebRequest::SetSimpleListener<kOnResponseStarted>)
.SetMethod("onErrorOccurred",
&WebRequestNS::SetSimpleListener<kOnErrorOccurred>)
.SetMethod("onCompleted", &WebRequestNS::SetSimpleListener<kOnCompleted>);
&WebRequest::SetSimpleListener<kOnErrorOccurred>)
.SetMethod("onCompleted", &WebRequest::SetSimpleListener<kOnCompleted>);
}
const char* WebRequestNS::GetTypeName() {
const char* WebRequest::GetTypeName() {
return "WebRequest";
}
bool WebRequestNS::HasListener() const {
bool WebRequest::HasListener() const {
return !(simple_listeners_.empty() && response_listeners_.empty());
}
int WebRequestNS::OnBeforeRequest(extensions::WebRequestInfo* info,
const network::ResourceRequest& request,
net::CompletionOnceCallback callback,
GURL* new_url) {
int WebRequest::OnBeforeRequest(extensions::WebRequestInfo* info,
const network::ResourceRequest& request,
net::CompletionOnceCallback callback,
GURL* new_url) {
return HandleResponseEvent(kOnBeforeRequest, info, std::move(callback),
new_url, request);
}
int WebRequestNS::OnBeforeSendHeaders(extensions::WebRequestInfo* info,
const network::ResourceRequest& request,
BeforeSendHeadersCallback callback,
net::HttpRequestHeaders* headers) {
int WebRequest::OnBeforeSendHeaders(extensions::WebRequestInfo* info,
const network::ResourceRequest& request,
BeforeSendHeadersCallback callback,
net::HttpRequestHeaders* headers) {
return HandleResponseEvent(
kOnBeforeSendHeaders, info,
base::BindOnce(std::move(callback), std::set<std::string>(),
@ -285,7 +285,7 @@ int WebRequestNS::OnBeforeSendHeaders(extensions::WebRequestInfo* info,
headers, request, *headers);
}
int WebRequestNS::OnHeadersReceived(
int WebRequest::OnHeadersReceived(
extensions::WebRequestInfo* info,
const network::ResourceRequest& request,
net::CompletionOnceCallback callback,
@ -299,53 +299,53 @@ int WebRequestNS::OnHeadersReceived(
request);
}
void WebRequestNS::OnSendHeaders(extensions::WebRequestInfo* info,
const network::ResourceRequest& request,
const net::HttpRequestHeaders& headers) {
void WebRequest::OnSendHeaders(extensions::WebRequestInfo* info,
const network::ResourceRequest& request,
const net::HttpRequestHeaders& headers) {
HandleSimpleEvent(kOnSendHeaders, info, request, headers);
}
void WebRequestNS::OnBeforeRedirect(extensions::WebRequestInfo* info,
const network::ResourceRequest& request,
const GURL& new_location) {
void WebRequest::OnBeforeRedirect(extensions::WebRequestInfo* info,
const network::ResourceRequest& request,
const GURL& new_location) {
HandleSimpleEvent(kOnBeforeRedirect, info, request, new_location);
}
void WebRequestNS::OnResponseStarted(extensions::WebRequestInfo* info,
const network::ResourceRequest& request) {
void WebRequest::OnResponseStarted(extensions::WebRequestInfo* info,
const network::ResourceRequest& request) {
HandleSimpleEvent(kOnResponseStarted, info, request);
}
void WebRequestNS::OnErrorOccurred(extensions::WebRequestInfo* info,
const network::ResourceRequest& request,
int net_error) {
void WebRequest::OnErrorOccurred(extensions::WebRequestInfo* info,
const network::ResourceRequest& request,
int net_error) {
callbacks_.erase(info->id);
HandleSimpleEvent(kOnErrorOccurred, info, request, net_error);
}
void WebRequestNS::OnCompleted(extensions::WebRequestInfo* info,
const network::ResourceRequest& request,
int net_error) {
void WebRequest::OnCompleted(extensions::WebRequestInfo* info,
const network::ResourceRequest& request,
int net_error) {
callbacks_.erase(info->id);
HandleSimpleEvent(kOnCompleted, info, request, net_error);
}
template <WebRequestNS::SimpleEvent event>
void WebRequestNS::SetSimpleListener(gin::Arguments* args) {
template <WebRequest::SimpleEvent event>
void WebRequest::SetSimpleListener(gin::Arguments* args) {
SetListener<SimpleListener>(event, &simple_listeners_, args);
}
template <WebRequestNS::ResponseEvent event>
void WebRequestNS::SetResponseListener(gin::Arguments* args) {
template <WebRequest::ResponseEvent event>
void WebRequest::SetResponseListener(gin::Arguments* args) {
SetListener<ResponseListener>(event, &response_listeners_, args);
}
template <typename Listener, typename Listeners, typename Event>
void WebRequestNS::SetListener(Event event,
Listeners* listeners,
gin::Arguments* args) {
void WebRequest::SetListener(Event event,
Listeners* listeners,
gin::Arguments* args) {
v8::Local<v8::Value> arg;
// { urls }.
@ -393,9 +393,9 @@ void WebRequestNS::SetListener(Event event,
}
template <typename... Args>
void WebRequestNS::HandleSimpleEvent(SimpleEvent event,
extensions::WebRequestInfo* request_info,
Args... args) {
void WebRequest::HandleSimpleEvent(SimpleEvent event,
extensions::WebRequestInfo* request_info,
Args... args) {
const auto iter = simple_listeners_.find(event);
if (iter == std::end(simple_listeners_))
return;
@ -412,11 +412,11 @@ void WebRequestNS::HandleSimpleEvent(SimpleEvent event,
}
template <typename Out, typename... Args>
int WebRequestNS::HandleResponseEvent(ResponseEvent event,
extensions::WebRequestInfo* request_info,
net::CompletionOnceCallback callback,
Out out,
Args... args) {
int WebRequest::HandleResponseEvent(ResponseEvent event,
extensions::WebRequestInfo* request_info,
net::CompletionOnceCallback callback,
Out out,
Args... args) {
const auto iter = response_listeners_.find(event);
if (iter == std::end(response_listeners_))
return net::OK;
@ -433,16 +433,16 @@ int WebRequestNS::HandleResponseEvent(ResponseEvent event,
FillDetails(&details, request_info, args...);
ResponseCallback response =
base::BindOnce(&WebRequestNS::OnListenerResult<Out>,
base::Unretained(this), request_info->id, out);
base::BindOnce(&WebRequest::OnListenerResult<Out>, base::Unretained(this),
request_info->id, out);
info.listener.Run(gin::ConvertToV8(isolate, details), std::move(response));
return net::ERR_IO_PENDING;
}
template <typename T>
void WebRequestNS::OnListenerResult(uint64_t id,
T out,
v8::Local<v8::Value> response) {
void WebRequest::OnListenerResult(uint64_t id,
T out,
v8::Local<v8::Value> response) {
const auto iter = callbacks_.find(id);
if (iter == std::end(callbacks_))
return;
@ -468,10 +468,10 @@ void WebRequestNS::OnListenerResult(uint64_t id,
}
// static
gin::Handle<WebRequestNS> WebRequestNS::FromOrCreate(
gin::Handle<WebRequest> WebRequest::FromOrCreate(
v8::Isolate* isolate,
content::BrowserContext* browser_context) {
gin::Handle<WebRequestNS> handle = From(isolate, browser_context);
gin::Handle<WebRequest> handle = From(isolate, browser_context);
if (handle.IsEmpty()) {
// Make sure the |Session| object has the |webRequest| property created.
v8::Local<v8::Value> web_request =
@ -485,24 +485,24 @@ gin::Handle<WebRequestNS> WebRequestNS::FromOrCreate(
}
// static
gin::Handle<WebRequestNS> WebRequestNS::Create(
gin::Handle<WebRequest> WebRequest::Create(
v8::Isolate* isolate,
content::BrowserContext* browser_context) {
DCHECK(From(isolate, browser_context).IsEmpty())
<< "WebRequestNS already created";
return gin::CreateHandle(isolate, new WebRequestNS(isolate, browser_context));
<< "WebRequest already created";
return gin::CreateHandle(isolate, new WebRequest(isolate, browser_context));
}
// static
gin::Handle<WebRequestNS> WebRequestNS::From(
gin::Handle<WebRequest> WebRequest::From(
v8::Isolate* isolate,
content::BrowserContext* browser_context) {
if (!browser_context)
return gin::Handle<WebRequestNS>();
return gin::Handle<WebRequest>();
auto* user_data =
static_cast<UserData*>(browser_context->GetUserData(kUserDataKey));
if (!user_data)
return gin::Handle<WebRequestNS>();
return gin::Handle<WebRequest>();
return gin::CreateHandle(isolate, user_data->data);
}

Просмотреть файл

@ -2,8 +2,8 @@
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef SHELL_BROWSER_API_ATOM_API_WEB_REQUEST_NS_H_
#define SHELL_BROWSER_API_ATOM_API_WEB_REQUEST_NS_H_
#ifndef SHELL_BROWSER_API_ATOM_API_WEB_REQUEST_H_
#define SHELL_BROWSER_API_ATOM_API_WEB_REQUEST_H_
#include <map>
#include <set>
@ -23,7 +23,7 @@ namespace electron {
namespace api {
class WebRequestNS : public gin::Wrappable<WebRequestNS>, public WebRequestAPI {
class WebRequest : public gin::Wrappable<WebRequest>, public WebRequestAPI {
public:
static gin::WrapperInfo kWrapperInfo;
@ -31,19 +31,18 @@ class WebRequestNS : public gin::Wrappable<WebRequestNS>, public WebRequestAPI {
// is no one.
// Note that the lifetime of WebRequest object is managed by Session, instead
// of the caller.
static gin::Handle<WebRequestNS> FromOrCreate(
static gin::Handle<WebRequest> FromOrCreate(
v8::Isolate* isolate,
content::BrowserContext* browser_context);
// Return a new WebRequest object, this should only be called by Session.
static gin::Handle<WebRequestNS> Create(
static gin::Handle<WebRequest> Create(
v8::Isolate* isolate,
content::BrowserContext* browser_context);
// Find the WebRequest object attached to |browser_context|.
static gin::Handle<WebRequestNS> From(
v8::Isolate* isolate,
content::BrowserContext* browser_context);
static gin::Handle<WebRequest> From(v8::Isolate* isolate,
content::BrowserContext* browser_context);
// gin::Wrappable:
gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
@ -51,8 +50,8 @@ class WebRequestNS : public gin::Wrappable<WebRequestNS>, public WebRequestAPI {
const char* GetTypeName() override;
private:
WebRequestNS(v8::Isolate* isolate, content::BrowserContext* browser_context);
~WebRequestNS() override;
WebRequest(v8::Isolate* isolate, content::BrowserContext* browser_context);
~WebRequest() override;
// WebRequestAPI:
bool HasListener() const override;
@ -155,4 +154,4 @@ class WebRequestNS : public gin::Wrappable<WebRequestNS>, public WebRequestAPI {
} // namespace electron
#endif // SHELL_BROWSER_API_ATOM_API_WEB_REQUEST_NS_H_
#endif // SHELL_BROWSER_API_ATOM_API_WEB_REQUEST_H_

Просмотреть файл

@ -50,10 +50,10 @@
#include "services/network/public/cpp/resource_request_body.h"
#include "shell/app/manifests.h"
#include "shell/browser/api/atom_api_app.h"
#include "shell/browser/api/atom_api_protocol_ns.h"
#include "shell/browser/api/atom_api_protocol.h"
#include "shell/browser/api/atom_api_session.h"
#include "shell/browser/api/atom_api_web_contents.h"
#include "shell/browser/api/atom_api_web_request_ns.h"
#include "shell/browser/api/atom_api_web_request.h"
#include "shell/browser/atom_autofill_driver_factory.h"
#include "shell/browser/atom_browser_context.h"
#include "shell/browser/atom_browser_main_parts.h"
@ -956,7 +956,7 @@ void AtomBrowserClient::RegisterNonNetworkNavigationURLLoaderFactories(
NonNetworkURLLoaderFactoryMap* factories) {
content::WebContents* web_contents =
content::WebContents::FromFrameTreeNodeId(frame_tree_node_id);
api::ProtocolNS* protocol = api::ProtocolNS::FromWrappedClass(
api::Protocol* protocol = api::Protocol::FromWrappedClass(
v8::Isolate::GetCurrent(), web_contents->GetBrowserContext());
if (protocol)
protocol->RegisterURLLoaderFactories(factories);
@ -972,7 +972,7 @@ void AtomBrowserClient::RegisterNonNetworkSubresourceURLLoaderFactories(
content::WebContents* web_contents =
content::WebContents::FromRenderFrameHost(frame_host);
if (web_contents) {
api::ProtocolNS* protocol = api::ProtocolNS::FromWrappedClass(
api::Protocol* protocol = api::Protocol::FromWrappedClass(
v8::Isolate::GetCurrent(), web_contents->GetBrowserContext());
if (protocol)
protocol->RegisterURLLoaderFactories(factories);
@ -990,10 +990,10 @@ bool AtomBrowserClient::WillCreateURLLoaderFactory(
header_client,
bool* bypass_redirect_checks) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
api::ProtocolNS* protocol =
api::ProtocolNS::FromWrappedClass(isolate, browser_context);
api::Protocol* protocol =
api::Protocol::FromWrappedClass(isolate, browser_context);
DCHECK(protocol);
auto web_request = api::WebRequestNS::FromOrCreate(isolate, browser_context);
auto web_request = api::WebRequest::FromOrCreate(isolate, browser_context);
DCHECK(web_request.get());
auto proxied_receiver = std::move(*factory_receiver);

Просмотреть файл

@ -23,7 +23,7 @@
namespace electron {
// Defines the interface for WebRequest API, implemented by api::WebRequestNS.
// Defines the interface for WebRequest API, implemented by api::WebRequest.
class WebRequestAPI {
public:
virtual ~WebRequestAPI() {}
@ -236,12 +236,12 @@ class ProxyingURLLoaderFactory
void RemoveRequest(int32_t network_service_request_id, uint64_t request_id);
void MaybeDeleteThis();
// Passed from api::WebRequestNS.
// Passed from api::WebRequest.
WebRequestAPI* web_request_api_;
// This is passed from api::ProtocolNS.
// This is passed from api::Protocol.
//
// The ProtocolNS instance lives through the lifetime of BrowserContenxt,
// The Protocol instance lives through the lifetime of BrowserContenxt,
// which is guarenteed to cover the lifetime of URLLoaderFactory, so the
// reference is guarenteed to be valid.
//