|
6 | 6 | crate::fuchsia::{ |
7 | 7 | epochs::{Epochs, RefGuard}, |
8 | 8 | errors::map_to_status, |
9 | | - fxblob::blob::FxBlob, |
10 | 9 | node::FxNode, |
11 | 10 | profile::Recorder, |
12 | 11 | }, |
@@ -166,7 +165,7 @@ pub struct Pager { |
166 | 165 | // need to wait for page requests for the specific file being flushed, but we should see if we |
167 | 166 | // need to for performance reasons first. |
168 | 167 | epochs: Arc<Epochs>, |
169 | | - recorder: Mutex<Option<Recorder>>, |
| 168 | + recorder: Mutex<Option<Box<dyn Recorder>>>, |
170 | 169 | } |
171 | 170 |
|
172 | 171 | // FileHolder is used to retain either a strong or a weak reference to a file. If there are any |
@@ -202,25 +201,23 @@ impl Pager { |
202 | 201 | } |
203 | 202 |
|
204 | 203 | /// Set the current profile recorder, or set to None to not record. |
205 | | - pub fn set_recorder(&self, recorder: Option<Recorder>) { |
| 204 | + pub fn set_recorder(&self, recorder: Option<Box<dyn Recorder>>) { |
206 | 205 | // Drop the old one outside of the lock. |
207 | 206 | let _ = std::mem::replace(&mut (*self.recorder.lock().unwrap()), recorder); |
208 | 207 | } |
209 | 208 |
|
210 | 209 | /// Borrow the profile recorder. Used to record file opens. |
211 | | - pub fn recorder(&self) -> MutexGuard<'_, Option<Recorder>> { |
| 210 | + pub fn recorder(&self) -> MutexGuard<'_, Option<Box<dyn Recorder>>> { |
212 | 211 | self.recorder.lock().unwrap() |
213 | 212 | } |
214 | 213 |
|
215 | 214 | /// Record a range into a profile if one is being recorded. |
216 | 215 | pub fn record_page_in<P: PagerBacked>(&self, node: Arc<P>, range: Range<u64>) { |
217 | | - if let Ok(blob) = node.into_any().downcast::<FxBlob>() { |
218 | | - let mut recorder_holder = self.recorder.lock().unwrap(); |
219 | | - if let Some(recorder) = &mut (*recorder_holder) { |
220 | | - // If the message fails to send, so will all the rest. |
221 | | - if let Err(_) = recorder.record(&blob.root(), range.start) { |
222 | | - *recorder_holder = None; |
223 | | - } |
| 216 | + let mut recorder_holder = self.recorder.lock().unwrap(); |
| 217 | + if let Some(recorder) = &mut (*recorder_holder) { |
| 218 | + // If the message fails to send, so will all the rest. |
| 219 | + if let Err(_) = recorder.record(node, range.start) { |
| 220 | + *recorder_holder = None; |
224 | 221 | } |
225 | 222 | } |
226 | 223 | } |
|
0 commit comments