servo: Merge #19328 - Remove cancellation map and ResourceId from the net* components (from Eijebong:remove_old_cancellation_code); r=KiChjang
authorBastien Orivel <eijebong@bananium.fr>
Tue, 21 Nov 2017 21:01:35 -0600
changeset 701862 2976031cb5fc916e858c879aea814f330209dd9d
parent 701861 ee92a8351073a7df9af706c110a0512808d1b700
child 701863 6259d018a90e8bf1a933c6c9ed41ecc9d777ac33
push id90298
push userbmo:bpostelnicu@mozilla.com
push dateWed, 22 Nov 2017 10:54:01 +0000
reviewersKiChjang
milestone59.0a1
servo: Merge #19328 - Remove cancellation map and ResourceId from the net* components (from Eijebong:remove_old_cancellation_code); r=KiChjang Fixes #19327 Source-Repo: https://github.com/servo/servo Source-Revision: 78fb3c206d30da8e7b16ea941268b733b21059ed
servo/components/net/resource_thread.rs
servo/components/net_traits/lib.rs
--- a/servo/components/net/resource_thread.rs
+++ b/servo/components/net/resource_thread.rs
@@ -12,19 +12,19 @@ use fetch::cors_cache::CorsCache;
 use fetch::methods::{CancellationListener, FetchContext, fetch};
 use filemanager_thread::{FileManager, TFDProvider};
 use hsts::HstsList;
 use http_cache::HttpCache;
 use http_loader::{HttpState, http_redirect_fetch};
 use hyper_serde::Serde;
 use ipc_channel::ipc::{self, IpcReceiver, IpcReceiverSet, IpcSender};
 use net_traits::{CookieSource, CoreResourceThread};
-use net_traits::{CoreResourceMsg, FetchChannels, FetchResponseMsg};
-use net_traits::{CustomResponseMediator, ResourceId};
-use net_traits::{ResourceThreads, WebSocketDomAction, WebSocketNetworkEvent};
+use net_traits::{CoreResourceMsg, CustomResponseMediator, FetchChannels};
+use net_traits::{FetchResponseMsg, ResourceThreads, WebSocketDomAction};
+use net_traits::WebSocketNetworkEvent;
 use net_traits::request::{Request, RequestInit};
 use net_traits::response::{Response, ResponseInit};
 use net_traits::storage_thread::StorageThreadMsg;
 use profile_traits::time::ProfilerChan;
 use serde::{Deserialize, Serialize};
 use serde_json;
 use servo_config::opts;
 use servo_config::resource_files::resources_dir_path;
@@ -182,22 +182,16 @@ impl ResourceChannelManager {
             CoreResourceMsg::NetworkMediator(mediator_chan) => {
                 self.resource_manager.swmanager_chan = Some(mediator_chan)
             }
             CoreResourceMsg::GetCookiesDataForUrl(url, consumer, source) => {
                 let mut cookie_jar = http_state.cookie_jar.write().unwrap();
                 let cookies = cookie_jar.cookies_data_for_url(&url, source).map(Serde).collect();
                 consumer.send(cookies).unwrap();
             }
-            CoreResourceMsg::Cancel(res_id) => {
-                if let Some(cancel_sender) = self.resource_manager.cancel_load_map.get(&res_id) {
-                    let _ = cancel_sender.send(());
-                }
-                self.resource_manager.cancel_load_map.remove(&res_id);
-            }
             CoreResourceMsg::Synchronize(sender) => {
                 let _ = sender.send(());
             }
             CoreResourceMsg::ToFileManager(msg) => self.resource_manager.filemanager.handle(msg, TFD_PROVIDER),
             CoreResourceMsg::Exit(sender) => {
                 if let Some(ref config_dir) = self.config_dir {
                     match http_state.auth_cache.read() {
                         Ok(auth_cache) => write_json_to_file(&*auth_cache, config_dir, "auth_cache.json"),
@@ -297,29 +291,27 @@ pub struct AuthCache {
     pub entries: HashMap<String, AuthCacheEntry>,
 }
 
 pub struct CoreResourceManager {
     user_agent: Cow<'static, str>,
     devtools_chan: Option<Sender<DevtoolsControlMsg>>,
     swmanager_chan: Option<IpcSender<CustomResponseMediator>>,
     filemanager: FileManager,
-    cancel_load_map: HashMap<ResourceId, Sender<()>>,
 }
 
 impl CoreResourceManager {
     pub fn new(user_agent: Cow<'static, str>,
                devtools_channel: Option<Sender<DevtoolsControlMsg>>,
                _profiler_chan: ProfilerChan) -> CoreResourceManager {
         CoreResourceManager {
             user_agent: user_agent,
             devtools_chan: devtools_channel,
             swmanager_chan: None,
             filemanager: FileManager::new(),
-            cancel_load_map: HashMap::new(),
         }
     }
 
     fn set_cookie_for_url(&mut self, request: &ServoUrl,
                           cookie: cookie_rs::Cookie<'static>,
                           source: CookieSource,
                           http_state: &Arc<HttpState>) {
         if let Some(cookie) = cookie::Cookie::new_wrapped(cookie, request, source) {
--- a/servo/components/net_traits/lib.rs
+++ b/servo/components/net_traits/lib.rs
@@ -357,18 +357,16 @@ pub enum CoreResourceMsg {
     /// Store a cookie for a given originating URL
     SetCookieForUrl(ServoUrl, Serde<Cookie<'static>>, CookieSource),
     /// Store a set of cookies for a given originating URL
     SetCookiesForUrl(ServoUrl, Vec<Serde<Cookie<'static>>>, CookieSource),
     /// Retrieve the stored cookies for a given URL
     GetCookiesForUrl(ServoUrl, IpcSender<Option<String>>, CookieSource),
     /// Get a cookie by name for a given originating URL
     GetCookiesDataForUrl(ServoUrl, IpcSender<Vec<Serde<Cookie<'static>>>>, CookieSource),
-    /// Cancel a network request corresponding to a given `ResourceId`
-    Cancel(ResourceId),
     /// Synchronization message solely for knowing the state of the ResourceChannelManager loop
     Synchronize(IpcSender<()>),
     /// Send the network sender in constellation to CoreResourceThread
     NetworkMediator(IpcSender<CustomResponseMediator>),
     /// Message forwarded to file manager's handler
     ToFileManager(FileManagerThreadMsg),
     /// Break the load handler loop, send a reply when done cleaning up local resources
     /// and exit
@@ -495,20 +493,16 @@ pub fn load_whole_resource(request: Requ
             FetchResponseMsg::ProcessResponseChunk(data) => buf.extend_from_slice(&data),
             FetchResponseMsg::ProcessResponseEOF(Ok(())) => return Ok((metadata.unwrap(), buf)),
             FetchResponseMsg::ProcessResponse(Err(e)) |
             FetchResponseMsg::ProcessResponseEOF(Err(e)) => return Err(e),
         }
     }
 }
 
-/// An unique identifier to keep track of each load message in the resource handler
-#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, PartialEq, Serialize)]
-pub struct ResourceId(pub u32);
-
 /// Network errors that have to be exported out of the loaders
 #[derive(Clone, Debug, Deserialize, Eq, MallocSizeOf, PartialEq, Serialize)]
 pub enum NetworkError {
     /// Could be any of the internal errors, like unsupported scheme, connection errors, etc.
     Internal(String),
     LoadCancelled,
     /// SSL validation error that has to be handled in the HTML parser
     SslValidation(ServoUrl, String),