mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
More build fixes
This commit is contained in:
parent
a52818978d
commit
894ff5a2bf
11 changed files with 56 additions and 56 deletions
|
@ -10,7 +10,7 @@ export create_content;
|
||||||
export Document;
|
export Document;
|
||||||
|
|
||||||
import std::arc::{arc, clone};
|
import std::arc::{arc, clone};
|
||||||
import comm::{port, chan, listen, select2};
|
import comm::{Port, Chan, port, chan, listen, select2};
|
||||||
import task::{spawn, spawn_listener};
|
import task::{spawn, spawn_listener};
|
||||||
import io::{read_whole_file, println};
|
import io::{read_whole_file, println};
|
||||||
import result::{ok, err};
|
import result::{ok, err};
|
||||||
|
@ -88,7 +88,7 @@ class Content<S:Sink send copy> {
|
||||||
|
|
||||||
let resource_task: ResourceTask;
|
let resource_task: ResourceTask;
|
||||||
|
|
||||||
new(layout: Layout, sink: S, from_master: port<ControlMsg>, resource_task: ResourceTask) {
|
new(layout: Layout, sink: S, from_master: Port<ControlMsg>, resource_task: ResourceTask) {
|
||||||
self.layout = layout;
|
self.layout = layout;
|
||||||
self.sink = sink;
|
self.sink = sink;
|
||||||
self.from_master = from_master;
|
self.from_master = from_master;
|
||||||
|
@ -219,7 +219,7 @@ class Content<S:Sink send copy> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_content<S: Sink send copy>(layout: Layout, sink: S, resource_task: ResourceTask) -> chan<ControlMsg> {
|
fn create_content<S: Sink send copy>(layout: Layout, sink: S, resource_task: ResourceTask) -> Chan<ControlMsg> {
|
||||||
do spawn_listener::<ControlMsg> |from_master| {
|
do spawn_listener::<ControlMsg> |from_master| {
|
||||||
Content(layout, sink, from_master, resource_task).start();
|
Content(layout, sink, from_master, resource_task).start();
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,15 +6,15 @@ import num::Num;
|
||||||
enum au = int;
|
enum au = int;
|
||||||
|
|
||||||
impl au : Num {
|
impl au : Num {
|
||||||
pure fn add(&&other: au) -> au { au(*self + *other) }
|
pure fn add(&&other: au) -> au { au(*self + *other) }
|
||||||
pure fn sub(&&other: au) -> au { au(*self - *other) }
|
pure fn sub(&&other: au) -> au { au(*self - *other) }
|
||||||
pure fn mul(&&other: au) -> au { au(*self * *other) }
|
pure fn mul(&&other: au) -> au { au(*self * *other) }
|
||||||
pure fn div(&&other: au) -> au { au(*self / *other) }
|
pure fn div(&&other: au) -> au { au(*self / *other) }
|
||||||
pure fn modulo(&&other: au) -> au { au(*self % *other) }
|
pure fn modulo(&&other: au) -> au { au(*self % *other) }
|
||||||
pure fn neg() -> au { au(-*self) }
|
pure fn neg() -> au { au(-*self) }
|
||||||
|
|
||||||
pure fn to_int() -> int { *self }
|
pure fn to_int() -> int { *self }
|
||||||
pure fn from_int(n: int) -> au { au(n) }
|
static pure fn from_int(n: int) -> au { au(n) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn box<A:copy Num>(x: A, y: A, w: A, h: A) -> Rect<A> {
|
fn box<A:copy Num>(x: A, y: A, w: A, h: A) -> Rect<A> {
|
||||||
|
|
|
@ -20,7 +20,7 @@ import cairo_bg::{cairo_image_surface_create, cairo_surface_destroy,
|
||||||
cairo_surface_write_to_png_stream};
|
cairo_surface_write_to_png_stream};
|
||||||
import renderer::{Renderer, Sink, RenderMsg};
|
import renderer::{Renderer, Sink, RenderMsg};
|
||||||
import task::spawn_listener;
|
import task::spawn_listener;
|
||||||
import comm::{chan, port};
|
import comm::{Chan, Port, chan, port};
|
||||||
import unsafe::reinterpret_cast;
|
import unsafe::reinterpret_cast;
|
||||||
import vec_from_buf = vec::unsafe::from_buf;
|
import vec_from_buf = vec::unsafe::from_buf;
|
||||||
import ptr::addr_of;
|
import ptr::addr_of;
|
||||||
|
@ -28,7 +28,7 @@ import dom::event::Event;
|
||||||
import dvec::dvec;
|
import dvec::dvec;
|
||||||
import layout::display_list::display_list;
|
import layout::display_list::display_list;
|
||||||
|
|
||||||
type PngSink = chan<Msg>;
|
type PngSink = Chan<Msg>;
|
||||||
|
|
||||||
enum Msg {
|
enum Msg {
|
||||||
BeginDrawing(pipes::chan<AzDrawTargetRef>),
|
BeginDrawing(pipes::chan<AzDrawTargetRef>),
|
||||||
|
@ -36,20 +36,20 @@ enum Msg {
|
||||||
Exit
|
Exit
|
||||||
}
|
}
|
||||||
|
|
||||||
impl chan<Msg> : Sink {
|
impl Chan<Msg> : Sink {
|
||||||
fn begin_drawing(+next_dt: pipes::chan<AzDrawTargetRef>) {
|
fn begin_drawing(+next_dt: pipes::chan<AzDrawTargetRef>) {
|
||||||
self.send(BeginDrawing(next_dt))
|
self.send(BeginDrawing(next_dt))
|
||||||
}
|
}
|
||||||
fn draw(+next_dt: pipes::chan<AzDrawTargetRef>, draw_me: AzDrawTargetRef) {
|
fn draw(+next_dt: pipes::chan<AzDrawTargetRef>, draw_me: AzDrawTargetRef) {
|
||||||
self.send(Draw(next_dt, draw_me))
|
self.send(Draw(next_dt, draw_me))
|
||||||
}
|
}
|
||||||
fn add_event_listener(_listener: chan<Event>) {
|
fn add_event_listener(_listener: Chan<Event>) {
|
||||||
// No events in this sink.
|
// No events in this sink.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn PngSink(output: chan<~[u8]>) -> PngSink {
|
fn PngSink(output: Chan<~[u8]>) -> PngSink {
|
||||||
do spawn_listener |po: port<Msg>| {
|
do spawn_listener |po: Port<Msg>| {
|
||||||
let cairo_surface = ImageSurface(CAIRO_FORMAT_ARGB32, 800, 600);
|
let cairo_surface = ImageSurface(CAIRO_FORMAT_ARGB32, 800, 600);
|
||||||
let draw_target = DrawTarget(cairo_surface);
|
let draw_target = DrawTarget(cairo_surface);
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ fn PngSink(output: chan<~[u8]>) -> PngSink {
|
||||||
|
|
||||||
fn do_draw(sender: pipes::chan<AzDrawTargetRef>,
|
fn do_draw(sender: pipes::chan<AzDrawTargetRef>,
|
||||||
dt: AzDrawTargetRef,
|
dt: AzDrawTargetRef,
|
||||||
output: chan<~[u8]>,
|
output: Chan<~[u8]>,
|
||||||
cairo_surface: ImageSurface) {
|
cairo_surface: ImageSurface) {
|
||||||
let buffer = io::mem_buffer();
|
let buffer = io::mem_buffer();
|
||||||
cairo_surface.write_to_png_stream(&buffer);
|
cairo_surface.write_to_png_stream(&buffer);
|
||||||
|
|
|
@ -16,11 +16,11 @@ import style::apply::apply_style;
|
||||||
import task::*;
|
import task::*;
|
||||||
import comm::*;
|
import comm::*;
|
||||||
|
|
||||||
type Layout = chan<Msg>;
|
type Layout = Chan<Msg>;
|
||||||
|
|
||||||
enum Msg {
|
enum Msg {
|
||||||
BuildMsg(Node, arc<Stylesheet>, url),
|
BuildMsg(Node, arc<Stylesheet>, url),
|
||||||
PingMsg(chan<content::PingMsg>),
|
PingMsg(Chan<content::PingMsg>),
|
||||||
ExitMsg
|
ExitMsg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import comm::{port, chan};
|
import comm::{Port, Chan, port, chan};
|
||||||
import dom::style;
|
import dom::style;
|
||||||
import option::is_none;
|
import option::is_none;
|
||||||
import str::from_bytes;
|
import str::from_bytes;
|
||||||
|
@ -166,7 +166,7 @@ impl HtmlLexer : HtmlLexerMethods {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn lexer(+input_port: port<resource_task::ProgressMsg>, state : ParseState) -> HtmlLexer {
|
fn lexer(+input_port: Port<resource_task::ProgressMsg>, state : ParseState) -> HtmlLexer {
|
||||||
return {
|
return {
|
||||||
input_state: {
|
input_state: {
|
||||||
mut lookahead: none,
|
mut lookahead: none,
|
||||||
|
@ -179,7 +179,7 @@ fn lexer(+input_port: port<resource_task::ProgressMsg>, state : ParseState) -> H
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(non_implicitly_copyable_typarams)]
|
#[allow(non_implicitly_copyable_typarams)]
|
||||||
fn spawn_html_lexer_task(-url: url, resource_task: ResourceTask) -> port<Token> {
|
fn spawn_html_lexer_task(-url: url, resource_task: ResourceTask) -> Port<Token> {
|
||||||
let html_port = port();
|
let html_port = port();
|
||||||
let html_chan = chan(html_port);
|
let html_chan = chan(html_port);
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
import option::is_none;
|
import option::is_none;
|
||||||
import str::from_bytes;
|
import str::from_bytes;
|
||||||
import vec::push;
|
import vec::push;
|
||||||
import comm::port;
|
import comm::Port;
|
||||||
import resource::resource_task::{ProgressMsg, Payload, Done};
|
import resource::resource_task::{ProgressMsg, Payload, Done};
|
||||||
|
|
||||||
enum CharOrEof {
|
enum CharOrEof {
|
||||||
|
@ -14,7 +14,7 @@ enum CharOrEof {
|
||||||
type InputState = {
|
type InputState = {
|
||||||
mut lookahead: option<CharOrEof>,
|
mut lookahead: option<CharOrEof>,
|
||||||
mut buffer: ~[u8],
|
mut buffer: ~[u8],
|
||||||
input_port: port<ProgressMsg>,
|
input_port: Port<ProgressMsg>,
|
||||||
mut eof: bool
|
mut eof: bool
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ fn OSMain() -> OSMain {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mainloop(po: port<Msg>) {
|
fn mainloop(po: Port<Msg>) {
|
||||||
let key_handlers: @DVec<pipes::chan<()>> = @dvec();
|
let key_handlers: @DVec<pipes::chan<()>> = @dvec();
|
||||||
let event_listeners: @DVec<comm::Chan<Event>> = @dvec();
|
let event_listeners: @DVec<comm::Chan<Event>> = @dvec();
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
export factory;
|
export factory;
|
||||||
|
|
||||||
import comm::chan;
|
import comm::Chan;
|
||||||
import task::spawn;
|
import task::spawn;
|
||||||
import resource_task::{ProgressMsg, Payload, Done};
|
import resource_task::{ProgressMsg, Payload, Done};
|
||||||
import std::net::url::url;
|
import std::net::url::url;
|
||||||
|
@ -9,7 +9,7 @@ import result::{result, ok, err};
|
||||||
|
|
||||||
const READ_SIZE: uint = 1024;
|
const READ_SIZE: uint = 1024;
|
||||||
|
|
||||||
fn factory(+url: url, progress_chan: chan<ProgressMsg>) {
|
fn factory(+url: url, progress_chan: Chan<ProgressMsg>) {
|
||||||
assert url.scheme == ~"file";
|
assert url.scheme == ~"file";
|
||||||
|
|
||||||
do spawn {
|
do spawn {
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
export factory;
|
export factory;
|
||||||
|
|
||||||
import comm::chan;
|
import comm::Chan;
|
||||||
import task::spawn;
|
import task::spawn;
|
||||||
import resource_task::{ProgressMsg, Payload, Done};
|
import resource_task::{ProgressMsg, Payload, Done};
|
||||||
import std::net::url::url;
|
import std::net::url::url;
|
||||||
import http_client::{uv_http_request};
|
import http_client::{uv_http_request};
|
||||||
import result::{ok, err};
|
import result::{ok, err};
|
||||||
|
|
||||||
fn factory(+url: url, progress_chan: chan<ProgressMsg>) {
|
fn factory(+url: url, progress_chan: Chan<ProgressMsg>) {
|
||||||
assert url.scheme == ~"http";
|
assert url.scheme == ~"http";
|
||||||
|
|
||||||
do spawn {
|
do spawn {
|
||||||
|
|
|
@ -7,7 +7,7 @@ export ImageCacheTaskClient;
|
||||||
import image::base::{Image, load_from_memory, test_image_bin};
|
import image::base::{Image, load_from_memory, test_image_bin};
|
||||||
import std::net::url::url;
|
import std::net::url::url;
|
||||||
import util::url::{make_url, UrlMap, url_map};
|
import util::url::{make_url, UrlMap, url_map};
|
||||||
import comm::{chan, port};
|
import comm::{Chan, Port, chan, port};
|
||||||
import task::{spawn, spawn_listener};
|
import task::{spawn, spawn_listener};
|
||||||
import resource::resource_task;
|
import resource::resource_task;
|
||||||
import resource_task::ResourceTask;
|
import resource_task::ResourceTask;
|
||||||
|
@ -26,7 +26,7 @@ enum Msg {
|
||||||
/*priv*/ StorePrefetchedImageData(url, result<Cell<~[u8]>, ()>),
|
/*priv*/ StorePrefetchedImageData(url, result<Cell<~[u8]>, ()>),
|
||||||
|
|
||||||
/// Request an Image object for a URL
|
/// Request an Image object for a URL
|
||||||
GetImage(url, chan<ImageResponseMsg>),
|
GetImage(url, Chan<ImageResponseMsg>),
|
||||||
|
|
||||||
/// Used by the decoder tasks to post decoded images back to the cache
|
/// Used by the decoder tasks to post decoded images back to the cache
|
||||||
/*priv*/ StoreImage(url, arc<~Image>),
|
/*priv*/ StoreImage(url, arc<~Image>),
|
||||||
|
@ -35,7 +35,7 @@ enum Msg {
|
||||||
/*priv*/ OnMsg(fn~(msg: &Msg)),
|
/*priv*/ OnMsg(fn~(msg: &Msg)),
|
||||||
|
|
||||||
/// Clients must wait for a response before shutting down the ResourceTask
|
/// Clients must wait for a response before shutting down the ResourceTask
|
||||||
Exit(chan<()>)
|
Exit(Chan<()>)
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ImageResponseMsg {
|
enum ImageResponseMsg {
|
||||||
|
@ -43,7 +43,7 @@ enum ImageResponseMsg {
|
||||||
ImageNotReady
|
ImageNotReady
|
||||||
}
|
}
|
||||||
|
|
||||||
type ImageCacheTask = chan<Msg>;
|
type ImageCacheTask = Chan<Msg>;
|
||||||
|
|
||||||
fn image_cache_task(resource_task: ResourceTask) -> ImageCacheTask {
|
fn image_cache_task(resource_task: ResourceTask) -> ImageCacheTask {
|
||||||
do spawn_listener |from_client| {
|
do spawn_listener |from_client| {
|
||||||
|
@ -60,10 +60,10 @@ struct ImageCache {
|
||||||
/// A handle to the resource task for fetching the image binaries
|
/// A handle to the resource task for fetching the image binaries
|
||||||
resource_task: ResourceTask;
|
resource_task: ResourceTask;
|
||||||
/// The port on which we'll receive client requests
|
/// The port on which we'll receive client requests
|
||||||
from_client: port<Msg>;
|
from_client: Port<Msg>;
|
||||||
/// The state of processsing an image for a URL
|
/// The state of processsing an image for a URL
|
||||||
state_map: UrlMap<ImageState>;
|
state_map: UrlMap<ImageState>;
|
||||||
mut need_exit: option<chan<()>>;
|
mut need_exit: option<Chan<()>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ImageState {
|
enum ImageState {
|
||||||
|
@ -76,7 +76,7 @@ enum ImageState {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct FutureData {
|
struct FutureData {
|
||||||
mut waiters: ~[chan<ImageResponseMsg>];
|
mut waiters: ~[Chan<ImageResponseMsg>];
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(non_implicitly_copyable_typarams)]
|
#[allow(non_implicitly_copyable_typarams)]
|
||||||
|
@ -203,7 +203,7 @@ impl ImageCache {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*priv*/ fn get_image(+url: url, response: chan<ImageResponseMsg>) {
|
/*priv*/ fn get_image(+url: url, response: Chan<ImageResponseMsg>) {
|
||||||
|
|
||||||
match self.get_state(copy url) {
|
match self.get_state(copy url) {
|
||||||
Init => fail ~"Request for image before prefetch",
|
Init => fail ~"Request for image before prefetch",
|
||||||
|
@ -323,7 +323,7 @@ fn should_exit_on_request() {
|
||||||
let mock_resource_task = do spawn_listener |from_client| {
|
let mock_resource_task = do spawn_listener |from_client| {
|
||||||
|
|
||||||
// infer me
|
// infer me
|
||||||
let from_client: port<resource_task::ControlMsg> = from_client;
|
let from_client: Port<resource_task::ControlMsg> = from_client;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
match from_client.recv() {
|
match from_client.recv() {
|
||||||
|
@ -363,7 +363,7 @@ fn should_request_url_from_resource_task_on_prefetch() {
|
||||||
let mock_resource_task = do spawn_listener |from_client| {
|
let mock_resource_task = do spawn_listener |from_client| {
|
||||||
|
|
||||||
// infer me
|
// infer me
|
||||||
let from_client: port<resource_task::ControlMsg> = from_client;
|
let from_client: Port<resource_task::ControlMsg> = from_client;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
match from_client.recv() {
|
match from_client.recv() {
|
||||||
|
@ -393,7 +393,7 @@ fn should_not_request_url_from_resource_task_on_multiple_prefetches() {
|
||||||
let mock_resource_task = do spawn_listener |from_client| {
|
let mock_resource_task = do spawn_listener |from_client| {
|
||||||
|
|
||||||
// infer me
|
// infer me
|
||||||
let from_client: port<resource_task::ControlMsg> = from_client;
|
let from_client: Port<resource_task::ControlMsg> = from_client;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
match from_client.recv() {
|
match from_client.recv() {
|
||||||
|
@ -425,7 +425,7 @@ fn should_return_image_not_ready_if_data_has_not_arrived() {
|
||||||
let mock_resource_task = do spawn_listener |from_client| {
|
let mock_resource_task = do spawn_listener |from_client| {
|
||||||
|
|
||||||
// infer me
|
// infer me
|
||||||
let from_client: port<resource_task::ControlMsg> = from_client;
|
let from_client: Port<resource_task::ControlMsg> = from_client;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
match from_client.recv() {
|
match from_client.recv() {
|
||||||
|
@ -458,7 +458,7 @@ fn should_return_decoded_image_data_if_data_has_arrived() {
|
||||||
let mock_resource_task = do spawn_listener |from_client| {
|
let mock_resource_task = do spawn_listener |from_client| {
|
||||||
|
|
||||||
// infer me
|
// infer me
|
||||||
let from_client: port<resource_task::ControlMsg> = from_client;
|
let from_client: Port<resource_task::ControlMsg> = from_client;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
match from_client.recv() {
|
match from_client.recv() {
|
||||||
|
@ -506,7 +506,7 @@ fn should_return_decoded_image_data_for_multiple_requests() {
|
||||||
let mock_resource_task = do spawn_listener |from_client| {
|
let mock_resource_task = do spawn_listener |from_client| {
|
||||||
|
|
||||||
// infer me
|
// infer me
|
||||||
let from_client: port<resource_task::ControlMsg> = from_client;
|
let from_client: Port<resource_task::ControlMsg> = from_client;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
match from_client.recv() {
|
match from_client.recv() {
|
||||||
|
@ -562,7 +562,7 @@ fn should_not_request_image_from_resource_task_if_image_is_already_available() {
|
||||||
let mock_resource_task = do spawn_listener |from_client| {
|
let mock_resource_task = do spawn_listener |from_client| {
|
||||||
|
|
||||||
// infer me
|
// infer me
|
||||||
let from_client: port<resource_task::ControlMsg> = from_client;
|
let from_client: Port<resource_task::ControlMsg> = from_client;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
match from_client.recv() {
|
match from_client.recv() {
|
||||||
|
@ -633,7 +633,7 @@ fn should_not_request_image_from_resource_task_if_image_fetch_already_failed() {
|
||||||
let mock_resource_task = do spawn_listener |from_client| {
|
let mock_resource_task = do spawn_listener |from_client| {
|
||||||
|
|
||||||
// infer me
|
// infer me
|
||||||
let from_client: port<resource_task::ControlMsg> = from_client;
|
let from_client: Port<resource_task::ControlMsg> = from_client;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
match from_client.recv() {
|
match from_client.recv() {
|
||||||
|
@ -684,7 +684,7 @@ fn should_return_not_ready_if_image_bin_cannot_be_fetched() {
|
||||||
let mock_resource_task = do spawn_listener |from_client| {
|
let mock_resource_task = do spawn_listener |from_client| {
|
||||||
|
|
||||||
// infer me
|
// infer me
|
||||||
let from_client: port<resource_task::ControlMsg> = from_client;
|
let from_client: Port<resource_task::ControlMsg> = from_client;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
match from_client.recv() {
|
match from_client.recv() {
|
||||||
|
@ -733,7 +733,7 @@ fn should_return_not_ready_for_multiple_get_image_requests_if_image_bin_cannot_b
|
||||||
let mock_resource_task = do spawn_listener |from_client| {
|
let mock_resource_task = do spawn_listener |from_client| {
|
||||||
|
|
||||||
// infer me
|
// infer me
|
||||||
let from_client: port<resource_task::ControlMsg> = from_client;
|
let from_client: Port<resource_task::ControlMsg> = from_client;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
match from_client.recv() {
|
match from_client.recv() {
|
||||||
|
|
|
@ -8,7 +8,7 @@ export ControlMsg, Load, Exit;
|
||||||
export ProgressMsg, Payload, Done;
|
export ProgressMsg, Payload, Done;
|
||||||
export ResourceTask, ResourceManager, LoaderTaskFactory;
|
export ResourceTask, ResourceManager, LoaderTaskFactory;
|
||||||
|
|
||||||
import comm::{chan, port};
|
import comm::{Chan, Port, chan, port};
|
||||||
import task::{spawn, spawn_listener};
|
import task::{spawn, spawn_listener};
|
||||||
import std::net::url;
|
import std::net::url;
|
||||||
import std::net::url::url;
|
import std::net::url::url;
|
||||||
|
@ -16,7 +16,7 @@ import result::{result, ok, err};
|
||||||
|
|
||||||
enum ControlMsg {
|
enum ControlMsg {
|
||||||
/// Request the data associated with a particular URL
|
/// Request the data associated with a particular URL
|
||||||
Load(url, chan<ProgressMsg>),
|
Load(url, Chan<ProgressMsg>),
|
||||||
Exit
|
Exit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ enum ProgressMsg {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handle to a resource task
|
/// Handle to a resource task
|
||||||
type ResourceTask = chan<ControlMsg>;
|
type ResourceTask = Chan<ControlMsg>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Creates a task to load a specific resource
|
Creates a task to load a specific resource
|
||||||
|
@ -37,7 +37,7 @@ Creates a task to load a specific resource
|
||||||
The ResourceManager delegates loading to a different type of loader task for
|
The ResourceManager delegates loading to a different type of loader task for
|
||||||
each URL scheme
|
each URL scheme
|
||||||
*/
|
*/
|
||||||
type LoaderTaskFactory = fn~(+url: url, chan<ProgressMsg>);
|
type LoaderTaskFactory = fn~(+url: url, Chan<ProgressMsg>);
|
||||||
|
|
||||||
/// Create a ResourceTask with the default loaders
|
/// Create a ResourceTask with the default loaders
|
||||||
fn ResourceTask() -> ResourceTask {
|
fn ResourceTask() -> ResourceTask {
|
||||||
|
@ -56,11 +56,11 @@ fn create_resource_task_with_loaders(+loaders: ~[(~str, LoaderTaskFactory)]) ->
|
||||||
}
|
}
|
||||||
|
|
||||||
class ResourceManager {
|
class ResourceManager {
|
||||||
let from_client: port<ControlMsg>;
|
let from_client: Port<ControlMsg>;
|
||||||
/// Per-scheme resource loaders
|
/// Per-scheme resource loaders
|
||||||
let loaders: ~[(~str, LoaderTaskFactory)];
|
let loaders: ~[(~str, LoaderTaskFactory)];
|
||||||
|
|
||||||
new(from_client: port<ControlMsg>, -loaders: ~[(~str, LoaderTaskFactory)]) {
|
new(from_client: Port<ControlMsg>, -loaders: ~[(~str, LoaderTaskFactory)]) {
|
||||||
self.from_client = from_client;
|
self.from_client = from_client;
|
||||||
self.loaders = loaders;
|
self.loaders = loaders;
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ class ResourceManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load(+url: url, progress_chan: chan<ProgressMsg>) {
|
fn load(+url: url, progress_chan: Chan<ProgressMsg>) {
|
||||||
|
|
||||||
match self.get_loader_factory(url) {
|
match self.get_loader_factory(url) {
|
||||||
some(loader_factory) => {
|
some(loader_factory) => {
|
||||||
|
@ -125,7 +125,7 @@ fn test_bad_scheme() {
|
||||||
#[allow(non_implicitly_copyable_typarams)]
|
#[allow(non_implicitly_copyable_typarams)]
|
||||||
fn should_delegate_to_scheme_loader() {
|
fn should_delegate_to_scheme_loader() {
|
||||||
let payload = ~[1, 2, 3];
|
let payload = ~[1, 2, 3];
|
||||||
let loader_factory = fn~(+_url: url, progress_chan: chan<ProgressMsg>, copy payload) {
|
let loader_factory = fn~(+_url: url, progress_chan: Chan<ProgressMsg>, copy payload) {
|
||||||
progress_chan.send(Payload(copy payload));
|
progress_chan.send(Payload(copy payload));
|
||||||
progress_chan.send(Done(ok(())));
|
progress_chan.send(Done(ok(())));
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue