chore: rename atomBinding to electronBinding (#17419)
This commit is contained in:
parent
5025c991ee
commit
38d75010c7
81 changed files with 167 additions and 164 deletions
|
@ -10,7 +10,7 @@
|
|||
#include "atom/app/uv_task_runner.h"
|
||||
#include "atom/browser/javascript_environment.h"
|
||||
#include "atom/browser/node_debugger.h"
|
||||
#include "atom/common/api/atom_bindings.h"
|
||||
#include "atom/common/api/electron_bindings.h"
|
||||
#include "atom/common/atom_version.h"
|
||||
#include "atom/common/crash_reporter/crash_reporter.h"
|
||||
#include "atom/common/native_mate_converters/string16_converter.h"
|
||||
|
@ -70,9 +70,9 @@ int NodeMain(int argc, char* argv[]) {
|
|||
|
||||
mate::Dictionary process(gin_env.isolate(), env->process_object());
|
||||
#if defined(OS_WIN)
|
||||
process.SetMethod("log", &AtomBindings::Log);
|
||||
process.SetMethod("log", &ElectronBindings::Log);
|
||||
#endif
|
||||
process.SetMethod("crash", &AtomBindings::Crash);
|
||||
process.SetMethod("crash", &ElectronBindings::Crash);
|
||||
|
||||
// Setup process.crashReporter.start in child node processes
|
||||
auto reporter = mate::Dictionary::CreateEmpty(gin_env.isolate());
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include "atom/browser/media/media_capture_devices_dispatcher.h"
|
||||
#include "atom/browser/node_debugger.h"
|
||||
#include "atom/browser/ui/devtools_manager_delegate.h"
|
||||
#include "atom/common/api/atom_bindings.h"
|
||||
#include "atom/common/api/electron_bindings.h"
|
||||
#include "atom/common/application_info.h"
|
||||
#include "atom/common/asar/asar_util.h"
|
||||
#include "atom/common/node_bindings.h"
|
||||
|
@ -234,7 +234,7 @@ AtomBrowserMainParts::AtomBrowserMainParts(
|
|||
: fake_browser_process_(new BrowserProcessImpl),
|
||||
browser_(new Browser),
|
||||
node_bindings_(NodeBindings::Create(NodeBindings::BROWSER)),
|
||||
atom_bindings_(new AtomBindings(uv_default_loop())),
|
||||
electron_bindings_(new ElectronBindings(uv_default_loop())),
|
||||
main_function_params_(params) {
|
||||
DCHECK(!self_) << "Cannot have two AtomBrowserMainParts";
|
||||
self_ = this;
|
||||
|
@ -323,7 +323,7 @@ void AtomBrowserMainParts::PostEarlyInitialization() {
|
|||
node_debugger_->Start();
|
||||
|
||||
// Add Electron extended APIs.
|
||||
atom_bindings_->BindTo(js_env_->isolate(), env->process_object());
|
||||
electron_bindings_->BindTo(js_env_->isolate(), env->process_object());
|
||||
|
||||
// Load everything.
|
||||
node_bindings_->LoadEnvironment(env);
|
||||
|
|
|
@ -29,7 +29,7 @@ class WMState;
|
|||
|
||||
namespace atom {
|
||||
|
||||
class AtomBindings;
|
||||
class ElectronBindings;
|
||||
class Browser;
|
||||
class JavascriptEnvironment;
|
||||
class NodeBindings;
|
||||
|
@ -123,7 +123,7 @@ class AtomBrowserMainParts : public content::BrowserMainParts {
|
|||
std::unique_ptr<Browser> browser_;
|
||||
std::unique_ptr<JavascriptEnvironment> js_env_;
|
||||
std::unique_ptr<NodeBindings> node_bindings_;
|
||||
std::unique_ptr<AtomBindings> atom_bindings_;
|
||||
std::unique_ptr<ElectronBindings> electron_bindings_;
|
||||
std::unique_ptr<NodeEnvironment> node_env_;
|
||||
std::unique_ptr<NodeDebugger> node_debugger_;
|
||||
std::unique_ptr<IconManager> icon_manager_;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/common/api/atom_bindings.h"
|
||||
#include "atom/common/api/electron_bindings.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
|
@ -43,25 +43,25 @@ struct DummyClass {
|
|||
// we can get the stack trace.
|
||||
void FatalErrorCallback(const char* location, const char* message) {
|
||||
LOG(ERROR) << "Fatal error in V8: " << location << " " << message;
|
||||
AtomBindings::Crash();
|
||||
ElectronBindings::Crash();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
AtomBindings::AtomBindings(uv_loop_t* loop) {
|
||||
ElectronBindings::ElectronBindings(uv_loop_t* loop) {
|
||||
uv_async_init(loop, &call_next_tick_async_, OnCallNextTick);
|
||||
call_next_tick_async_.data = this;
|
||||
metrics_ = base::ProcessMetrics::CreateCurrentProcessMetrics();
|
||||
}
|
||||
|
||||
AtomBindings::~AtomBindings() {
|
||||
ElectronBindings::~ElectronBindings() {
|
||||
uv_close(reinterpret_cast<uv_handle_t*>(&call_next_tick_async_), nullptr);
|
||||
}
|
||||
|
||||
// static
|
||||
void AtomBindings::BindProcess(v8::Isolate* isolate,
|
||||
mate::Dictionary* process,
|
||||
base::ProcessMetrics* metrics) {
|
||||
void ElectronBindings::BindProcess(v8::Isolate* isolate,
|
||||
mate::Dictionary* process,
|
||||
base::ProcessMetrics* metrics) {
|
||||
// These bindings are shared between sandboxed & unsandboxed renderers
|
||||
process->SetMethod("crash", &Crash);
|
||||
process->SetMethod("hang", &Hang);
|
||||
|
@ -73,7 +73,7 @@ void AtomBindings::BindProcess(v8::Isolate* isolate,
|
|||
process->SetMethod("getSystemVersion",
|
||||
&base::SysInfo::OperatingSystemVersion);
|
||||
process->SetMethod("getIOCounters", &GetIOCounters);
|
||||
process->SetMethod("getCPUUsage", base::Bind(&AtomBindings::GetCPUUsage,
|
||||
process->SetMethod("getCPUUsage", base::Bind(&ElectronBindings::GetCPUUsage,
|
||||
base::Unretained(metrics)));
|
||||
|
||||
#if defined(MAS_BUILD)
|
||||
|
@ -86,7 +86,8 @@ void AtomBindings::BindProcess(v8::Isolate* isolate,
|
|||
#endif
|
||||
}
|
||||
|
||||
void AtomBindings::BindTo(v8::Isolate* isolate, v8::Local<v8::Object> process) {
|
||||
void ElectronBindings::BindTo(v8::Isolate* isolate,
|
||||
v8::Local<v8::Object> process) {
|
||||
isolate->SetFatalErrorHandler(FatalErrorCallback);
|
||||
|
||||
mate::Dictionary dict(isolate, process);
|
||||
|
@ -96,7 +97,7 @@ void AtomBindings::BindTo(v8::Isolate* isolate, v8::Local<v8::Object> process) {
|
|||
#if defined(OS_POSIX)
|
||||
dict.SetMethod("setFdLimit", &base::IncreaseFdLimitTo);
|
||||
#endif
|
||||
dict.SetMethod("activateUvLoop", base::Bind(&AtomBindings::ActivateUVLoop,
|
||||
dict.SetMethod("activateUvLoop", base::Bind(&ElectronBindings::ActivateUVLoop,
|
||||
base::Unretained(this)));
|
||||
|
||||
mate::Dictionary versions;
|
||||
|
@ -106,14 +107,14 @@ void AtomBindings::BindTo(v8::Isolate* isolate, v8::Local<v8::Object> process) {
|
|||
}
|
||||
}
|
||||
|
||||
void AtomBindings::EnvironmentDestroyed(node::Environment* env) {
|
||||
void ElectronBindings::EnvironmentDestroyed(node::Environment* env) {
|
||||
auto it =
|
||||
std::find(pending_next_ticks_.begin(), pending_next_ticks_.end(), env);
|
||||
if (it != pending_next_ticks_.end())
|
||||
pending_next_ticks_.erase(it);
|
||||
}
|
||||
|
||||
void AtomBindings::ActivateUVLoop(v8::Isolate* isolate) {
|
||||
void ElectronBindings::ActivateUVLoop(v8::Isolate* isolate) {
|
||||
node::Environment* env = node::Environment::GetCurrent(isolate);
|
||||
if (std::find(pending_next_ticks_.begin(), pending_next_ticks_.end(), env) !=
|
||||
pending_next_ticks_.end())
|
||||
|
@ -124,8 +125,8 @@ void AtomBindings::ActivateUVLoop(v8::Isolate* isolate) {
|
|||
}
|
||||
|
||||
// static
|
||||
void AtomBindings::OnCallNextTick(uv_async_t* handle) {
|
||||
AtomBindings* self = static_cast<AtomBindings*>(handle->data);
|
||||
void ElectronBindings::OnCallNextTick(uv_async_t* handle) {
|
||||
ElectronBindings* self = static_cast<ElectronBindings*>(handle->data);
|
||||
for (std::list<node::Environment*>::const_iterator it =
|
||||
self->pending_next_ticks_.begin();
|
||||
it != self->pending_next_ticks_.end(); ++it) {
|
||||
|
@ -141,23 +142,23 @@ void AtomBindings::OnCallNextTick(uv_async_t* handle) {
|
|||
}
|
||||
|
||||
// static
|
||||
void AtomBindings::Log(const base::string16& message) {
|
||||
void ElectronBindings::Log(const base::string16& message) {
|
||||
std::cout << message << std::flush;
|
||||
}
|
||||
|
||||
// static
|
||||
void AtomBindings::Crash() {
|
||||
void ElectronBindings::Crash() {
|
||||
static_cast<DummyClass*>(nullptr)->crash = true;
|
||||
}
|
||||
|
||||
// static
|
||||
void AtomBindings::Hang() {
|
||||
void ElectronBindings::Hang() {
|
||||
for (;;)
|
||||
base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1));
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Local<v8::Value> AtomBindings::GetHeapStatistics(v8::Isolate* isolate) {
|
||||
v8::Local<v8::Value> ElectronBindings::GetHeapStatistics(v8::Isolate* isolate) {
|
||||
v8::HeapStatistics v8_heap_stats;
|
||||
isolate->GetHeapStatistics(&v8_heap_stats);
|
||||
|
||||
|
@ -187,7 +188,7 @@ v8::Local<v8::Value> AtomBindings::GetHeapStatistics(v8::Isolate* isolate) {
|
|||
}
|
||||
|
||||
// static
|
||||
v8::Local<v8::Value> AtomBindings::GetCreationTime(v8::Isolate* isolate) {
|
||||
v8::Local<v8::Value> ElectronBindings::GetCreationTime(v8::Isolate* isolate) {
|
||||
auto timeValue = base::Process::Current().CreationTime();
|
||||
if (timeValue.is_null()) {
|
||||
return v8::Null(isolate);
|
||||
|
@ -197,8 +198,9 @@ v8::Local<v8::Value> AtomBindings::GetCreationTime(v8::Isolate* isolate) {
|
|||
}
|
||||
|
||||
// static
|
||||
v8::Local<v8::Value> AtomBindings::GetSystemMemoryInfo(v8::Isolate* isolate,
|
||||
mate::Arguments* args) {
|
||||
v8::Local<v8::Value> ElectronBindings::GetSystemMemoryInfo(
|
||||
v8::Isolate* isolate,
|
||||
mate::Arguments* args) {
|
||||
base::SystemMemoryInfoKB mem_info;
|
||||
if (!base::GetSystemMemoryInfo(&mem_info)) {
|
||||
args->ThrowError("Unable to retrieve system memory information");
|
||||
|
@ -228,7 +230,7 @@ v8::Local<v8::Value> AtomBindings::GetSystemMemoryInfo(v8::Isolate* isolate,
|
|||
}
|
||||
|
||||
// static
|
||||
v8::Local<v8::Promise> AtomBindings::GetProcessMemoryInfo(
|
||||
v8::Local<v8::Promise> ElectronBindings::GetProcessMemoryInfo(
|
||||
v8::Isolate* isolate) {
|
||||
util::Promise promise(isolate);
|
||||
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||
|
@ -243,13 +245,13 @@ v8::Local<v8::Promise> AtomBindings::GetProcessMemoryInfo(
|
|||
memory_instrumentation::MemoryInstrumentation::GetInstance()
|
||||
->RequestGlobalDumpForPid(
|
||||
base::GetCurrentProcId(), std::vector<std::string>(),
|
||||
base::BindOnce(&AtomBindings::DidReceiveMemoryDump,
|
||||
base::BindOnce(&ElectronBindings::DidReceiveMemoryDump,
|
||||
std::move(context), std::move(promise)));
|
||||
return handle;
|
||||
}
|
||||
|
||||
// static
|
||||
void AtomBindings::DidReceiveMemoryDump(
|
||||
void ElectronBindings::DidReceiveMemoryDump(
|
||||
v8::Global<v8::Context> context,
|
||||
util::Promise promise,
|
||||
bool success,
|
||||
|
@ -290,8 +292,9 @@ void AtomBindings::DidReceiveMemoryDump(
|
|||
}
|
||||
|
||||
// static
|
||||
v8::Local<v8::Value> AtomBindings::GetCPUUsage(base::ProcessMetrics* metrics,
|
||||
v8::Isolate* isolate) {
|
||||
v8::Local<v8::Value> ElectronBindings::GetCPUUsage(
|
||||
base::ProcessMetrics* metrics,
|
||||
v8::Isolate* isolate) {
|
||||
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
|
||||
dict.SetHidden("simple", true);
|
||||
int processor_count = base::SysInfo::NumberOfProcessors();
|
||||
|
@ -310,7 +313,7 @@ v8::Local<v8::Value> AtomBindings::GetCPUUsage(base::ProcessMetrics* metrics,
|
|||
}
|
||||
|
||||
// static
|
||||
v8::Local<v8::Value> AtomBindings::GetIOCounters(v8::Isolate* isolate) {
|
||||
v8::Local<v8::Value> ElectronBindings::GetIOCounters(v8::Isolate* isolate) {
|
||||
auto metrics = base::ProcessMetrics::CreateCurrentProcessMetrics();
|
||||
base::IoCounters io_counters;
|
||||
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
|
||||
|
@ -329,8 +332,8 @@ v8::Local<v8::Value> AtomBindings::GetIOCounters(v8::Isolate* isolate) {
|
|||
}
|
||||
|
||||
// static
|
||||
bool AtomBindings::TakeHeapSnapshot(v8::Isolate* isolate,
|
||||
const base::FilePath& file_path) {
|
||||
bool ElectronBindings::TakeHeapSnapshot(v8::Isolate* isolate,
|
||||
const base::FilePath& file_path) {
|
||||
base::ThreadRestrictions::ScopedAllowIO allow_io;
|
||||
|
||||
base::File file(file_path,
|
|
@ -2,8 +2,8 @@
|
|||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_COMMON_API_ATOM_BINDINGS_H_
|
||||
#define ATOM_COMMON_API_ATOM_BINDINGS_H_
|
||||
#ifndef ATOM_COMMON_API_ELECTRON_BINDINGS_H_
|
||||
#define ATOM_COMMON_API_ELECTRON_BINDINGS_H_
|
||||
|
||||
#include <list>
|
||||
#include <memory>
|
||||
|
@ -32,13 +32,13 @@ class Environment;
|
|||
|
||||
namespace atom {
|
||||
|
||||
class AtomBindings {
|
||||
class ElectronBindings {
|
||||
public:
|
||||
explicit AtomBindings(uv_loop_t* loop);
|
||||
virtual ~AtomBindings();
|
||||
explicit ElectronBindings(uv_loop_t* loop);
|
||||
virtual ~ElectronBindings();
|
||||
|
||||
// Add process.atomBinding function, which behaves like process.binding but
|
||||
// load native code from Electron instead.
|
||||
// Add process.electronBinding function, which behaves like process.binding
|
||||
// but load native code from Electron instead.
|
||||
void BindTo(v8::Isolate* isolate, v8::Local<v8::Object> process);
|
||||
|
||||
// Should be called when a node::Environment has been destroyed.
|
||||
|
@ -78,9 +78,9 @@ class AtomBindings {
|
|||
std::list<node::Environment*> pending_next_ticks_;
|
||||
std::unique_ptr<base::ProcessMetrics> metrics_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomBindings);
|
||||
DISALLOW_COPY_AND_ASSIGN(ElectronBindings);
|
||||
};
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_COMMON_API_ATOM_BINDINGS_H_
|
||||
#endif // ATOM_COMMON_API_ELECTRON_BINDINGS_H_
|
|
@ -7,7 +7,7 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "atom/common/api/atom_bindings.h"
|
||||
#include "atom/common/api/electron_bindings.h"
|
||||
#include "atom/common/api/event_emitter_caller.h"
|
||||
#include "atom/common/asar/asar_util.h"
|
||||
#include "atom/common/node_bindings.h"
|
||||
|
@ -35,7 +35,7 @@ bool IsDevToolsExtension(content::RenderFrame* render_frame) {
|
|||
|
||||
AtomRendererClient::AtomRendererClient()
|
||||
: node_bindings_(NodeBindings::Create(NodeBindings::RENDERER)),
|
||||
atom_bindings_(new AtomBindings(uv_default_loop())) {}
|
||||
electron_bindings_(new ElectronBindings(uv_default_loop())) {}
|
||||
|
||||
AtomRendererClient::~AtomRendererClient() {
|
||||
asar::ClearArchives();
|
||||
|
@ -114,7 +114,7 @@ void AtomRendererClient::DidCreateScriptContext(
|
|||
environments_.insert(env);
|
||||
|
||||
// Add Electron extended APIs.
|
||||
atom_bindings_->BindTo(env->isolate(), env->process_object());
|
||||
electron_bindings_->BindTo(env->isolate(), env->process_object());
|
||||
AddRenderBindings(env->isolate(), env->process_object());
|
||||
mate::Dictionary process_dict(env->isolate(), env->process_object());
|
||||
process_dict.SetReadOnly("isMainFrame", render_frame->IsMainFrame());
|
||||
|
@ -157,8 +157,8 @@ void AtomRendererClient::WillReleaseScriptContext(
|
|||
switches::kNodeIntegrationInSubFrames))
|
||||
node::FreeEnvironment(env);
|
||||
|
||||
// AtomBindings is tracking node environments.
|
||||
atom_bindings_->EnvironmentDestroyed(env);
|
||||
// ElectronBindings is tracking node environments.
|
||||
electron_bindings_->EnvironmentDestroyed(env);
|
||||
}
|
||||
|
||||
bool AtomRendererClient::ShouldFork(blink::WebLocalFrame* frame,
|
||||
|
|
|
@ -18,7 +18,7 @@ class Environment;
|
|||
|
||||
namespace atom {
|
||||
|
||||
class AtomBindings;
|
||||
class ElectronBindings;
|
||||
class NodeBindings;
|
||||
|
||||
class AtomRendererClient : public RendererClientBase {
|
||||
|
@ -60,7 +60,7 @@ class AtomRendererClient : public RendererClientBase {
|
|||
bool node_integration_initialized_ = false;
|
||||
|
||||
std::unique_ptr<NodeBindings> node_bindings_;
|
||||
std::unique_ptr<AtomBindings> atom_bindings_;
|
||||
std::unique_ptr<ElectronBindings> electron_bindings_;
|
||||
|
||||
// The node::Environment::GetCurrent API does not return nullptr when it
|
||||
// is called for a context without node::Environment, so we have to keep
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "atom/renderer/atom_sandboxed_renderer_client.h"
|
||||
|
||||
#include "atom/common/api/api_messages.h"
|
||||
#include "atom/common/api/atom_bindings.h"
|
||||
#include "atom/common/api/electron_bindings.h"
|
||||
#include "atom/common/application_info.h"
|
||||
#include "atom/common/native_mate_converters/string16_converter.h"
|
||||
#include "atom/common/native_mate_converters/value_converter.h"
|
||||
|
@ -149,7 +149,7 @@ void AtomSandboxedRendererClient::InitializeBindings(
|
|||
mate::Dictionary process = mate::Dictionary::CreateEmpty(isolate);
|
||||
b.Set("process", process);
|
||||
|
||||
AtomBindings::BindProcess(isolate, &process, metrics_.get());
|
||||
ElectronBindings::BindProcess(isolate, &process, metrics_.get());
|
||||
|
||||
process.Set("argv", base::CommandLine::ForCurrentProcess()->argv());
|
||||
process.SetReadOnly("pid", base::GetCurrentProcId());
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
#include "atom/renderer/web_worker_observer.h"
|
||||
|
||||
#include "atom/common/api/atom_bindings.h"
|
||||
#include "atom/common/api/electron_bindings.h"
|
||||
#include "atom/common/api/event_emitter_caller.h"
|
||||
#include "atom/common/asar/asar_util.h"
|
||||
#include "atom/common/node_bindings.h"
|
||||
|
@ -30,7 +30,7 @@ WebWorkerObserver* WebWorkerObserver::GetCurrent() {
|
|||
|
||||
WebWorkerObserver::WebWorkerObserver()
|
||||
: node_bindings_(NodeBindings::Create(NodeBindings::WORKER)),
|
||||
atom_bindings_(new AtomBindings(node_bindings_->uv_loop())) {
|
||||
electron_bindings_(new ElectronBindings(node_bindings_->uv_loop())) {
|
||||
lazy_tls.Pointer()->Set(this);
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ void WebWorkerObserver::ContextCreated(v8::Local<v8::Context> context) {
|
|||
node::Environment* env = node_bindings_->CreateEnvironment(context);
|
||||
|
||||
// Add Electron extended APIs.
|
||||
atom_bindings_->BindTo(env->isolate(), env->process_object());
|
||||
electron_bindings_->BindTo(env->isolate(), env->process_object());
|
||||
|
||||
// Load everything.
|
||||
node_bindings_->LoadEnvironment(env);
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
namespace atom {
|
||||
|
||||
class AtomBindings;
|
||||
class ElectronBindings;
|
||||
class NodeBindings;
|
||||
|
||||
// Watches for WebWorker and insert node integration to it.
|
||||
|
@ -29,7 +29,7 @@ class WebWorkerObserver {
|
|||
~WebWorkerObserver();
|
||||
|
||||
std::unique_ptr<NodeBindings> node_bindings_;
|
||||
std::unique_ptr<AtomBindings> atom_bindings_;
|
||||
std::unique_ptr<ElectronBindings> electron_bindings_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(WebWorkerObserver);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue