Repository: servo/servo
File: ports/servoshell/egl/app.rs (Rust)

Code before:
    fn notify_media_session_event(&self, event: MediaSessionEvent) {
        match event {
            MediaSessionEvent::SetMetadata(metadata) => {
                self.host
                    .on_media_session_metadata(metadata.title, metadata.artist, metadata.album)
            },
            MediaSessionEvent::PlaybackStateChange(state) => {
                self.host.on_media_session_playback_state_change(state)
            },
            MediaSessionEvent::SetPositionState(position_state) => {
                self.host.on_media_session_set_position_state(
                    position_state.duration,
                    position_state.position,
                    position_state.playback_rate,
                )
            },
        };
    }

    fn notify_crashed(&self, _webview: WebView, reason: String, backtrace: Option<String>) {
        self.host.on_panic(reason, backtrace);
    }

    fn show_console_message(&self, level: servo::ConsoleLogLevel, message: &str) {
        // On embedded platforms, use logger only
        log::log!(level.into(), "{}", message);
    }
}

#[derive(Default)]
pub(crate) struct VsyncRefreshDriver {
    start_frame_callbacks: RefCell<Vec<Box<dyn Fn() + Send>>>,
}

impl VsyncRefreshDriver {
    fn notify_vsync(&self) {
        let start_frame_callbacks: Vec<_> =
            self.start_frame_callbacks.borrow_mut().drain(..).collect();
        for start_frame_callback in start_frame_callbacks {
            start_frame_callback()
        }
    }
}

impl RefreshDriver for VsyncRefreshDriver {
    fn observe_next_frame(&self, new_start_frame_callback: Box<dyn Fn() + Send + 'static>) {
        self.start_frame_callbacks
            .borrow_mut()
            .push(new_start_frame_callback);
    }
}

Review comment (suggestion):
```suggestion
        log::log!(level.into(), "{message}");
```

Code after:
    fn notify_media_session_event(&self, event: MediaSessionEvent) {
        match event {
            MediaSessionEvent::SetMetadata(metadata) => {
                self.host
                    .on_media_session_metadata(metadata.title, metadata.artist, metadata.album)
            },
            MediaSessionEvent::PlaybackStateChange(state) => {
                self.host.on_media_session_playback_state_change(state)
            },
            MediaSessionEvent::SetPositionState(position_state) => {
                self.host.on_media_session_set_position_state(
                    position_state.duration,
                    position_state.position,
                    position_state.playback_rate,
                )
            },
        };
    }

    fn notify_crashed(&self, _webview: WebView, reason: String, backtrace: Option<String>) {
        self.host.on_panic(reason, backtrace);
    }

    fn show_console_message(&self, level: servo::ConsoleLogLevel, message: &str) {
        log::log!(level.into(), "{message}");
    }
}

#[derive(Default)]
pub(crate) struct VsyncRefreshDriver {
    start_frame_callbacks: RefCell<Vec<Box<dyn Fn() + Send>>>,
}

impl VsyncRefreshDriver {
    fn notify_vsync(&self) {
        let start_frame_callbacks: Vec<_> =
            self.start_frame_callbacks.borrow_mut().drain(..).collect();
        for start_frame_callback in start_frame_callbacks {
            start_frame_callback()
        }
    }
}

impl RefreshDriver for VsyncRefreshDriver {
    fn observe_next_frame(&self, new_start_frame_callback: Box<dyn Fn() + Send + 'static>) {
        self.start_frame_callbacks
            .borrow_mut()
            .push(new_start_frame_callback);
    }
}