Extract user_agent from global opts

This commit is contained in:
Utsav Oza 2020-04-03 20:48:37 +05:30
parent 50ea9fc02d
commit 2c306227e9
9 changed files with 108 additions and 75 deletions

View file

@ -166,7 +166,7 @@ use servo_config::{opts, pref};
use servo_rand::{random, Rng, ServoRng, SliceRandom};
use servo_remutex::ReentrantMutex;
use servo_url::{Host, ImmutableOrigin, ServoUrl};
use std::borrow::ToOwned;
use std::borrow::{Cow, ToOwned};
use std::collections::hash_map::Entry;
use std::collections::{HashMap, HashSet, VecDeque};
use std::marker::PhantomData;
@ -503,6 +503,9 @@ pub struct Constellation<Message, LTF, STF, SWF> {
/// Pipeline ID of the active media session.
active_media_session: Option<PipelineId>,
/// User agent string to report in network requests.
user_agent: Cow<'static, str>,
}
/// State needed to construct a constellation.
@ -562,6 +565,9 @@ pub struct InitialConstellationState {
/// A flag share with the compositor to indicate that a WR frame is in progress.
pub pending_wr_frame: Arc<AtomicBool>,
/// User agent string to report in network requests.
pub user_agent: Cow<'static, str>,
}
/// Data needed for webdriver
@ -1021,6 +1027,7 @@ where
player_context: state.player_context,
event_loop_waker: state.event_loop_waker,
active_media_session: None,
user_agent: state.user_agent,
};
constellation.run();
@ -1268,6 +1275,7 @@ where
webxr_registry: self.webxr_registry.clone(),
player_context: self.player_context.clone(),
event_loop_waker: self.event_loop_waker.as_ref().map(|w| (*w).clone_box()),
user_agent: self.user_agent.clone(),
});
let pipeline = match result {