Better clarity and fix typo

This commit is contained in:
Cheng Zhao 2018-02-23 09:15:13 +09:00
parent 816a96c2cc
commit 3be92f550c
2 changed files with 10 additions and 10 deletions

View file

@ -136,8 +136,8 @@ void BrowserWindow::Init(v8::Isolate* isolate,
mate::Handle<class WebContents> web_contents) { mate::Handle<class WebContents> web_contents) {
web_contents_.Reset(isolate, web_contents.ToV8()); web_contents_.Reset(isolate, web_contents.ToV8());
api_web_contents_ = web_contents.get(); api_web_contents_ = web_contents.get();
Observe(web_contents->web_contents());
api_web_contents_->AddObserver(this); api_web_contents_->AddObserver(this);
Observe(api_web_contents_->web_contents());
// Keep a copy of the options for later use. // Keep a copy of the options for later use.
mate::Dictionary(isolate, web_contents->GetWrapper()).Set( mate::Dictionary(isolate, web_contents->GetWrapper()).Set(
@ -248,7 +248,7 @@ void BrowserWindow::DidFirstVisuallyNonEmptyPaint() {
void BrowserWindow::BeforeUnloadDialogCancelled() { void BrowserWindow::BeforeUnloadDialogCancelled() {
WindowList::WindowCloseCancelled(window_.get()); WindowList::WindowCloseCancelled(window_.get());
// Cancel unresponsive event when window close is cancelled. // Cancel unresponsive event when window close is cancelled.
window_unresposive_closure_.Cancel(); window_unresponsive_closure_.Cancel();
} }
void BrowserWindow::OnRendererUnresponsive(content::RenderWidgetHost*) { void BrowserWindow::OnRendererUnresponsive(content::RenderWidgetHost*) {
@ -295,11 +295,11 @@ void BrowserWindow::OnCloseContents() {
window_->CloseImmediately(); window_->CloseImmediately();
// Do not sent "unresponsive" event after window is closed. // Do not sent "unresponsive" event after window is closed.
window_unresposive_closure_.Cancel(); window_unresponsive_closure_.Cancel();
} }
void BrowserWindow::OnRendererResponsive() { void BrowserWindow::OnRendererResponsive() {
window_unresposive_closure_.Cancel(); window_unresponsive_closure_.Cancel();
Emit("responsive"); Emit("responsive");
} }
@ -317,7 +317,7 @@ void BrowserWindow::OnCloseButtonClicked(bool* prevent_default) {
// not closed in 5s, in this way we can quickly show the unresponsive // not closed in 5s, in this way we can quickly show the unresponsive
// dialog when the window is busy executing some script withouth waiting for // dialog when the window is busy executing some script withouth waiting for
// the unresponsive timeout. // the unresponsive timeout.
if (window_unresposive_closure_.IsCancelled()) if (window_unresponsive_closure_.IsCancelled())
ScheduleUnresponsiveEvent(5000); ScheduleUnresponsiveEvent(5000);
if (!web_contents()) if (!web_contents())
@ -1139,19 +1139,19 @@ void BrowserWindow::UpdateDraggableRegions(
} }
void BrowserWindow::ScheduleUnresponsiveEvent(int ms) { void BrowserWindow::ScheduleUnresponsiveEvent(int ms) {
if (!window_unresposive_closure_.IsCancelled()) if (!window_unresponsive_closure_.IsCancelled())
return; return;
window_unresposive_closure_.Reset( window_unresponsive_closure_.Reset(
base::Bind(&BrowserWindow::NotifyWindowUnresponsive, GetWeakPtr())); base::Bind(&BrowserWindow::NotifyWindowUnresponsive, GetWeakPtr()));
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, FROM_HERE,
window_unresposive_closure_.callback(), window_unresponsive_closure_.callback(),
base::TimeDelta::FromMilliseconds(ms)); base::TimeDelta::FromMilliseconds(ms));
} }
void BrowserWindow::NotifyWindowUnresponsive() { void BrowserWindow::NotifyWindowUnresponsive() {
window_unresposive_closure_.Cancel(); window_unresponsive_closure_.Cancel();
if (!window_->IsClosed() && window_->IsEnabled() && if (!window_->IsClosed() && window_->IsEnabled() &&
!IsUnresponsiveEventSuppressed()) { !IsUnresponsiveEventSuppressed()) {
Emit("unresponsive"); Emit("unresponsive");

View file

@ -273,7 +273,7 @@ class BrowserWindow : public mate::TrackableObject<BrowserWindow>,
// Closure that would be called when window is unresponsive when closing, // Closure that would be called when window is unresponsive when closing,
// it should be cancelled when we can prove that the window is responsive. // it should be cancelled when we can prove that the window is responsive.
base::CancelableClosure window_unresposive_closure_; base::CancelableClosure window_unresponsive_closure_;
v8::Global<v8::Value> browser_view_; v8::Global<v8::Value> browser_view_;
v8::Global<v8::Value> web_contents_; v8::Global<v8::Value> web_contents_;