mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Auto merge of #9201 - wenderen:8512-task-thread, r=jdm
task -> thread for #8512 <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9201) <!-- Reviewable:end -->
This commit is contained in:
commit
d3e2f94f20
119 changed files with 1209 additions and 1207 deletions
|
@ -2,7 +2,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use gfx::font_cache_task::FontCacheTask;
|
||||
use gfx::font_cache_thread::FontCacheThread;
|
||||
use ipc_channel::ipc;
|
||||
use style::computed_values::font_family::FontFamily;
|
||||
use style::font_face::Source;
|
||||
|
@ -11,11 +11,11 @@ use style::font_face::Source;
|
|||
fn test_local_web_font() {
|
||||
let (inp_chan, _) = ipc::channel().unwrap();
|
||||
let (out_chan, out_receiver) = ipc::channel().unwrap();
|
||||
let font_cache_task = FontCacheTask::new(inp_chan);
|
||||
let font_cache_thread = FontCacheThread::new(inp_chan);
|
||||
let family_name = FontFamily::FamilyName(From::from("test family"));
|
||||
let variant_name = FontFamily::FamilyName(From::from("test font face"));
|
||||
|
||||
font_cache_task.add_web_font(family_name, Source::Local(variant_name), out_chan);
|
||||
font_cache_thread.add_web_font(family_name, Source::Local(variant_name), out_chan);
|
||||
|
||||
assert_eq!(out_receiver.recv().unwrap(), ());
|
||||
}
|
|
@ -6,5 +6,5 @@ extern crate gfx;
|
|||
extern crate ipc_channel;
|
||||
extern crate style;
|
||||
|
||||
#[cfg(test)] mod font_cache_task;
|
||||
#[cfg(test)] mod font_cache_thread;
|
||||
#[cfg(test)] mod text_util;
|
||||
|
|
|
@ -18,7 +18,7 @@ fn assert_parse(url: &'static str,
|
|||
data: Option<Vec<u8>>) {
|
||||
use net::data_loader::load;
|
||||
use net::mime_classifier::MIMEClassifier;
|
||||
use net::resource_task::CancellationListener;
|
||||
use net::resource_thread::CancellationListener;
|
||||
use std::sync::Arc;
|
||||
use std::sync::mpsc::channel;
|
||||
use url::Url;
|
||||
|
|
|
@ -21,7 +21,7 @@ use net::cookie::Cookie;
|
|||
use net::cookie_storage::CookieStorage;
|
||||
use net::hsts::{HSTSList};
|
||||
use net::http_loader::{load, LoadError, HttpRequestFactory, HttpRequest, HttpResponse};
|
||||
use net::resource_task::CancellationListener;
|
||||
use net::resource_thread::CancellationListener;
|
||||
use net_traits::{LoadData, CookieSource, LoadContext};
|
||||
use std::borrow::Cow;
|
||||
use std::io::{self, Write, Read, Cursor};
|
||||
|
@ -1197,7 +1197,7 @@ fn test_load_errors_when_viewing_source_and_inner_url_scheme_is_not_http_or_http
|
|||
#[test]
|
||||
fn test_load_errors_when_cancelled() {
|
||||
use ipc_channel::ipc;
|
||||
use net::resource_task::CancellableResource;
|
||||
use net::resource_thread::CancellableResource;
|
||||
use net_traits::ResourceId;
|
||||
|
||||
struct Factory;
|
||||
|
|
|
@ -20,6 +20,6 @@ extern crate util;
|
|||
#[cfg(test)] mod cookie;
|
||||
#[cfg(test)] mod data_loader;
|
||||
#[cfg(test)] mod mime_classifier;
|
||||
#[cfg(test)] mod resource_task;
|
||||
#[cfg(test)] mod resource_thread;
|
||||
#[cfg(test)] mod hsts;
|
||||
#[cfg(test)] mod http_loader;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use ipc_channel::ipc;
|
||||
use net::resource_task::new_resource_task;
|
||||
use net::resource_thread::new_resource_thread;
|
||||
use net_traits::hosts::{parse_hostsfile, host_replacement};
|
||||
use net_traits::{ControlMsg, LoadData, LoadConsumer, ProgressMsg, LoadContext};
|
||||
use std::borrow::ToOwned;
|
||||
|
@ -13,23 +13,23 @@ use url::Url;
|
|||
|
||||
#[test]
|
||||
fn test_exit() {
|
||||
let resource_task = new_resource_task("".to_owned(), None);
|
||||
resource_task.send(ControlMsg::Exit).unwrap();
|
||||
let resource_thread = new_resource_thread("".to_owned(), None);
|
||||
resource_thread.send(ControlMsg::Exit).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_bad_scheme() {
|
||||
let resource_task = new_resource_task("".to_owned(), None);
|
||||
let resource_thread = new_resource_thread("".to_owned(), None);
|
||||
let (start_chan, start) = ipc::channel().unwrap();
|
||||
let url = url!("bogus://whatever");
|
||||
resource_task.send(ControlMsg::Load(LoadData::new(LoadContext::Browsing, url, None),
|
||||
resource_thread.send(ControlMsg::Load(LoadData::new(LoadContext::Browsing, url, None),
|
||||
LoadConsumer::Channel(start_chan), None)).unwrap();
|
||||
let response = start.recv().unwrap();
|
||||
match response.progress_port.recv().unwrap() {
|
||||
ProgressMsg::Done(result) => { assert!(result.is_err()) }
|
||||
_ => panic!("bleh")
|
||||
}
|
||||
resource_task.send(ControlMsg::Exit).unwrap();
|
||||
resource_thread.send(ControlMsg::Exit).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -196,20 +196,20 @@ fn test_cancelled_listener() {
|
|||
}
|
||||
});
|
||||
|
||||
let resource_task = new_resource_task("".to_owned(), None);
|
||||
let resource_thread = new_resource_thread("".to_owned(), None);
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
let (id_sender, id_receiver) = ipc::channel().unwrap();
|
||||
let (sync_sender, sync_receiver) = ipc::channel().unwrap();
|
||||
let url = Url::parse(&format!("http://127.0.0.1:{}", port)).unwrap();
|
||||
|
||||
resource_task.send(ControlMsg::Load(LoadData::new(LoadContext::Browsing, url, None),
|
||||
resource_thread.send(ControlMsg::Load(LoadData::new(LoadContext::Browsing, url, None),
|
||||
LoadConsumer::Channel(sender),
|
||||
Some(id_sender))).unwrap();
|
||||
// get the `ResourceId` and send a cancel message, which should stop the loading loop
|
||||
let res_id = id_receiver.recv().unwrap();
|
||||
resource_task.send(ControlMsg::Cancel(res_id)).unwrap();
|
||||
// synchronize with the resource_task loop, so that we don't simply send everything at once!
|
||||
resource_task.send(ControlMsg::Synchronize(sync_sender)).unwrap();
|
||||
resource_thread.send(ControlMsg::Cancel(res_id)).unwrap();
|
||||
// synchronize with the resource_thread loop, so that we don't simply send everything at once!
|
||||
resource_thread.send(ControlMsg::Synchronize(sync_sender)).unwrap();
|
||||
let _ = sync_receiver.recv();
|
||||
// now, let's send the body, because the connection is still active and data would be loaded
|
||||
// (but, the loading has been cancelled)
|
||||
|
@ -219,5 +219,5 @@ fn test_cancelled_listener() {
|
|||
ProgressMsg::Done(result) => assert_eq!(result.unwrap_err(), "load cancelled".to_owned()),
|
||||
_ => panic!("baaaah!"),
|
||||
}
|
||||
resource_task.send(ControlMsg::Exit).unwrap();
|
||||
resource_thread.send(ControlMsg::Exit).unwrap();
|
||||
}
|
|
@ -14,7 +14,7 @@ extern crate util;
|
|||
|
||||
#[cfg(test)] mod cache;
|
||||
#[cfg(test)] mod logical_geometry;
|
||||
#[cfg(test)] mod task;
|
||||
#[cfg(test)] mod thread;
|
||||
#[cfg(test)] mod vec;
|
||||
#[cfg(test)] mod mem;
|
||||
#[cfg(test)] mod str;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::borrow::ToOwned;
|
||||
use util::task::spawn_named;
|
||||
use util::thread::spawn_named;
|
||||
|
||||
#[test]
|
||||
fn spawn_named_test() {
|
Loading…
Add table
Add a link
Reference in a new issue