diff options
Diffstat (limited to 'components/script/layout_interface.rs')
-rw-r--r-- | components/script/layout_interface.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/components/script/layout_interface.rs b/components/script/layout_interface.rs index e6e448dd800..52b5aed1b43 100644 --- a/components/script/layout_interface.rs +++ b/components/script/layout_interface.rs @@ -13,6 +13,7 @@ use geom::rect::Rect; use script_traits::{ScriptControlChan, OpaqueScriptLayoutChannel, UntrustedNodeAddress}; use msg::constellation_msg::{PipelineExitType, WindowSizeData}; use util::geometry::Au; +use util::memory::{MemoryReporter, MemoryReportsChan}; use std::any::Any; use std::sync::mpsc::{channel, Receiver, Sender}; use std::boxed::BoxAny; @@ -44,6 +45,10 @@ pub enum Msg { /// TODO(pcwalton): Maybe think about batching to avoid message traffic. ReapLayoutData(LayoutData), + /// Requests that the layout task measure its memory usage. The resulting reports are sent back + /// via the supplied channel. + CollectMemoryReports(MemoryReportsChan), + /// Requests that the layout task enter a quiescent state in which no more messages are /// accepted except `ExitMsg`. A response message will be sent on the supplied channel when /// this happens. @@ -128,6 +133,14 @@ impl LayoutChan { } } +impl MemoryReporter for LayoutChan { + // Just injects an appropriate event into the layout task's queue. + fn collect_reports(&self, reports_chan: MemoryReportsChan) -> bool { + let LayoutChan(ref c) = *self; + c.send(Msg::CollectMemoryReports(reports_chan)).is_ok() + } +} + /// A trait to manage opaque references to script<->layout channels without needing /// to expose the message type to crates that don't need to know about them. pub trait ScriptLayoutChan { |