Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix performance interface timing member #25205

Merged

#24468 Performance::queue_entries return the index of the added perfo…

…rmance entry
  • Loading branch information
shnmorimoto authored and jdm committed Dec 13, 2019
commit 91287216f5d9a779eabe873a5daaa753569da9bc
@@ -233,10 +233,10 @@ impl Performance {
/// <https://w3c.github.io/performance-timeline/#queue-a-performanceentry>
/// Also this algorithm has been extented according to :
/// <https://w3c.github.io/resource-timing/#sec-extensions-performance-interface>
pub fn queue_entry(&self, entry: &PerformanceEntry, add_to_performance_entries_buffer: bool) {
pub fn queue_entry(&self, entry: &PerformanceEntry) -> Option<usize> {
// https://w3c.github.io/performance-timeline/#dfn-determine-eligibility-for-adding-a-performance-entry
if entry.entry_type() == "resource" && !self.should_queue_resource_entry(entry) {
return;
return None;
}

// Steps 1-3.
@@ -253,26 +253,27 @@ impl Performance {
}

// Step 4.
// If the "add to performance entry buffer flag" is set, add the
// new entry to the buffer.
if add_to_performance_entries_buffer {
self.buffer
.borrow_mut()
.entries
.push(DomRoot::from_ref(entry));
}
//add the new entry to the buffer.
self.buffer
.borrow_mut()
.entries
.push(DomRoot::from_ref(entry));

let entry_last_index = self.buffer.borrow_mut().entries.len() - 1;

// Step 5.
// If there is already a queued notification task, we just bail out.
if self.pending_notification_observers_task.get() {
return;
return None;
}

// Step 6.
// Queue a new notification task.
self.pending_notification_observers_task.set(true);
let task_source = self.global().performance_timeline_task_source();
task_source.queue_notification(&self.global());

Some(entry_last_index)
}

/// Observers notifications task.
@@ -321,7 +322,7 @@ impl Performance {
.borrow_mut()
.pop_front();
if let Some(ref entry) = entry {
self.queue_entry(entry, true);
self.queue_entry(entry);
} else {
break;
}
@@ -438,10 +439,7 @@ impl PerformanceMethods for Performance {
// Steps 2 to 6.
let entry = PerformanceMark::new(&global, mark_name, self.now(), 0.);
// Steps 7 and 8.
self.queue_entry(
&entry.upcast::<PerformanceEntry>(),
true, /* buffer performance entry */
);
self.queue_entry(&entry.upcast::<PerformanceEntry>());

// Step 9.
Ok(())
@@ -488,10 +486,7 @@ impl PerformanceMethods for Performance {
);

// Step 9 and 10.
self.queue_entry(
&entry.upcast::<PerformanceEntry>(),
true, /* buffer performance entry */
);
self.queue_entry(&entry.upcast::<PerformanceEntry>());

// Step 11.
Ok(())
@@ -913,7 +913,7 @@ impl FetchResponseListener for ParserContext {
document
.global()
.performance()
.queue_entry(performance_entry.upcast::<PerformanceEntry>(), true);
.queue_entry(performance_entry.upcast::<PerformanceEntry>());
}
}

@@ -62,7 +62,7 @@ pub fn submit_timing_data(
PerformanceResourceTiming::new(global, url, initiator_type, None, resource_timing);
global
.performance()
.queue_entry(performance_entry.upcast::<PerformanceEntry>(), true);
.queue_entry(performance_entry.upcast::<PerformanceEntry>());
}

impl<Listener: PreInvoke + Send + 'static> NetworkListener<Listener> {
@@ -3889,10 +3889,9 @@ impl ScriptThread {
metric_type,
metric_value,
);
window.Performance().queue_entry(
&entry.upcast::<PerformanceEntry>(),
true, /* buffer performance entry */
);
window
.Performance()
.queue_entry(&entry.upcast::<PerformanceEntry>());
}
}

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.