mirror of
https://github.com/servo/servo.git
synced 2025-08-02 04:00:32 +01:00
#24468 Performance::queue_entries return the index of the added performance entry
This commit is contained in:
parent
faee09ffa9
commit
91287216f5
4 changed files with 20 additions and 26 deletions
|
@ -233,10 +233,10 @@ impl Performance {
|
||||||
/// <https://w3c.github.io/performance-timeline/#queue-a-performanceentry>
|
/// <https://w3c.github.io/performance-timeline/#queue-a-performanceentry>
|
||||||
/// Also this algorithm has been extented according to :
|
/// Also this algorithm has been extented according to :
|
||||||
/// <https://w3c.github.io/resource-timing/#sec-extensions-performance-interface>
|
/// <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
|
// 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) {
|
if entry.entry_type() == "resource" && !self.should_queue_resource_entry(entry) {
|
||||||
return;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Steps 1-3.
|
// Steps 1-3.
|
||||||
|
@ -253,19 +253,18 @@ impl Performance {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 4.
|
// Step 4.
|
||||||
// If the "add to performance entry buffer flag" is set, add the
|
//add the new entry to the buffer.
|
||||||
// new entry to the buffer.
|
|
||||||
if add_to_performance_entries_buffer {
|
|
||||||
self.buffer
|
self.buffer
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.entries
|
.entries
|
||||||
.push(DomRoot::from_ref(entry));
|
.push(DomRoot::from_ref(entry));
|
||||||
}
|
|
||||||
|
let entry_last_index = self.buffer.borrow_mut().entries.len() - 1;
|
||||||
|
|
||||||
// Step 5.
|
// Step 5.
|
||||||
// If there is already a queued notification task, we just bail out.
|
// If there is already a queued notification task, we just bail out.
|
||||||
if self.pending_notification_observers_task.get() {
|
if self.pending_notification_observers_task.get() {
|
||||||
return;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 6.
|
// Step 6.
|
||||||
|
@ -273,6 +272,8 @@ impl Performance {
|
||||||
self.pending_notification_observers_task.set(true);
|
self.pending_notification_observers_task.set(true);
|
||||||
let task_source = self.global().performance_timeline_task_source();
|
let task_source = self.global().performance_timeline_task_source();
|
||||||
task_source.queue_notification(&self.global());
|
task_source.queue_notification(&self.global());
|
||||||
|
|
||||||
|
Some(entry_last_index)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Observers notifications task.
|
/// Observers notifications task.
|
||||||
|
@ -321,7 +322,7 @@ impl Performance {
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.pop_front();
|
.pop_front();
|
||||||
if let Some(ref entry) = entry {
|
if let Some(ref entry) = entry {
|
||||||
self.queue_entry(entry, true);
|
self.queue_entry(entry);
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -438,10 +439,7 @@ impl PerformanceMethods for Performance {
|
||||||
// Steps 2 to 6.
|
// Steps 2 to 6.
|
||||||
let entry = PerformanceMark::new(&global, mark_name, self.now(), 0.);
|
let entry = PerformanceMark::new(&global, mark_name, self.now(), 0.);
|
||||||
// Steps 7 and 8.
|
// Steps 7 and 8.
|
||||||
self.queue_entry(
|
self.queue_entry(&entry.upcast::<PerformanceEntry>());
|
||||||
&entry.upcast::<PerformanceEntry>(),
|
|
||||||
true, /* buffer performance entry */
|
|
||||||
);
|
|
||||||
|
|
||||||
// Step 9.
|
// Step 9.
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -488,10 +486,7 @@ impl PerformanceMethods for Performance {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Step 9 and 10.
|
// Step 9 and 10.
|
||||||
self.queue_entry(
|
self.queue_entry(&entry.upcast::<PerformanceEntry>());
|
||||||
&entry.upcast::<PerformanceEntry>(),
|
|
||||||
true, /* buffer performance entry */
|
|
||||||
);
|
|
||||||
|
|
||||||
// Step 11.
|
// Step 11.
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -913,7 +913,7 @@ impl FetchResponseListener for ParserContext {
|
||||||
document
|
document
|
||||||
.global()
|
.global()
|
||||||
.performance()
|
.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);
|
PerformanceResourceTiming::new(global, url, initiator_type, None, resource_timing);
|
||||||
global
|
global
|
||||||
.performance()
|
.performance()
|
||||||
.queue_entry(performance_entry.upcast::<PerformanceEntry>(), true);
|
.queue_entry(performance_entry.upcast::<PerformanceEntry>());
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Listener: PreInvoke + Send + 'static> NetworkListener<Listener> {
|
impl<Listener: PreInvoke + Send + 'static> NetworkListener<Listener> {
|
||||||
|
|
|
@ -3889,10 +3889,9 @@ impl ScriptThread {
|
||||||
metric_type,
|
metric_type,
|
||||||
metric_value,
|
metric_value,
|
||||||
);
|
);
|
||||||
window.Performance().queue_entry(
|
window
|
||||||
&entry.upcast::<PerformanceEntry>(),
|
.Performance()
|
||||||
true, /* buffer performance entry */
|
.queue_entry(&entry.upcast::<PerformanceEntry>());
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue