Consolidate ProfilerMetadata and TimerMetadata.

There is no good reason to have the two types.

This also means that the result of LayoutTask::profiler_metadata no longer
borrows the LayoutTask, which I'll need later.
This commit is contained in:
Ms2ger 2015-11-06 13:10:37 +01:00
parent 3780fb7fe0
commit ff0acccc06
8 changed files with 28 additions and 37 deletions

View file

@ -3,18 +3,16 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
extern crate time as std_time;
extern crate url;
use energy::read_energy_uj;
use ipc_channel::ipc::IpcSender;
use self::std_time::precise_time_ns;
use self::url::Url;
#[derive(PartialEq, Clone, PartialOrd, Eq, Ord, Deserialize, Serialize)]
pub struct TimerMetadata {
pub url: String,
pub iframe: bool,
pub incremental: bool,
pub iframe: TimerMetadataFrameType,
pub incremental: TimerMetadataReflowType,
}
#[derive(Clone, Deserialize, Serialize)]
@ -77,23 +75,20 @@ pub enum ProfilerCategory {
ApplicationHeartbeat,
}
#[derive(Eq, PartialEq)]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize)]
pub enum TimerMetadataFrameType {
RootWindow,
IFrame,
}
#[derive(Eq, PartialEq)]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize)]
pub enum TimerMetadataReflowType {
Incremental,
FirstReflow,
}
pub type ProfilerMetadata<'a> =
Option<(&'a Url, TimerMetadataFrameType, TimerMetadataReflowType)>;
pub fn profile<T, F>(category: ProfilerCategory,
meta: ProfilerMetadata,
meta: Option<TimerMetadata>,
profiler_chan: ProfilerChan,
callback: F)
-> T
@ -104,12 +99,6 @@ pub fn profile<T, F>(category: ProfilerCategory,
let val = callback();
let end_time = precise_time_ns();
let end_energy = read_energy_uj();
let meta = meta.map(|(url, iframe, reflow_type)|
TimerMetadata {
url: url.serialize(),
iframe: iframe == TimerMetadataFrameType::IFrame,
incremental: reflow_type == TimerMetadataReflowType::Incremental,
});
profiler_chan.send(ProfilerMsg::Time((category, meta),
(start_time, end_time),
(start_energy, end_energy)));