aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShinichi Morimoto <shnmorimoto@gmail.com>2019-12-08 00:34:02 +0900
committerJosh Matthews <josh@joshmatthews.net>2019-12-13 13:41:47 -0500
commit91287216f5d9a779eabe873a5daaa753569da9bc (patch)
tree204472b82c0b6389a1cfdaa33f986c5516a41676
parentfaee09ffa9f6adb30593fec32904aa352e58c6ee (diff)
downloadservo-91287216f5d9a779eabe873a5daaa753569da9bc.tar.gz
servo-91287216f5d9a779eabe873a5daaa753569da9bc.zip
#24468 Performance::queue_entries return the index of the added performance entry
-rw-r--r--components/script/dom/performance.rs35
-rw-r--r--components/script/dom/servoparser/mod.rs2
-rw-r--r--components/script/network_listener.rs2
-rw-r--r--components/script/script_thread.rs7
4 files changed, 20 insertions, 26 deletions
diff --git a/components/script/dom/performance.rs b/components/script/dom/performance.rs
index 6c418b44316..efba383646d 100644
--- a/components/script/dom/performance.rs
+++ b/components/script/dom/performance.rs
@@ -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,19 +253,18 @@ 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.
@@ -273,6 +272,8 @@ impl Performance {
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(())
diff --git a/components/script/dom/servoparser/mod.rs b/components/script/dom/servoparser/mod.rs
index 0258a068c0f..6c8b8ede013 100644
--- a/components/script/dom/servoparser/mod.rs
+++ b/components/script/dom/servoparser/mod.rs
@@ -913,7 +913,7 @@ impl FetchResponseListener for ParserContext {
document
.global()
.performance()
- .queue_entry(performance_entry.upcast::<PerformanceEntry>(), true);
+ .queue_entry(performance_entry.upcast::<PerformanceEntry>());
}
}
diff --git a/components/script/network_listener.rs b/components/script/network_listener.rs
index 699a8e70f72..29c43450aac 100644
--- a/components/script/network_listener.rs
+++ b/components/script/network_listener.rs
@@ -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> {
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs
index 1373896cdff..64fd85b210b 100644
--- a/components/script/script_thread.rs
+++ b/components/script/script_thread.rs
@@ -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>());
}
}