mirror of
https://github.com/servo/servo.git
synced 2025-08-01 03:30:33 +01:00
Auto merge of #27417 - jdm:clear-reload, r=Manishearth
Make reload button clear the network cache. The developer workflow in FxR is frustrating right now because of bugs like https://github.com/servo/servo/issues/24385. To allow us to put out a new release soon that addresses this papercut, these changes make the reload button clear the network cache in FxR. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix (kind of) #26411. - [x] These changes do not require tests because can't test FxR.
This commit is contained in:
commit
0ce3ad5a4b
10 changed files with 50 additions and 1 deletions
|
@ -71,6 +71,8 @@ pub enum ConstellationMsg {
|
||||||
AllowNavigationResponse(PipelineId, bool),
|
AllowNavigationResponse(PipelineId, bool),
|
||||||
/// Request to load a page.
|
/// Request to load a page.
|
||||||
LoadUrl(TopLevelBrowsingContextId, ServoUrl),
|
LoadUrl(TopLevelBrowsingContextId, ServoUrl),
|
||||||
|
/// Clear the network cache.
|
||||||
|
ClearCache,
|
||||||
/// Request to traverse the joint session history of the provided browsing context.
|
/// Request to traverse the joint session history of the provided browsing context.
|
||||||
TraverseHistory(TopLevelBrowsingContextId, TraversalDirection),
|
TraverseHistory(TopLevelBrowsingContextId, TraversalDirection),
|
||||||
/// Inform the constellation of a window being resized.
|
/// Inform the constellation of a window being resized.
|
||||||
|
@ -143,6 +145,7 @@ impl fmt::Debug for ConstellationMsg {
|
||||||
MediaSessionAction(..) => "MediaSessionAction",
|
MediaSessionAction(..) => "MediaSessionAction",
|
||||||
ChangeBrowserVisibility(..) => "ChangeBrowserVisibility",
|
ChangeBrowserVisibility(..) => "ChangeBrowserVisibility",
|
||||||
IMEDismissed => "IMEDismissed",
|
IMEDismissed => "IMEDismissed",
|
||||||
|
ClearCache => "ClearCache",
|
||||||
};
|
};
|
||||||
write!(formatter, "ConstellationMsg::{}", variant)
|
write!(formatter, "ConstellationMsg::{}", variant)
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,6 +95,8 @@ pub enum WindowEvent {
|
||||||
ToggleWebRenderDebug(WebRenderDebugOption),
|
ToggleWebRenderDebug(WebRenderDebugOption),
|
||||||
/// Capture current WebRender
|
/// Capture current WebRender
|
||||||
CaptureWebRender,
|
CaptureWebRender,
|
||||||
|
/// Clear the network cache.
|
||||||
|
ClearCache,
|
||||||
/// Toggle sampling profiler with the given sampling rate and max duration.
|
/// Toggle sampling profiler with the given sampling rate and max duration.
|
||||||
ToggleSamplingProfiler(Duration, Duration),
|
ToggleSamplingProfiler(Duration, Duration),
|
||||||
/// Sent when the user triggers a media action through the UA exposed media UI
|
/// Sent when the user triggers a media action through the UA exposed media UI
|
||||||
|
@ -137,6 +139,7 @@ impl Debug for WindowEvent {
|
||||||
WindowEvent::MediaSessionAction(..) => write!(f, "MediaSessionAction"),
|
WindowEvent::MediaSessionAction(..) => write!(f, "MediaSessionAction"),
|
||||||
WindowEvent::ChangeBrowserVisibility(..) => write!(f, "ChangeBrowserVisibility"),
|
WindowEvent::ChangeBrowserVisibility(..) => write!(f, "ChangeBrowserVisibility"),
|
||||||
WindowEvent::IMEDismissed => write!(f, "IMEDismissed"),
|
WindowEvent::IMEDismissed => write!(f, "IMEDismissed"),
|
||||||
|
WindowEvent::ClearCache => write!(f, "ClearCache"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1529,6 +1529,10 @@ where
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
FromCompositorMsg::ClearCache => {
|
||||||
|
self.public_resource_threads.clear_cache();
|
||||||
|
self.private_resource_threads.clear_cache();
|
||||||
|
},
|
||||||
// Load a new page from a typed url
|
// Load a new page from a typed url
|
||||||
// If there is already a pending page (self.pending_changes), it will not be overridden;
|
// If there is already a pending page (self.pending_changes), it will not be overridden;
|
||||||
// However, if the id is not encompassed by another change, it will be.
|
// However, if the id is not encompassed by another change, it will be.
|
||||||
|
|
|
@ -902,4 +902,9 @@ impl HttpCache {
|
||||||
// See A cache MAY complete a stored incomplete response by making a subsequent range request
|
// See A cache MAY complete a stored incomplete response by making a subsequent range request
|
||||||
// https://tools.ietf.org/html/rfc7234#section-3.1
|
// https://tools.ietf.org/html/rfc7234#section-3.1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Clear the contents of this cache.
|
||||||
|
pub fn clear(&mut self) {
|
||||||
|
self.entries.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -354,6 +354,9 @@ impl ResourceChannelManager {
|
||||||
CoreResourceMsg::Synchronize(sender) => {
|
CoreResourceMsg::Synchronize(sender) => {
|
||||||
let _ = sender.send(());
|
let _ = sender.send(());
|
||||||
},
|
},
|
||||||
|
CoreResourceMsg::ClearCache => {
|
||||||
|
http_state.http_cache.write().unwrap().clear();
|
||||||
|
},
|
||||||
CoreResourceMsg::ToFileManager(msg) => self.resource_manager.filemanager.handle(msg),
|
CoreResourceMsg::ToFileManager(msg) => self.resource_manager.filemanager.handle(msg),
|
||||||
CoreResourceMsg::Exit(sender) => {
|
CoreResourceMsg::Exit(sender) => {
|
||||||
if let Some(ref config_dir) = self.config_dir {
|
if let Some(ref config_dir) = self.config_dir {
|
||||||
|
|
|
@ -361,6 +361,10 @@ impl ResourceThreads {
|
||||||
storage_thread: s,
|
storage_thread: s,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn clear_cache(&self) {
|
||||||
|
let _ = self.core_thread.send(CoreResourceMsg::ClearCache);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IpcSend<CoreResourceMsg> for ResourceThreads {
|
impl IpcSend<CoreResourceMsg> for ResourceThreads {
|
||||||
|
@ -459,6 +463,8 @@ pub enum CoreResourceMsg {
|
||||||
RemoveHistoryStates(Vec<HistoryStateId>),
|
RemoveHistoryStates(Vec<HistoryStateId>),
|
||||||
/// Synchronization message solely for knowing the state of the ResourceChannelManager loop
|
/// Synchronization message solely for knowing the state of the ResourceChannelManager loop
|
||||||
Synchronize(IpcSender<()>),
|
Synchronize(IpcSender<()>),
|
||||||
|
/// Clear the network cache.
|
||||||
|
ClearCache,
|
||||||
/// Send the service worker network mediator for an origin to CoreResourceThread
|
/// Send the service worker network mediator for an origin to CoreResourceThread
|
||||||
NetworkMediator(IpcSender<CustomResponseMediator>, ImmutableOrigin),
|
NetworkMediator(IpcSender<CustomResponseMediator>, ImmutableOrigin),
|
||||||
/// Message forwarded to file manager's handler
|
/// Message forwarded to file manager's handler
|
||||||
|
|
|
@ -583,6 +583,13 @@ where
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
WindowEvent::ClearCache => {
|
||||||
|
let msg = ConstellationMsg::ClearCache;
|
||||||
|
if let Err(e) = self.constellation_chan.send(msg) {
|
||||||
|
warn!("Sending clear cache to constellation failed ({:?}).", e);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
WindowEvent::MouseWindowEventClass(mouse_window_event) => {
|
WindowEvent::MouseWindowEventClass(mouse_window_event) => {
|
||||||
self.compositor
|
self.compositor
|
||||||
.on_mouse_window_event_class(mouse_window_event);
|
.on_mouse_window_event_class(mouse_window_event);
|
||||||
|
|
|
@ -355,6 +355,13 @@ impl ServoGlue {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Reload the page.
|
||||||
|
pub fn clear_cache(&mut self) -> Result<(), &'static str> {
|
||||||
|
info!("clear_cache");
|
||||||
|
let event = WindowEvent::ClearCache;
|
||||||
|
self.process_event(event)
|
||||||
|
}
|
||||||
|
|
||||||
/// Reload the page.
|
/// Reload the page.
|
||||||
pub fn reload(&mut self) -> Result<(), &'static str> {
|
pub fn reload(&mut self) -> Result<(), &'static str> {
|
||||||
info!("reload");
|
info!("reload");
|
||||||
|
|
|
@ -565,6 +565,14 @@ pub extern "C" fn load_uri(url: *const c_char) -> bool {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn clear_cache() {
|
||||||
|
catch_any_panic(|| {
|
||||||
|
debug!("clear_cache");
|
||||||
|
call(|s| s.clear_cache())
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn reload() {
|
pub extern "C" fn reload() {
|
||||||
catch_any_panic(|| {
|
catch_any_panic(|| {
|
||||||
|
|
|
@ -67,7 +67,10 @@ public:
|
||||||
void KeyDown(const char *k) { key_down(k); }
|
void KeyDown(const char *k) { key_down(k); }
|
||||||
void KeyUp(const char *k) { key_up(k); }
|
void KeyUp(const char *k) { key_up(k); }
|
||||||
|
|
||||||
void Reload() { reload(); }
|
void Reload() {
|
||||||
|
clear_cache();
|
||||||
|
reload();
|
||||||
|
}
|
||||||
void Stop() { stop(); }
|
void Stop() { stop(); }
|
||||||
bool LoadUri(hstring uri) { return load_uri(*hstring2char(uri)); }
|
bool LoadUri(hstring uri) { return load_uri(*hstring2char(uri)); }
|
||||||
void ChangeVisibility(bool visible) { change_visibility(visible); }
|
void ChangeVisibility(bool visible) { change_visibility(visible); }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue