diff options
author | Utsav Oza <utsavoza96@gmail.com> | 2020-04-03 20:48:37 +0530 |
---|---|---|
committer | Utsav Oza <utsavoza96@gmail.com> | 2020-04-06 21:29:58 +0530 |
commit | 2c306227e9bc3b448df93e5d48d336c4a91e9df9 (patch) | |
tree | fcaa6f5cc8bdafab633c5d5c08dd89a92d1bc05c /components/constellation | |
parent | 50ea9fc02d1a6407c169dc98107002b2ad2b0eb0 (diff) | |
download | servo-2c306227e9bc3b448df93e5d48d336c4a91e9df9.tar.gz servo-2c306227e9bc3b448df93e5d48d336c4a91e9df9.zip |
Extract user_agent from global opts
Diffstat (limited to 'components/constellation')
-rw-r--r-- | components/constellation/constellation.rs | 10 | ||||
-rw-r--r-- | components/constellation/pipeline.rs | 8 |
2 files changed, 16 insertions, 2 deletions
diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs index 265db68e7ae..a6cb9df5532 100644 --- a/components/constellation/constellation.rs +++ b/components/constellation/constellation.rs @@ -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 { diff --git a/components/constellation/pipeline.rs b/components/constellation/pipeline.rs index 16cb67ab9a2..9739ecf32af 100644 --- a/components/constellation/pipeline.rs +++ b/components/constellation/pipeline.rs @@ -41,6 +41,7 @@ use script_traits::{ScriptThreadFactory, TimerSchedulerMsg, WindowSizeData}; use servo_config::opts::{self, Opts}; use servo_config::{prefs, prefs::PrefValue}; use servo_url::ServoUrl; +use std::borrow::Cow; use std::collections::{HashMap, HashSet}; use std::rc::Rc; use std::sync::atomic::AtomicBool; @@ -201,6 +202,9 @@ pub struct InitialPipelineState { /// Mechanism to force the compositor to process events. pub event_loop_waker: Option<Box<dyn EventLoopWaker>>, + + /// User agent string to report in network requests. + pub user_agent: Cow<'static, str>, } pub struct NewPipeline { @@ -304,6 +308,7 @@ impl Pipeline { webvr_chan: state.webvr_chan, webxr_registry: state.webxr_registry, player_context: state.player_context, + user_agent: state.user_agent, }; // Spawn the child process. @@ -520,6 +525,7 @@ pub struct UnprivilegedPipelineContent { webvr_chan: Option<IpcSender<WebVRMsg>>, webxr_registry: webxr_api::Registry, player_context: WindowGLContext, + user_agent: Cow<'static, str>, } impl UnprivilegedPipelineContent { @@ -588,7 +594,7 @@ impl UnprivilegedPipelineContent { self.opts.userscripts, self.opts.headless, self.opts.replace_surrogates, - self.opts.user_agent, + self.user_agent, ); LTF::create( |