Skip to content

Commit

Permalink
Fix link and script element resource timing issue.
Browse files Browse the repository at this point in the history
b/194344538

Change-Id: Ic88b36cbc520cd771bbe122e1eabb47d3cd671e5
(cherry picked from commit 1a454569fe6ebf9c2d4427b2f2ffe07916c6f4d8)
  • Loading branch information
Cobalt Team committed Jul 22, 2021
1 parent e443819 commit faa8e07
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions cobalt/dom/html_link_element.cc
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,9 @@ void HTMLLinkElement::OnContentProduced(const loader::Origin& last_url_origin,

void HTMLLinkElement::OnLoadingComplete(
const base::Optional<std::string>& error) {
// GetLoadTimingInfo and create resource timing before loader released.
GetLoadTimingInfoAndCreateResourceTiming();

base::MessageLoop::current()->task_runner()->PostTask(
FROM_HERE, base::Bind(&HTMLLinkElement::ReleaseLoader, this));

Expand All @@ -279,9 +282,6 @@ void HTMLLinkElement::OnLoadingComplete(
// complete.
node_document()->DecreaseLoadingCounterAndMaybeDispatchLoadEvent();
}

// GetLoadTimingInfo and create resource timing before loader released.
GetLoadTimingInfoAndCreateResourceTiming();
}

void HTMLLinkElement::OnSplashscreenLoaded(Document* document,
Expand Down
6 changes: 3 additions & 3 deletions cobalt/dom/html_script_element.cc
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,9 @@ void HTMLScriptElement::OnContentProduced(
// https://www.w3.org/TR/html50/scripting-1.html#prepare-a-script
void HTMLScriptElement::OnLoadingComplete(
const base::Optional<std::string>& error) {
// GetLoadTimingInfo and create resource timing before loader released.
GetLoadTimingInfoAndCreateResourceTiming();

if (!error) return;

DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
Expand Down Expand Up @@ -596,9 +599,6 @@ void HTMLScriptElement::OnLoadingComplete(
// once the resource has been fetched (defined above) has been run.
document_->DecreaseLoadingCounterAndMaybeDispatchLoadEvent();

// GetLoadTimingInfo and create resource timing before loader released.
GetLoadTimingInfoAndCreateResourceTiming();

// Post a task to release the loader.
base::MessageLoop::current()->task_runner()->PostTask(
FROM_HERE, base::Bind(&HTMLScriptElement::ReleaseLoader, this));
Expand Down

0 comments on commit faa8e07

Please sign in to comment.