Commit dfc86cf5 authored by John Chen's avatar John Chen Committed by Commit Bot

[ChromeDriver] Avoid deallocating WebView still in use

While dispatching an event to a child frame, place a hold on the WebView
of the child frame to prevent it from getting deallocated.

Bug: chromedriver:3375
Change-Id: I0ff52f6476a2e6767d27c0755a012bdf16dc9c77
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2097538Reviewed-by: default avatarCaleb Rouleau <crouleau@chromium.org>
Commit-Queue: John Chen <johnchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#749276}
parent 68d0d7f5
......@@ -498,6 +498,7 @@ Status DevToolsClientImpl::HandleMessage(int expected_id,
}
client = it->second;
}
WebViewImplHolder client_holder(client->owner_);
if (type == internal::kEventMessageType) {
return client->ProcessEvent(event);
}
......
......@@ -1201,7 +1201,7 @@ std::unique_ptr<base::Value> WebViewImpl::GetCastIssueMessage() {
}
WebViewImplHolder::WebViewImplHolder(WebViewImpl* web_view)
: web_view_(web_view), was_locked_(web_view->Lock()) {}
: web_view_(web_view), was_locked_(web_view && web_view->Lock()) {}
WebViewImplHolder::~WebViewImplHolder() {
if (web_view_ != nullptr && !was_locked_) {
......
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