Commit 0d53513f authored by Pavel Feldman's avatar Pavel Feldman Committed by Commit Bot

Headless: don't run unload hooks upon web contents close.

Change-Id: I6e391fadbbf47aa6427a16495bdca3c88d456b05
Reviewed-on: https://chromium-review.googlesource.com/1105041Reviewed-by: default avatarDmitry Gozman <dgozman@chromium.org>
Commit-Queue: Pavel Feldman <pfeldman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568213}
parent 149266a4
...@@ -95,7 +95,7 @@ class HeadlessWebContentsImpl::Delegate : public content::WebContentsDelegate { ...@@ -95,7 +95,7 @@ class HeadlessWebContentsImpl::Delegate : public content::WebContentsDelegate {
auto* const headless_contents = auto* const headless_contents =
HeadlessWebContentsImpl::From(browser(), source); HeadlessWebContentsImpl::From(browser(), source);
DCHECK(headless_contents); DCHECK(headless_contents);
headless_contents->DelegateRequestsClose(); headless_contents->Close();
} }
void AddNewContents(content::WebContents* source, void AddNewContents(content::WebContents* source,
...@@ -379,29 +379,9 @@ bool HeadlessWebContentsImpl::OpenURL(const GURL& url) { ...@@ -379,29 +379,9 @@ bool HeadlessWebContentsImpl::OpenURL(const GURL& url) {
void HeadlessWebContentsImpl::Close() { void HeadlessWebContentsImpl::Close() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
if (quit_closure_)
return;
if (!render_process_exited_) {
web_contents_->ClosePage();
base::RunLoop run_loop(base::RunLoop::Type::kNestableTasksAllowed);
quit_closure_ = run_loop.QuitClosure();
run_loop.Run();
}
browser_context()->DestroyWebContents(this); browser_context()->DestroyWebContents(this);
} }
void HeadlessWebContentsImpl::DelegateRequestsClose() {
if (quit_closure_) {
quit_closure_.Run();
quit_closure_ = base::Closure();
} else {
browser_context()->DestroyWebContents(this);
}
}
std::string HeadlessWebContentsImpl::GetDevToolsAgentHostId() { std::string HeadlessWebContentsImpl::GetDevToolsAgentHostId() {
return agent_host_->GetId(); return agent_host_->GetId();
} }
......
...@@ -99,8 +99,6 @@ class HEADLESS_EXPORT HeadlessWebContentsImpl ...@@ -99,8 +99,6 @@ class HEADLESS_EXPORT HeadlessWebContentsImpl
void Close() override; void Close() override;
void DelegateRequestsClose();
std::string GetDevToolsAgentHostId(); std::string GetDevToolsAgentHostId();
HeadlessBrowserImpl* browser() const; HeadlessBrowserImpl* browser() const;
...@@ -178,8 +176,6 @@ class HEADLESS_EXPORT HeadlessWebContentsImpl ...@@ -178,8 +176,6 @@ class HEADLESS_EXPORT HeadlessWebContentsImpl
base::ObserverList<HeadlessWebContents::Observer> observers_; base::ObserverList<HeadlessWebContents::Observer> observers_;
base::Closure quit_closure_;
base::WeakPtrFactory<HeadlessWebContentsImpl> weak_ptr_factory_; base::WeakPtrFactory<HeadlessWebContentsImpl> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(HeadlessWebContentsImpl); DISALLOW_COPY_AND_ASSIGN(HeadlessWebContentsImpl);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment