Commit 34b0d610 authored by Brandon Walderman's avatar Brandon Walderman Committed by Commit Bot

Check status of GetWebViewsInfo on new session

GetWebViewsInfo returns a Status so its value should be checked during
WaitForDevToolsAndCheckVersion and propagated to the client in case of
failure.

Also attempting to improve reliability by always trying GetWebViewsInfo
at least once, even if the deadline is reached. It is possible for the
call to DevToolsHttpClient::Init to exceed the deadline but return an
OK status. If this happens, we currently return an error even though
GetWebViewsInfo would likely succeed as well.

Bug: 951876
Change-Id: I1623919b22a07f5e4d5b9ea3141e18e6b07d9935
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1851912Reviewed-by: default avatarJohn Chen <johnchen@chromium.org>
Commit-Queue: Brandon Walderman <brwalder@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#704672}
parent 67bd0961
......@@ -237,9 +237,10 @@ Status WaitForDevToolsAndCheckVersion(
std::move(window_types), capabilities->page_load_strategy));
}
base::TimeTicks deadline =
base::TimeTicks::Now() + base::TimeDelta::FromSeconds(wait_time);
Status status = client->Init(deadline - base::TimeTicks::Now());
const base::TimeTicks initial = base::TimeTicks::Now();
const base::TimeTicks deadline =
initial + base::TimeDelta::FromSeconds(wait_time);
Status status = client->Init(deadline - initial);
if (status.IsError())
return status;
......@@ -281,9 +282,13 @@ Status WaitForDevToolsAndCheckVersion(
}
}
while (base::TimeTicks::Now() < deadline) {
// Always try GetWebViewsInfo at least once if the client
// initialized successfully.
do {
WebViewsInfo views_info;
client->GetWebViewsInfo(&views_info);
status = client->GetWebViewsInfo(&views_info);
if (status.IsError())
return status;
for (size_t i = 0; i < views_info.GetSize(); ++i) {
if (views_info.Get(i).type == WebViewInfo::kPage) {
*user_client = std::move(client);
......@@ -291,7 +296,8 @@ Status WaitForDevToolsAndCheckVersion(
}
}
base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(50));
}
} while (base::TimeTicks::Now() < deadline);
return Status(kUnknownError, "unable to discover open pages");
}
......
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