chore: convert View APIs away from base::Bind (#18035)

This commit is contained in:
Shelley Vohr 2019-04-29 17:40:39 -07:00 committed by Cheng Zhao
parent 4a3771ff7f
commit 4ee201c56e
14 changed files with 40 additions and 32 deletions

View file

@ -1353,7 +1353,7 @@ void App::BuildPrototype(v8::Isolate* isolate,
.SetMethod("clearRecentDocuments", .SetMethod("clearRecentDocuments",
base::BindRepeating(&Browser::ClearRecentDocuments, browser)) base::BindRepeating(&Browser::ClearRecentDocuments, browser))
.SetMethod("setAppUserModelId", .SetMethod("setAppUserModelId",
base::Bind(&Browser::SetAppUserModelID, browser)) base::BindRepeating(&Browser::SetAppUserModelID, browser))
.SetMethod( .SetMethod(
"isDefaultProtocolClient", "isDefaultProtocolClient",
base::BindRepeating(&Browser::IsDefaultProtocolClient, browser)) base::BindRepeating(&Browser::IsDefaultProtocolClient, browser))

View file

@ -110,7 +110,7 @@ void NetLog::OnNewState(const base::DictionaryValue& state) {
for (auto& promise : stop_callback_queue_) { for (auto& promise : stop_callback_queue_) {
// TODO(zcbenz): Remove the use of CopyablePromise when the // TODO(zcbenz): Remove the use of CopyablePromise when the
// GetFilePathToCompletedLog API accepts OnceCallback. // GetFilePathToCompletedLog API accepts OnceCallback.
net_log_writer_->GetFilePathToCompletedLog(base::Bind( net_log_writer_->GetFilePathToCompletedLog(base::BindRepeating(
util::CopyablePromise::ResolveCopyablePromise<const base::FilePath&>, util::CopyablePromise::ResolveCopyablePromise<const base::FilePath&>,
util::CopyablePromise(promise))); util::CopyablePromise(promise)));
} }

View file

@ -37,11 +37,11 @@ namespace api {
PowerMonitor::PowerMonitor(v8::Isolate* isolate) { PowerMonitor::PowerMonitor(v8::Isolate* isolate) {
#if defined(OS_LINUX) #if defined(OS_LINUX)
SetShutdownHandler( SetShutdownHandler(base::BindRepeating(&PowerMonitor::ShouldShutdown,
base::Bind(&PowerMonitor::ShouldShutdown, base::Unretained(this))); base::Unretained(this)));
#elif defined(OS_MACOSX) #elif defined(OS_MACOSX)
Browser::Get()->SetShutdownHandler( Browser::Get()->SetShutdownHandler(base::BindRepeating(
base::Bind(&PowerMonitor::ShouldShutdown, base::Unretained(this))); &PowerMonitor::ShouldShutdown, base::Unretained(this)));
#endif #endif
base::PowerMonitor::Get()->AddObserver(this); base::PowerMonitor::Get()->AddObserver(this);
Init(isolate); Init(isolate);

View file

@ -124,8 +124,9 @@ void Initialize(v8::Local<v8::Object> exports,
void* priv) { void* priv) {
v8::Isolate* isolate = context->GetIsolate(); v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary dict(isolate, exports); mate::Dictionary dict(isolate, exports);
dict.Set("WebContentsView", mate::CreateConstructor<WebContentsView>( dict.Set("WebContentsView",
isolate, base::Bind(&WebContentsView::New))); mate::CreateConstructor<WebContentsView>(
isolate, base::BindRepeating(&WebContentsView::New)));
} }
} // namespace } // namespace

View file

@ -78,7 +78,7 @@ void Initialize(v8::Local<v8::Object> exports,
v8::Isolate* isolate = context->GetIsolate(); v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary dict(isolate, exports); mate::Dictionary dict(isolate, exports);
dict.Set("BoxLayout", mate::CreateConstructor<BoxLayout>( dict.Set("BoxLayout", mate::CreateConstructor<BoxLayout>(
isolate, base::Bind(&BoxLayout::New))); isolate, base::BindRepeating(&BoxLayout::New)));
} }
} // namespace } // namespace

View file

@ -50,8 +50,8 @@ void Initialize(v8::Local<v8::Object> exports,
void* priv) { void* priv) {
v8::Isolate* isolate = context->GetIsolate(); v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary dict(isolate, exports); mate::Dictionary dict(isolate, exports);
dict.Set("Button", dict.Set("Button", mate::CreateConstructor<Button>(
mate::CreateConstructor<Button>(isolate, base::Bind(&Button::New))); isolate, base::BindRepeating(&Button::New)));
} }
} // namespace } // namespace

View file

@ -71,7 +71,7 @@ void Initialize(v8::Local<v8::Object> exports,
v8::Isolate* isolate = context->GetIsolate(); v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary dict(isolate, exports); mate::Dictionary dict(isolate, exports);
dict.Set("LabelButton", mate::CreateConstructor<LabelButton>( dict.Set("LabelButton", mate::CreateConstructor<LabelButton>(
isolate, base::Bind(&LabelButton::New))); isolate, base::BindRepeating(&LabelButton::New)));
} }
} // namespace } // namespace

View file

@ -53,8 +53,9 @@ void Initialize(v8::Local<v8::Object> exports,
void* priv) { void* priv) {
v8::Isolate* isolate = context->GetIsolate(); v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary dict(isolate, exports); mate::Dictionary dict(isolate, exports);
dict.Set("LayoutManager", mate::CreateConstructor<LayoutManager>( dict.Set("LayoutManager",
isolate, base::Bind(&LayoutManager::New))); mate::CreateConstructor<LayoutManager>(
isolate, base::BindRepeating(&LayoutManager::New)));
} }
} // namespace } // namespace

View file

@ -47,8 +47,9 @@ void Initialize(v8::Local<v8::Object> exports,
void* priv) { void* priv) {
v8::Isolate* isolate = context->GetIsolate(); v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary dict(isolate, exports); mate::Dictionary dict(isolate, exports);
dict.Set("MdTextButton", mate::CreateConstructor<MdTextButton>( dict.Set("MdTextButton",
isolate, base::Bind(&MdTextButton::New))); mate::CreateConstructor<MdTextButton>(
isolate, base::BindRepeating(&MdTextButton::New)));
} }
} // namespace } // namespace

View file

@ -51,7 +51,7 @@ void Initialize(v8::Local<v8::Object> exports,
v8::Isolate* isolate = context->GetIsolate(); v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary dict(isolate, exports); mate::Dictionary dict(isolate, exports);
dict.Set("ResizeArea", mate::CreateConstructor<ResizeArea>( dict.Set("ResizeArea", mate::CreateConstructor<ResizeArea>(
isolate, base::Bind(&ResizeArea::New))); isolate, base::BindRepeating(&ResizeArea::New)));
} }
} // namespace } // namespace

View file

@ -58,7 +58,7 @@ void Initialize(v8::Local<v8::Object> exports,
v8::Isolate* isolate = context->GetIsolate(); v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary dict(isolate, exports); mate::Dictionary dict(isolate, exports);
dict.Set("TextField", mate::CreateConstructor<TextField>( dict.Set("TextField", mate::CreateConstructor<TextField>(
isolate, base::Bind(&TextField::New))); isolate, base::BindRepeating(&TextField::New)));
} }
} // namespace } // namespace

View file

@ -52,16 +52,19 @@ void Initialize(v8::Local<v8::Object> exports,
void* priv) { void* priv) {
mate::Dictionary dict(context->GetIsolate(), exports); mate::Dictionary dict(context->GetIsolate(), exports);
auto reporter = base::Unretained(CrashReporter::GetInstance()); auto reporter = base::Unretained(CrashReporter::GetInstance());
dict.SetMethod("start", base::Bind(&CrashReporter::Start, reporter)); dict.SetMethod("start", base::BindRepeating(&CrashReporter::Start, reporter));
dict.SetMethod("addExtraParameter", &AddExtraParameter); dict.SetMethod("addExtraParameter", &AddExtraParameter);
dict.SetMethod("removeExtraParameter", &RemoveExtraParameter); dict.SetMethod("removeExtraParameter", &RemoveExtraParameter);
dict.SetMethod("getParameters", &GetParameters); dict.SetMethod("getParameters", &GetParameters);
dict.SetMethod("getUploadedReports", dict.SetMethod(
base::Bind(&CrashReporter::GetUploadedReports, reporter)); "getUploadedReports",
dict.SetMethod("setUploadToServer", base::BindRepeating(&CrashReporter::GetUploadedReports, reporter));
base::Bind(&CrashReporter::SetUploadToServer, reporter)); dict.SetMethod(
dict.SetMethod("getUploadToServer", "setUploadToServer",
base::Bind(&CrashReporter::GetUploadToServer, reporter)); base::BindRepeating(&CrashReporter::SetUploadToServer, reporter));
dict.SetMethod(
"getUploadToServer",
base::BindRepeating(&CrashReporter::GetUploadToServer, reporter));
} }
} // namespace } // namespace

View file

@ -73,7 +73,8 @@ void ElectronBindings::BindProcess(v8::Isolate* isolate,
process->SetMethod("getSystemVersion", process->SetMethod("getSystemVersion",
&base::SysInfo::OperatingSystemVersion); &base::SysInfo::OperatingSystemVersion);
process->SetMethod("getIOCounters", &GetIOCounters); process->SetMethod("getIOCounters", &GetIOCounters);
process->SetMethod("getCPUUsage", base::Bind(&ElectronBindings::GetCPUUsage, process->SetMethod("getCPUUsage",
base::BindRepeating(&ElectronBindings::GetCPUUsage,
base::Unretained(metrics))); base::Unretained(metrics)));
#if defined(MAS_BUILD) #if defined(MAS_BUILD)
@ -97,7 +98,8 @@ void ElectronBindings::BindTo(v8::Isolate* isolate,
#if defined(OS_POSIX) #if defined(OS_POSIX)
dict.SetMethod("setFdLimit", &base::IncreaseFdLimitTo); dict.SetMethod("setFdLimit", &base::IncreaseFdLimitTo);
#endif #endif
dict.SetMethod("activateUvLoop", base::Bind(&ElectronBindings::ActivateUVLoop, dict.SetMethod("activateUvLoop",
base::BindRepeating(&ElectronBindings::ActivateUVLoop,
base::Unretained(this))); base::Unretained(this)));
mate::Dictionary versions; mate::Dictionary versions;

View file

@ -134,9 +134,9 @@ void RendererClientBase::AddRenderBindings(
v8::Isolate* isolate, v8::Isolate* isolate,
v8::Local<v8::Object> binding_object) { v8::Local<v8::Object> binding_object) {
mate::Dictionary dict(isolate, binding_object); mate::Dictionary dict(isolate, binding_object);
dict.SetMethod( dict.SetMethod("getRenderProcessPreferences",
"getRenderProcessPreferences", base::BindRepeating(GetRenderProcessPreferences,
base::Bind(GetRenderProcessPreferences, preferences_manager_.get())); preferences_manager_.get()));
} }
void RendererClientBase::RenderThreadStarted() { void RendererClientBase::RenderThreadStarted() {