servo: Merge #4820 - add `unwrap` to `send/recv` calls (from servo:send-recv); r=Ms2ger

Source-Repo: https://github.com/servo/servo
Source-Revision: 8e6dcc7c26d88bb0452226ff8c34539e368e03d9
This commit is contained in:
Alexandru Cojocaru 2015-02-03 11:24:53 -07:00
Родитель c99d3e601b
Коммит 24ca70cf6f
30 изменённых файлов: 100 добавлений и 100 удалений

Просмотреть файл

@ -120,11 +120,11 @@ impl FontCache {
Command::GetFontTemplate(family, descriptor, result) => { Command::GetFontTemplate(family, descriptor, result) => {
let family = LowercaseString::new(family.as_slice()); let family = LowercaseString::new(family.as_slice());
let maybe_font_template = self.get_font_template(&family, &descriptor); let maybe_font_template = self.get_font_template(&family, &descriptor);
result.send(Reply::GetFontTemplateReply(maybe_font_template)); result.send(Reply::GetFontTemplateReply(maybe_font_template)).unwrap();
} }
Command::GetLastResortFontTemplate(descriptor, result) => { Command::GetLastResortFontTemplate(descriptor, result) => {
let font_template = self.get_last_resort_font_template(&descriptor); let font_template = self.get_last_resort_font_template(&descriptor);
result.send(Reply::GetFontTemplateReply(Some(font_template))); result.send(Reply::GetFontTemplateReply(Some(font_template))).unwrap();
} }
Command::AddWebFont(family_name, src, result) => { Command::AddWebFont(family_name, src, result) => {
let family_name = LowercaseString::new(family_name.as_slice()); let family_name = LowercaseString::new(family_name.as_slice());
@ -154,10 +154,10 @@ impl FontCache {
}); });
} }
} }
result.send(()); result.send(()).unwrap();
} }
Command::Exit(result) => { Command::Exit(result) => {
result.send(()); result.send(()).unwrap();
break; break;
} }
} }
@ -289,7 +289,7 @@ impl FontCacheTask {
-> Option<Arc<FontTemplateData>> { -> Option<Arc<FontTemplateData>> {
let (response_chan, response_port) = channel(); let (response_chan, response_port) = channel();
self.chan.send(Command::GetFontTemplate(family, desc, response_chan)); self.chan.send(Command::GetFontTemplate(family, desc, response_chan)).unwrap();
let reply = response_port.recv().unwrap(); let reply = response_port.recv().unwrap();
@ -304,7 +304,7 @@ impl FontCacheTask {
-> Arc<FontTemplateData> { -> Arc<FontTemplateData> {
let (response_chan, response_port) = channel(); let (response_chan, response_port) = channel();
self.chan.send(Command::GetLastResortFontTemplate(desc, response_chan)); self.chan.send(Command::GetLastResortFontTemplate(desc, response_chan)).unwrap();
let reply = response_port.recv().unwrap(); let reply = response_port.recv().unwrap();
@ -317,13 +317,13 @@ impl FontCacheTask {
pub fn add_web_font(&self, family: String, src: Source) { pub fn add_web_font(&self, family: String, src: Source) {
let (response_chan, response_port) = channel(); let (response_chan, response_port) = channel();
self.chan.send(Command::AddWebFont(family, src, response_chan)); self.chan.send(Command::AddWebFont(family, src, response_chan)).unwrap();
response_port.recv(); response_port.recv().unwrap();
} }
pub fn exit(&self) { pub fn exit(&self) {
let (response_chan, response_port) = channel(); let (response_chan, response_port) = channel();
self.chan.send(Command::Exit(response_chan)); self.chan.send(Command::Exit(response_chan)).unwrap();
response_port.recv(); response_port.recv().unwrap();
} }
} }

Просмотреть файл

@ -186,7 +186,7 @@ impl<C> PaintTask<C> where C: PaintListener + Send {
} }
debug!("paint_task: shutdown_chan send"); debug!("paint_task: shutdown_chan send");
shutdown_chan.send(()); shutdown_chan.send(()).unwrap();
}, ConstellationMsg::Failure(failure_msg), c); }, ConstellationMsg::Failure(failure_msg), c);
} }
@ -203,7 +203,7 @@ impl<C> PaintTask<C> where C: PaintListener + Send {
if !self.paint_permission { if !self.paint_permission {
debug!("PaintTask: paint ready msg"); debug!("PaintTask: paint ready msg");
let ConstellationChan(ref mut c) = self.constellation_chan; let ConstellationChan(ref mut c) = self.constellation_chan;
c.send(ConstellationMsg::PainterReady(self.id)); c.send(ConstellationMsg::PainterReady(self.id)).unwrap();
continue; continue;
} }
@ -214,7 +214,7 @@ impl<C> PaintTask<C> where C: PaintListener + Send {
if !self.paint_permission { if !self.paint_permission {
debug!("PaintTask: paint ready msg"); debug!("PaintTask: paint ready msg");
let ConstellationChan(ref mut c) = self.constellation_chan; let ConstellationChan(ref mut c) = self.constellation_chan;
c.send(ConstellationMsg::PainterReady(self.id)); c.send(ConstellationMsg::PainterReady(self.id)).unwrap();
self.compositor.paint_msg_discarded(); self.compositor.paint_msg_discarded();
continue; continue;
} }

Просмотреть файл

@ -912,7 +912,7 @@ impl FragmentDisplayListBuilding for Fragment {
let (sender, receiver) = channel::<Vec<u8>>(); let (sender, receiver) = channel::<Vec<u8>>();
let canvas_data = match canvas_fragment_info.renderer { let canvas_data = match canvas_fragment_info.renderer {
Some(ref renderer) => { Some(ref renderer) => {
renderer.lock().unwrap().send(SendPixelContents(sender)); renderer.lock().unwrap().send(SendPixelContents(sender)).unwrap();
receiver.recv().unwrap() receiver.recv().unwrap()
}, },
None => repeat(0xFFu8).take(width * height * 4).collect(), None => repeat(0xFFu8).take(width * height * 4).collect(),
@ -955,7 +955,7 @@ impl FragmentDisplayListBuilding for Fragment {
let ConstellationChan(ref chan) = layout_context.shared.constellation_chan; let ConstellationChan(ref chan) = layout_context.shared.constellation_chan;
chan.send(ConstellationMsg::FrameRect(iframe_fragment.pipeline_id, chan.send(ConstellationMsg::FrameRect(iframe_fragment.pipeline_id,
iframe_fragment.subpage_id, iframe_fragment.subpage_id,
iframe_rect)); iframe_rect)).unwrap();
} }
fn clipping_region_for_children(&self, fn clipping_region_for_children(&self,

Просмотреть файл

@ -204,7 +204,7 @@ impl LayoutTaskFactory for LayoutTask {
time_profiler_chan); time_profiler_chan);
layout.start(); layout.start();
} }
shutdown_chan.send(()); shutdown_chan.send(()).unwrap();
}, ConstellationMsg::Failure(failure_msg), con_chan); }, ConstellationMsg::Failure(failure_msg), con_chan);
} }
} }
@ -400,7 +400,7 @@ impl LayoutTask {
Msg::SetQuirksMode => self.handle_set_quirks_mode(possibly_locked_rw_data), Msg::SetQuirksMode => self.handle_set_quirks_mode(possibly_locked_rw_data),
Msg::GetRPC(response_chan) => { Msg::GetRPC(response_chan) => {
response_chan.send(box LayoutRPCImpl(self.rw_data.clone()) as response_chan.send(box LayoutRPCImpl(self.rw_data.clone()) as
Box<LayoutRPC + Send>); Box<LayoutRPC + Send>).unwrap();
}, },
Msg::Reflow(data) => { Msg::Reflow(data) => {
profile(TimeProfilerCategory::LayoutPerform, profile(TimeProfilerCategory::LayoutPerform,
@ -434,7 +434,7 @@ impl LayoutTask {
fn prepare_to_exit<'a>(&'a self, fn prepare_to_exit<'a>(&'a self,
response_chan: Sender<()>, response_chan: Sender<()>,
possibly_locked_rw_data: &mut Option<MutexGuard<'a, LayoutTaskData>>) { possibly_locked_rw_data: &mut Option<MutexGuard<'a, LayoutTaskData>>) {
response_chan.send(()); response_chan.send(()).unwrap();
loop { loop {
match self.port.recv().unwrap() { match self.port.recv().unwrap() {
Msg::ReapLayoutData(dead_layout_data) => { Msg::ReapLayoutData(dead_layout_data) => {
@ -878,9 +878,9 @@ impl LayoutTask {
// //
// FIXME(pcwalton): This should probably be *one* channel, but we can't fix this without // FIXME(pcwalton): This should probably be *one* channel, but we can't fix this without
// either select or a filtered recv() that only looks for messages of a given type. // either select or a filtered recv() that only looks for messages of a given type.
data.script_join_chan.send(()); data.script_join_chan.send(()).unwrap();
let ScriptControlChan(ref chan) = data.script_chan; let ScriptControlChan(ref chan) = data.script_chan;
chan.send(ConstellationControlMsg::ReflowComplete(self.id, data.id)); chan.send(ConstellationControlMsg::ReflowComplete(self.id, data.id)).unwrap();
} }
unsafe fn dirty_all_nodes(node: &mut LayoutNode) { unsafe fn dirty_all_nodes(node: &mut LayoutNode) {
@ -1009,7 +1009,7 @@ impl LayoutRPC for LayoutRPCImpl {
Cursor::DefaultCursor Cursor::DefaultCursor
}; };
let ConstellationChan(ref constellation_chan) = rw_data.constellation_chan; let ConstellationChan(ref constellation_chan) = rw_data.constellation_chan;
constellation_chan.send(ConstellationMsg::SetCursor(cursor)); constellation_chan.send(ConstellationMsg::SetCursor(cursor)).unwrap();
} }
if mouse_over_list.is_empty() { if mouse_over_list.is_empty() {

Просмотреть файл

@ -28,7 +28,7 @@ pub fn factory(mut load_data: LoadData, start_chan: Sender<TargetedLoadResponse>
headers: None, headers: None,
status: Some(RawStatus(200, "OK".to_owned())) status: Some(RawStatus(200, "OK".to_owned()))
}); });
chan.send(Done(Ok(()))); chan.send(Done(Ok(()))).unwrap();
return return
} }
"crash" => panic!("Loading the about:crash URL."), "crash" => panic!("Loading the about:crash URL."),
@ -40,7 +40,7 @@ pub fn factory(mut load_data: LoadData, start_chan: Sender<TargetedLoadResponse>
} }
_ => { _ => {
start_sending(senders, Metadata::default(load_data.url)) start_sending(senders, Metadata::default(load_data.url))
.send(Done(Err("Unknown about: URL.".to_string()))); .send(Done(Err("Unknown about: URL.".to_string()))).unwrap();
return return
} }
}; };

Просмотреть файл

@ -45,7 +45,7 @@ fn load(load_data: LoadData, start_chan: Sender<TargetedLoadResponse>) {
} }
let parts: Vec<&str> = scheme_data.as_slice().splitn(1, ',').collect(); let parts: Vec<&str> = scheme_data.as_slice().splitn(1, ',').collect();
if parts.len() != 2 { if parts.len() != 2 {
start_sending(senders, metadata).send(Done(Err("invalid data uri".to_string()))); start_sending(senders, metadata).send(Done(Err("invalid data uri".to_string()))).unwrap();
return; return;
} }
@ -72,16 +72,16 @@ fn load(load_data: LoadData, start_chan: Sender<TargetedLoadResponse>) {
let bytes = bytes.into_iter().filter(|&b| b != ' ' as u8).collect::<Vec<u8>>(); let bytes = bytes.into_iter().filter(|&b| b != ' ' as u8).collect::<Vec<u8>>();
match bytes.as_slice().from_base64() { match bytes.as_slice().from_base64() {
Err(..) => { Err(..) => {
progress_chan.send(Done(Err("non-base64 data uri".to_string()))); progress_chan.send(Done(Err("non-base64 data uri".to_string()))).unwrap();
} }
Ok(data) => { Ok(data) => {
progress_chan.send(Payload(data)); progress_chan.send(Payload(data)).unwrap();
progress_chan.send(Done(Ok(()))); progress_chan.send(Done(Ok(()))).unwrap();
} }
} }
} else { } else {
progress_chan.send(Payload(bytes)); progress_chan.send(Payload(bytes)).unwrap();
progress_chan.send(Done(Ok(()))); progress_chan.send(Done(Ok(()))).unwrap();
} }
} }

Просмотреть файл

@ -47,15 +47,15 @@ pub fn factory(load_data: LoadData, start_chan: Sender<TargetedLoadResponse>) {
match File::open_mode(&Path::new(file_path), io::Open, io::Read) { match File::open_mode(&Path::new(file_path), io::Open, io::Read) {
Ok(ref mut reader) => { Ok(ref mut reader) => {
let res = read_all(reader as &mut io::Stream, &progress_chan); let res = read_all(reader as &mut io::Stream, &progress_chan);
progress_chan.send(Done(res)); progress_chan.send(Done(res)).unwrap();
} }
Err(e) => { Err(e) => {
progress_chan.send(Done(Err(e.desc.to_string()))); progress_chan.send(Done(Err(e.desc.to_string()))).unwrap();
} }
} }
} }
Err(_) => { Err(_) => {
progress_chan.send(Done(Err(url.to_string()))); progress_chan.send(Done(Err(url.to_string()))).unwrap();
} }
} }
}); });

Просмотреть файл

@ -166,7 +166,7 @@ impl ImageCache {
Msg::Prefetch(url) => self.prefetch(url), Msg::Prefetch(url) => self.prefetch(url),
Msg::StorePrefetchedImageData(url, data) => { Msg::StorePrefetchedImageData(url, data) => {
store_prefetched_chan.map(|chan| { store_prefetched_chan.map(|chan| {
chan.send(()); chan.send(()).unwrap();
}); });
store_prefetched_chan = None; store_prefetched_chan = None;
@ -175,7 +175,7 @@ impl ImageCache {
Msg::Decode(url) => self.decode(url), Msg::Decode(url) => self.decode(url),
Msg::StoreImage(url, image) => { Msg::StoreImage(url, image) => {
store_chan.map(|chan| { store_chan.map(|chan| {
chan.send(()); chan.send(()).unwrap();
}); });
store_chan = None; store_chan = None;
@ -211,7 +211,7 @@ impl ImageCache {
} }
if can_exit { if can_exit {
response.send(()); response.send(()).unwrap();
break; break;
} else { } else {
self.need_exit = Some(response); self.need_exit = Some(response);
@ -245,7 +245,7 @@ impl ImageCache {
debug!("image_cache_task: started fetch for {}", url.serialize()); debug!("image_cache_task: started fetch for {}", url.serialize());
let image = load_image_data(url.clone(), resource_task.clone()); let image = load_image_data(url.clone(), resource_task.clone());
to_cache.send(Msg::StorePrefetchedImageData(url.clone(), image)); to_cache.send(Msg::StorePrefetchedImageData(url.clone(), image)).unwrap();
debug!("image_cache_task: ended fetch for {}", url.serialize()); debug!("image_cache_task: ended fetch for {}", url.serialize());
}); });
@ -309,7 +309,7 @@ impl ImageCache {
debug!("image_cache_task: started image decode for {}", url.serialize()); debug!("image_cache_task: started image decode for {}", url.serialize());
let image = load_from_memory(data.as_slice()); let image = load_from_memory(data.as_slice());
let image = image.map(|image| Arc::new(box image)); let image = image.map(|image| Arc::new(box image));
to_cache.send(Msg::StoreImage(url.clone(), image)); to_cache.send(Msg::StoreImage(url.clone(), image)).unwrap();
debug!("image_cache_task: ended image decode for {}", url.serialize()); debug!("image_cache_task: ended image decode for {}", url.serialize());
}); });
@ -354,7 +354,7 @@ impl ImageCache {
Some(waiters) => { Some(waiters) => {
let items = waiters.lock().unwrap(); let items = waiters.lock().unwrap();
for response in items.iter() { for response in items.iter() {
response.send(f()); response.send(f()).unwrap();
} }
} }
None => () None => ()
@ -391,11 +391,11 @@ impl ImageCache {
} }
ImageState::Decoded(image) => { ImageState::Decoded(image) => {
response.send(ImageResponseMsg::ImageReady(image)); response.send(ImageResponseMsg::ImageReady(image)).unwrap();
} }
ImageState::Failed => { ImageState::Failed => {
response.send(ImageResponseMsg::ImageFailed); response.send(ImageResponseMsg::ImageFailed).unwrap();
} }
} }
} }
@ -417,7 +417,7 @@ impl ImageCacheTaskClient for ImageCacheTask {
impl ImageCacheTask { impl ImageCacheTask {
pub fn send(&self, msg: Msg) { pub fn send(&self, msg: Msg) {
self.chan.send(msg); self.chan.send(msg).unwrap();
} }
#[cfg(test)] #[cfg(test)]
@ -437,7 +437,7 @@ impl ImageCacheTask {
fn load_image_data(url: Url, resource_task: ResourceTask) -> Result<Vec<u8>, ()> { fn load_image_data(url: Url, resource_task: ResourceTask) -> Result<Vec<u8>, ()> {
let (response_chan, response_port) = channel(); let (response_chan, response_port) = channel();
resource_task.send(resource_task::ControlMsg::Load(LoadData::new(url, response_chan))); resource_task.send(resource_task::ControlMsg::Load(LoadData::new(url, response_chan))).unwrap();
let mut image_data = vec!(); let mut image_data = vec!();
@ -466,7 +466,7 @@ pub fn spawn_listener<F, A>(f: F) -> Sender<A>
spawn_named("ImageCacheTask (listener)".to_owned(), move || { spawn_named("ImageCacheTask (listener)".to_owned(), move || {
let (chan, port) = channel(); let (chan, port) = channel();
setup_chan.send(chan); setup_chan.send(chan).unwrap();
f(port); f(port);
}); });
setup_port.recv().unwrap() setup_port.recv().unwrap()

Просмотреть файл

@ -94,13 +94,13 @@ impl<NodeAddress: Send> LocalImageCache<NodeAddress> {
match state.last_response { match state.last_response {
ImageResponseMsg::ImageReady(ref image) => { ImageResponseMsg::ImageReady(ref image) => {
let (chan, port) = channel(); let (chan, port) = channel();
chan.send(ImageResponseMsg::ImageReady(image.clone())); chan.send(ImageResponseMsg::ImageReady(image.clone())).unwrap();
return port; return port;
} }
ImageResponseMsg::ImageNotReady => { ImageResponseMsg::ImageNotReady => {
if last_round == round_number { if last_round == round_number {
let (chan, port) = channel(); let (chan, port) = channel();
chan.send(ImageResponseMsg::ImageNotReady); chan.send(ImageResponseMsg::ImageNotReady).unwrap();
return port; return port;
} else { } else {
// We haven't requested the image from the // We haven't requested the image from the
@ -109,7 +109,7 @@ impl<NodeAddress: Send> LocalImageCache<NodeAddress> {
} }
ImageResponseMsg::ImageFailed => { ImageResponseMsg::ImageFailed => {
let (chan, port) = channel(); let (chan, port) = channel();
chan.send(ImageResponseMsg::ImageFailed); chan.send(ImageResponseMsg::ImageFailed).unwrap();
return port; return port;
} }
} }
@ -149,7 +149,7 @@ impl<NodeAddress: Send> LocalImageCache<NodeAddress> {
self.get_state(url).last_response = response_copy; self.get_state(url).last_response = response_copy;
let (chan, port) = channel(); let (chan, port) = channel();
chan.send(response); chan.send(response).unwrap();
return port; return port;
} }

Просмотреть файл

@ -164,7 +164,7 @@ pub fn start_sending_opt(senders: ResponseSenders, metadata: Metadata) -> Result
pub fn load_whole_resource(resource_task: &ResourceTask, url: Url) pub fn load_whole_resource(resource_task: &ResourceTask, url: Url)
-> Result<(Metadata, Vec<u8>), String> { -> Result<(Metadata, Vec<u8>), String> {
let (start_chan, start_port) = channel(); let (start_chan, start_port) = channel();
resource_task.send(ControlMsg::Load(LoadData::new(url, start_chan))); resource_task.send(ControlMsg::Load(LoadData::new(url, start_chan))).unwrap();
let response = start_port.recv().unwrap(); let response = start_port.recv().unwrap();
let mut buf = vec!(); let mut buf = vec!();
@ -238,7 +238,7 @@ impl ResourceManager {
_ => { _ => {
debug!("resource_task: no loader for scheme {}", load_data.url.scheme); debug!("resource_task: no loader for scheme {}", load_data.url.scheme);
start_sending(senders, Metadata::default(load_data.url)) start_sending(senders, Metadata::default(load_data.url))
.send(ProgressMsg::Done(Err("no loader for scheme".to_string()))); .send(ProgressMsg::Done(Err("no loader for scheme".to_string()))).unwrap();
return return
} }
} }
@ -248,7 +248,7 @@ impl ResourceManager {
/// Load a URL asynchronously and iterate over chunks of bytes from the response. /// Load a URL asynchronously and iterate over chunks of bytes from the response.
pub fn load_bytes_iter(resource_task: &ResourceTask, url: Url) -> (Metadata, ProgressMsgPortIterator) { pub fn load_bytes_iter(resource_task: &ResourceTask, url: Url) -> (Metadata, ProgressMsgPortIterator) {
let (input_chan, input_port) = channel(); let (input_chan, input_port) = channel();
resource_task.send(ControlMsg::Load(LoadData::new(url, input_chan))); resource_task.send(ControlMsg::Load(LoadData::new(url, input_chan))).unwrap();
let response = input_port.recv().unwrap(); let response = input_port.recv().unwrap();
let iter = ProgressMsgPortIterator { progress_port: response.progress_port }; let iter = ProgressMsgPortIterator { progress_port: response.progress_port };

Просмотреть файл

@ -99,14 +99,14 @@ impl StorageManager {
fn length(&self, sender: Sender<u32>, url: Url) { fn length(&self, sender: Sender<u32>, url: Url) {
let origin = self.get_origin_as_string(url); let origin = self.get_origin_as_string(url);
sender.send(self.data.get(&origin).map_or(0u, |entry| entry.len()) as u32); sender.send(self.data.get(&origin).map_or(0u, |entry| entry.len()) as u32).unwrap();
} }
fn key(&self, sender: Sender<Option<DOMString>>, url: Url, index: u32) { fn key(&self, sender: Sender<Option<DOMString>>, url: Url, index: u32) {
let origin = self.get_origin_as_string(url); let origin = self.get_origin_as_string(url);
sender.send(self.data.get(&origin) sender.send(self.data.get(&origin)
.and_then(|entry| entry.keys().nth(index as uint)) .and_then(|entry| entry.keys().nth(index as uint))
.map(|key| key.clone())); .map(|key| key.clone())).unwrap();
} }
fn set_item(&mut self, sender: Sender<bool>, url: Url, name: DOMString, value: DOMString) { fn set_item(&mut self, sender: Sender<bool>, url: Url, name: DOMString, value: DOMString) {
@ -124,20 +124,20 @@ impl StorageManager {
} }
}).unwrap(); }).unwrap();
sender.send(updated); sender.send(updated).unwrap();
} }
fn get_item(&self, sender: Sender<Option<DOMString>>, url: Url, name: DOMString) { fn get_item(&self, sender: Sender<Option<DOMString>>, url: Url, name: DOMString) {
let origin = self.get_origin_as_string(url); let origin = self.get_origin_as_string(url);
sender.send(self.data.get(&origin) sender.send(self.data.get(&origin)
.and_then(|entry| entry.get(&name)) .and_then(|entry| entry.get(&name))
.map(|value| value.to_string())); .map(|value| value.to_string())).unwrap();
} }
fn remove_item(&mut self, sender: Sender<bool>, url: Url, name: DOMString) { fn remove_item(&mut self, sender: Sender<bool>, url: Url, name: DOMString) {
let origin = self.get_origin_as_string(url); let origin = self.get_origin_as_string(url);
sender.send(self.data.get_mut(&origin) sender.send(self.data.get_mut(&origin)
.map_or(false, |entry| entry.remove(&name).is_some())); .map_or(false, |entry| entry.remove(&name).is_some())).unwrap();
} }
fn clear(&mut self, sender: Sender<bool>, url: Url) { fn clear(&mut self, sender: Sender<bool>, url: Url) {
@ -149,7 +149,7 @@ impl StorageManager {
true true
} else { } else {
false false
}})); }})).unwrap();
} }
fn get_origin_as_string(&self, url: Url) -> String { fn get_origin_as_string(&self, url: Url) -> String {

Просмотреть файл

@ -45,7 +45,7 @@ pub fn handle_evaluate_js(page: &Rc<Page>, pipeline: PipelineId, eval: String, r
//FIXME: jsvals don't have an is_int32/is_number yet //FIXME: jsvals don't have an is_int32/is_number yet
assert!(rval.is_object()); assert!(rval.is_object());
panic!("object values unimplemented") panic!("object values unimplemented")
}); }).unwrap();
} }
pub fn handle_get_root_node(page: &Rc<Page>, pipeline: PipelineId, reply: Sender<NodeInfo>) { pub fn handle_get_root_node(page: &Rc<Page>, pipeline: PipelineId, reply: Sender<NodeInfo>) {
@ -54,7 +54,7 @@ pub fn handle_get_root_node(page: &Rc<Page>, pipeline: PipelineId, reply: Sender
let document = frame.as_ref().unwrap().document.root(); let document = frame.as_ref().unwrap().document.root();
let node: JSRef<Node> = NodeCast::from_ref(document.r()); let node: JSRef<Node> = NodeCast::from_ref(document.r());
reply.send(node.summarize()); reply.send(node.summarize()).unwrap();
} }
pub fn handle_get_document_element(page: &Rc<Page>, pipeline: PipelineId, reply: Sender<NodeInfo>) { pub fn handle_get_document_element(page: &Rc<Page>, pipeline: PipelineId, reply: Sender<NodeInfo>) {
@ -64,7 +64,7 @@ pub fn handle_get_document_element(page: &Rc<Page>, pipeline: PipelineId, reply:
let document_element = document.r().GetDocumentElement().root().unwrap(); let document_element = document.r().GetDocumentElement().root().unwrap();
let node: JSRef<Node> = NodeCast::from_ref(document_element.r()); let node: JSRef<Node> = NodeCast::from_ref(document_element.r());
reply.send(node.summarize()); reply.send(node.summarize()).unwrap();
} }
fn find_node_by_unique_id(page: &Rc<Page>, pipeline: PipelineId, node_id: String) -> Temporary<Node> { fn find_node_by_unique_id(page: &Rc<Page>, pipeline: PipelineId, node_id: String) -> Temporary<Node> {
@ -85,14 +85,14 @@ fn find_node_by_unique_id(page: &Rc<Page>, pipeline: PipelineId, node_id: String
pub fn handle_get_children(page: &Rc<Page>, pipeline: PipelineId, node_id: String, reply: Sender<Vec<NodeInfo>>) { pub fn handle_get_children(page: &Rc<Page>, pipeline: PipelineId, node_id: String, reply: Sender<Vec<NodeInfo>>) {
let parent = find_node_by_unique_id(&*page, pipeline, node_id).root(); let parent = find_node_by_unique_id(&*page, pipeline, node_id).root();
let children = parent.r().children().map(|child| child.summarize()).collect(); let children = parent.r().children().map(|child| child.summarize()).collect();
reply.send(children); reply.send(children).unwrap();
} }
pub fn handle_get_layout(page: &Rc<Page>, pipeline: PipelineId, node_id: String, reply: Sender<(f32, f32)>) { pub fn handle_get_layout(page: &Rc<Page>, pipeline: PipelineId, node_id: String, reply: Sender<(f32, f32)>) {
let node = find_node_by_unique_id(&*page, pipeline, node_id).root(); let node = find_node_by_unique_id(&*page, pipeline, node_id).root();
let elem: JSRef<Element> = ElementCast::to_ref(node.r()).expect("should be getting layout of element"); let elem: JSRef<Element> = ElementCast::to_ref(node.r()).expect("should be getting layout of element");
let rect = elem.GetBoundingClientRect().root(); let rect = elem.GetBoundingClientRect().root();
reply.send((rect.r().Width(), rect.r().Height())); reply.send((rect.r().Width(), rect.r().Height())).unwrap();
} }
pub fn handle_modify_attribute(page: &Rc<Page>, pipeline: PipelineId, node_id: String, modifications: Vec<Modification>) { pub fn handle_modify_attribute(page: &Rc<Page>, pipeline: PipelineId, node_id: String, modifications: Vec<Modification>) {

Просмотреть файл

@ -42,7 +42,7 @@ impl CanvasRenderingContext2D {
} }
pub fn recreate(&self, size: Size2D<i32>) { pub fn recreate(&self, size: Size2D<i32>) {
self.renderer.send(Recreate(size)); self.renderer.send(Recreate(size)).unwrap();
} }
} }
@ -63,23 +63,23 @@ impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D>
fn FillRect(self, x: f64, y: f64, width: f64, height: f64) { fn FillRect(self, x: f64, y: f64, width: f64, height: f64) {
let rect = Rect(Point2D(x as f32, y as f32), Size2D(width as f32, height as f32)); let rect = Rect(Point2D(x as f32, y as f32), Size2D(width as f32, height as f32));
self.renderer.send(FillRect(rect)); self.renderer.send(FillRect(rect)).unwrap();
} }
fn ClearRect(self, x: f64, y: f64, width: f64, height: f64) { fn ClearRect(self, x: f64, y: f64, width: f64, height: f64) {
let rect = Rect(Point2D(x as f32, y as f32), Size2D(width as f32, height as f32)); let rect = Rect(Point2D(x as f32, y as f32), Size2D(width as f32, height as f32));
self.renderer.send(ClearRect(rect)); self.renderer.send(ClearRect(rect)).unwrap();
} }
fn StrokeRect(self, x: f64, y: f64, width: f64, height: f64) { fn StrokeRect(self, x: f64, y: f64, width: f64, height: f64) {
let rect = Rect(Point2D(x as f32, y as f32), Size2D(width as f32, height as f32)); let rect = Rect(Point2D(x as f32, y as f32), Size2D(width as f32, height as f32));
self.renderer.send(StrokeRect(rect)); self.renderer.send(StrokeRect(rect)).unwrap();
} }
} }
#[unsafe_destructor] #[unsafe_destructor]
impl Drop for CanvasRenderingContext2D { impl Drop for CanvasRenderingContext2D {
fn drop(&mut self) { fn drop(&mut self) {
self.renderer.send(Close); self.renderer.send(Close).unwrap();
} }
} }

Просмотреть файл

@ -47,7 +47,7 @@ pub struct SendableWorkerScriptChan {
impl ScriptChan for SendableWorkerScriptChan { impl ScriptChan for SendableWorkerScriptChan {
fn send(&self, msg: ScriptMsg) { fn send(&self, msg: ScriptMsg) {
self.sender.send((self.worker.clone(), msg)); self.sender.send((self.worker.clone(), msg)).unwrap();
} }
fn clone(&self) -> Box<ScriptChan + Send> { fn clone(&self) -> Box<ScriptChan + Send> {

Просмотреть файл

@ -223,7 +223,7 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
let window = self.window.root(); let window = self.window.root();
let window = window.r(); let window = window.r();
let LayoutChan(ref layout_chan) = window.page().layout_chan; let LayoutChan(ref layout_chan) = window.page().layout_chan;
layout_chan.send(Msg::SetQuirksMode); layout_chan.send(Msg::SetQuirksMode).unwrap();
} }
NoQuirks | LimitedQuirks => {} NoQuirks | LimitedQuirks => {}
} }

Просмотреть файл

@ -113,7 +113,7 @@ impl<'a> HTMLIFrameElementHelpers for JSRef<'a, HTMLIFrameElement> {
page.id, page.id,
new_subpage_id, new_subpage_id,
old_subpage_id, old_subpage_id,
sandboxed)); sandboxed)).unwrap();
} }
} }

Просмотреть файл

@ -133,7 +133,7 @@ impl<'a> PrivateHTMLLinkElementHelpers for JSRef<'a, HTMLLinkElement> {
match UrlParser::new().base_url(&window.page().get_url()).parse(href) { match UrlParser::new().base_url(&window.page().get_url()).parse(href) {
Ok(url) => { Ok(url) => {
let LayoutChan(ref layout_chan) = window.page().layout_chan; let LayoutChan(ref layout_chan) = window.page().layout_chan;
layout_chan.send(Msg::LoadStylesheet(url)); layout_chan.send(Msg::LoadStylesheet(url)).unwrap();
} }
Err(e) => debug!("Parsing url {} failed: {}", href, e) Err(e) => debug!("Parsing url {} failed: {}", href, e)
} }

Просмотреть файл

@ -57,7 +57,7 @@ impl<'a> StyleElementHelpers for JSRef<'a, HTMLStyleElement> {
let data = node.GetTextContent().expect("Element.textContent must be a string"); let data = node.GetTextContent().expect("Element.textContent must be a string");
let sheet = Stylesheet::from_str(data.as_slice(), url, Origin::Author); let sheet = Stylesheet::from_str(data.as_slice(), url, Origin::Author);
let LayoutChan(ref layout_chan) = win.page().layout_chan; let LayoutChan(ref layout_chan) = win.page().layout_chan;
layout_chan.send(Msg::AddStylesheet(sheet)); layout_chan.send(Msg::AddStylesheet(sheet)).unwrap();
} }
} }

Просмотреть файл

@ -54,21 +54,21 @@ impl<'a> StorageMethods for JSRef<'a, Storage> {
fn Length(self) -> u32 { fn Length(self) -> u32 {
let (sender, receiver) = channel(); let (sender, receiver) = channel();
self.get_storage_task().send(StorageTaskMsg::Length(sender, self.get_url())); self.get_storage_task().send(StorageTaskMsg::Length(sender, self.get_url())).unwrap();
receiver.recv().unwrap() receiver.recv().unwrap()
} }
fn Key(self, index: u32) -> Option<DOMString> { fn Key(self, index: u32) -> Option<DOMString> {
let (sender, receiver) = channel(); let (sender, receiver) = channel();
self.get_storage_task().send(StorageTaskMsg::Key(sender, self.get_url(), index)); self.get_storage_task().send(StorageTaskMsg::Key(sender, self.get_url(), index)).unwrap();
receiver.recv().unwrap() receiver.recv().unwrap()
} }
fn GetItem(self, name: DOMString) -> Option<DOMString> { fn GetItem(self, name: DOMString) -> Option<DOMString> {
let (sender, receiver) = channel(); let (sender, receiver) = channel();
self.get_storage_task().send(StorageTaskMsg::GetItem(sender, self.get_url(), name)); self.get_storage_task().send(StorageTaskMsg::GetItem(sender, self.get_url(), name)).unwrap();
receiver.recv().unwrap() receiver.recv().unwrap()
} }
@ -81,7 +81,7 @@ impl<'a> StorageMethods for JSRef<'a, Storage> {
fn SetItem(self, name: DOMString, value: DOMString) { fn SetItem(self, name: DOMString, value: DOMString) {
let (sender, receiver) = channel(); let (sender, receiver) = channel();
self.get_storage_task().send(StorageTaskMsg::SetItem(sender, self.get_url(), name, value)); self.get_storage_task().send(StorageTaskMsg::SetItem(sender, self.get_url(), name, value)).unwrap();
if receiver.recv().unwrap() { if receiver.recv().unwrap() {
//TODO send notification //TODO send notification
} }
@ -98,7 +98,7 @@ impl<'a> StorageMethods for JSRef<'a, Storage> {
fn RemoveItem(self, name: DOMString) { fn RemoveItem(self, name: DOMString) {
let (sender, receiver) = channel(); let (sender, receiver) = channel();
self.get_storage_task().send(StorageTaskMsg::RemoveItem(sender, self.get_url(), name)); self.get_storage_task().send(StorageTaskMsg::RemoveItem(sender, self.get_url(), name)).unwrap();
if receiver.recv().unwrap() { if receiver.recv().unwrap() {
//TODO send notification //TODO send notification
} }
@ -111,7 +111,7 @@ impl<'a> StorageMethods for JSRef<'a, Storage> {
fn Clear(self) { fn Clear(self) {
let (sender, receiver) = channel(); let (sender, receiver) = channel();
self.get_storage_task().send(StorageTaskMsg::Clear(sender, self.get_url())); self.get_storage_task().send(StorageTaskMsg::Clear(sender, self.get_url())).unwrap();
if receiver.recv().unwrap() { if receiver.recv().unwrap() {
//TODO send notification //TODO send notification
} }

Просмотреть файл

@ -94,7 +94,7 @@ impl<'a> WorkerMethods for JSRef<'a, Worker> {
fn PostMessage(self, cx: *mut JSContext, message: JSVal) -> ErrorResult { fn PostMessage(self, cx: *mut JSContext, message: JSVal) -> ErrorResult {
let data = try!(StructuredCloneData::write(cx, message)); let data = try!(StructuredCloneData::write(cx, message));
let address = Trusted::new(cx, self, self.global.root().r().script_chan().clone()); let address = Trusted::new(cx, self, self.global.root().r().script_chan().clone());
self.sender.send((address, ScriptMsg::DOMMessage(data))); self.sender.send((address, ScriptMsg::DOMMessage(data))).unwrap();
Ok(()) Ok(())
} }

Просмотреть файл

@ -260,7 +260,7 @@ impl XMLHttpRequest {
// perhaps should be handled by the resource_loader? // perhaps should be handled by the resource_loader?
spawn_named("XHR:Cors".to_owned(), move || { spawn_named("XHR:Cors".to_owned(), move || {
let response = req2.http_fetch(); let response = req2.http_fetch();
chan.send(response); chan.send(response).unwrap();
}); });
select! ( select! (
@ -282,7 +282,7 @@ impl XMLHttpRequest {
} }
// Step 10, 13 // Step 10, 13
resource_task.send(Load(load_data)); resource_task.send(Load(load_data)).unwrap();
let progress_port; let progress_port;

Просмотреть файл

@ -139,7 +139,7 @@ impl Page {
let layout_rpc: Box<LayoutRPC> = { let layout_rpc: Box<LayoutRPC> = {
let (rpc_send, rpc_recv) = channel(); let (rpc_send, rpc_recv) = channel();
let LayoutChan(ref lchan) = layout_chan; let LayoutChan(ref lchan) = layout_chan;
lchan.send(Msg::GetRPC(rpc_send)); lchan.send(Msg::GetRPC(rpc_send)).unwrap();
rpc_recv.recv().unwrap() rpc_recv.recv().unwrap()
}; };
Page { Page {
@ -323,7 +323,7 @@ impl Page {
match join_port.try_recv() { match join_port.try_recv() {
Err(Empty) => { Err(Empty) => {
info!("script: waiting on layout"); info!("script: waiting on layout");
join_port.recv(); join_port.recv().unwrap();
} }
Ok(_) => {} Ok(_) => {}
Err(Disconnected) => { Err(Disconnected) => {
@ -398,7 +398,7 @@ impl Page {
}; };
let LayoutChan(ref chan) = self.layout_chan; let LayoutChan(ref chan) = self.layout_chan;
chan.send(Msg::Reflow(reflow)); chan.send(Msg::Reflow(reflow)).unwrap();
debug!("script: layout forked"); debug!("script: layout forked");

Просмотреть файл

@ -144,7 +144,7 @@ pub struct NonWorkerScriptChan(pub Sender<ScriptMsg>);
impl ScriptChan for NonWorkerScriptChan { impl ScriptChan for NonWorkerScriptChan {
fn send(&self, msg: ScriptMsg) { fn send(&self, msg: ScriptMsg) {
let NonWorkerScriptChan(ref chan) = *self; let NonWorkerScriptChan(ref chan) = *self;
chan.send(msg); chan.send(msg).unwrap();
} }
fn clone(&self) -> Box<ScriptChan+Send> { fn clone(&self) -> Box<ScriptChan+Send> {
@ -695,7 +695,7 @@ impl ScriptTask {
/// TODO(tkuehn): is it ever possible to navigate only on a subframe? /// TODO(tkuehn): is it ever possible to navigate only on a subframe?
fn handle_navigate_msg(&self, direction: NavigationDirection) { fn handle_navigate_msg(&self, direction: NavigationDirection) {
let ConstellationChan(ref chan) = self.constellation_chan; let ConstellationChan(ref chan) = self.constellation_chan;
chan.send(ConstellationMsg::Navigate(direction)); chan.send(ConstellationMsg::Navigate(direction)).unwrap();
} }
/// Window was resized, but this script was not active, so don't reflow yet /// Window was resized, but this script was not active, so don't reflow yet
@ -832,7 +832,7 @@ impl ScriptTask {
data: load_data.data, data: load_data.data,
cors: None, cors: None,
consumer: input_chan, consumer: input_chan,
})); })).unwrap();
let load_response = input_port.recv().unwrap(); let load_response = input_port.recv().unwrap();
@ -899,7 +899,7 @@ impl ScriptTask {
*page.fragment_name.borrow_mut() = final_url.fragment.clone(); *page.fragment_name.borrow_mut() = final_url.fragment.clone();
let ConstellationChan(ref chan) = self.constellation_chan; let ConstellationChan(ref chan) = self.constellation_chan;
chan.send(ConstellationMsg::LoadComplete); chan.send(ConstellationMsg::LoadComplete).unwrap();
// Notify devtools that a new script global exists. // Notify devtools that a new script global exists.
match self.devtools_chan { match self.devtools_chan {
@ -910,7 +910,7 @@ impl ScriptTask {
url: final_url url: final_url
}; };
chan.send(NewGlobal(pipeline_id, self.devtools_sender.clone(), chan.send(NewGlobal(pipeline_id, self.devtools_sender.clone(),
page_info)); page_info)).unwrap();
} }
} }
} }
@ -1070,7 +1070,7 @@ impl ScriptTask {
/// for the given pipeline. /// for the given pipeline.
fn trigger_load(&self, pipeline_id: PipelineId, load_data: LoadData) { fn trigger_load(&self, pipeline_id: PipelineId, load_data: LoadData) {
let ConstellationChan(ref const_chan) = self.constellation_chan; let ConstellationChan(ref const_chan) = self.constellation_chan;
const_chan.send(ConstellationMsg::LoadUrl(pipeline_id, load_data)); const_chan.send(ConstellationMsg::LoadUrl(pipeline_id, load_data)).unwrap();
} }
/// The entry point for content to notify that a fragment url has been requested /// The entry point for content to notify that a fragment url has been requested
@ -1284,8 +1284,8 @@ fn shut_down_layout(page_tree: &Rc<Page>, rt: *mut JSRuntime, exit_type: Pipelin
// processed this message. // processed this message.
let (response_chan, response_port) = channel(); let (response_chan, response_port) = channel();
let LayoutChan(ref chan) = page.layout_chan; let LayoutChan(ref chan) = page.layout_chan;
chan.send(layout_interface::Msg::PrepareToExit(response_chan)); chan.send(layout_interface::Msg::PrepareToExit(response_chan)).unwrap();
response_port.recv(); response_port.recv().unwrap();
} }
// Remove our references to the DOM objects in this page tree. // Remove our references to the DOM objects in this page tree.
@ -1307,7 +1307,7 @@ fn shut_down_layout(page_tree: &Rc<Page>, rt: *mut JSRuntime, exit_type: Pipelin
// Destroy the layout task. If there were node leaks, layout will now crash safely. // Destroy the layout task. If there were node leaks, layout will now crash safely.
for page in page_tree.iter() { for page in page_tree.iter() {
let LayoutChan(ref chan) = page.layout_chan; let LayoutChan(ref chan) = page.layout_chan;
chan.send(layout_interface::Msg::ExitNow(exit_type)); chan.send(layout_interface::Msg::ExitNow(exit_type)).unwrap();
} }
} }

Просмотреть файл

@ -148,7 +148,7 @@ impl TimerManager {
loop { loop {
let id = select.wait(); let id = select.wait();
if id == timeout_handle.id() { if id == timeout_handle.id() {
timeout_port.recv(); timeout_port.recv().unwrap();
script_chan.send(ScriptMsg::FireTimer(source, TimerId(handle))); script_chan.send(ScriptMsg::FireTimer(source, TimerId(handle)));
if is_interval == IsInterval::NonInterval { if is_interval == IsInterval::NonInterval {
break; break;

Просмотреть файл

@ -124,11 +124,11 @@ impl<Window> Browser<Window> where Window: WindowMethods + 'static {
}; };
let ConstellationChan(ref chan) = constellation_chan; let ConstellationChan(ref chan) = constellation_chan;
chan.send(ConstellationMsg::InitLoadUrl(url)); chan.send(ConstellationMsg::InitLoadUrl(url)).unwrap();
} }
// Send the constallation Chan as the result // Send the constallation Chan as the result
result_chan.send(constellation_chan); result_chan.send(constellation_chan).unwrap();
}); });
let constellation_chan = result_port.recv().unwrap(); let constellation_chan = result_port.recv().unwrap();

Просмотреть файл

@ -26,7 +26,7 @@ pub struct MemoryProfilerChan(pub Sender<MemoryProfilerMsg>);
impl MemoryProfilerChan { impl MemoryProfilerChan {
pub fn send(&self, msg: MemoryProfilerMsg) { pub fn send(&self, msg: MemoryProfilerMsg) {
let MemoryProfilerChan(ref c) = *self; let MemoryProfilerChan(ref c) = *self;
c.send(msg); c.send(msg).unwrap();
} }
} }

Просмотреть файл

@ -37,7 +37,7 @@ pub fn spawn_named_with_send_on_failure<F, T>(name: &'static str,
Ok(()) => (), Ok(()) => (),
Err(..) => { Err(..) => {
debug!("{} failed, notifying constellation", name); debug!("{} failed, notifying constellation", name);
dest.send(msg); dest.send(msg).unwrap();
} }
} }
}); });

Просмотреть файл

@ -54,6 +54,6 @@ impl TaskPool {
pub fn execute<F>(&self, job: F) pub fn execute<F>(&self, job: F)
where F: FnOnce() + Send where F: FnOnce() + Send
{ {
self.tx.send(Thunk::new(job)); self.tx.send(Thunk::new(job)).unwrap();
} }
} }

Просмотреть файл

@ -24,7 +24,7 @@ pub struct TimeProfilerChan(pub Sender<TimeProfilerMsg>);
impl TimeProfilerChan { impl TimeProfilerChan {
pub fn send(&self, msg: TimeProfilerMsg) { pub fn send(&self, msg: TimeProfilerMsg) {
let TimeProfilerChan(ref c) = *self; let TimeProfilerChan(ref c) = *self;
c.send(msg); c.send(msg).unwrap();
} }
} }

Просмотреть файл

@ -675,7 +675,7 @@ unsafe impl Send for GlutinCompositorProxy {}
impl CompositorProxy for GlutinCompositorProxy { impl CompositorProxy for GlutinCompositorProxy {
fn send(&mut self, msg: compositor_task::Msg) { fn send(&mut self, msg: compositor_task::Msg) {
// Send a message and kick the OS event loop awake. // Send a message and kick the OS event loop awake.
self.sender.send(msg); self.sender.send(msg).unwrap();
match self.window_proxy { match self.window_proxy {
Some(ref window_proxy) => window_proxy.wakeup_event_loop(), Some(ref window_proxy) => window_proxy.wakeup_event_loop(),
None => {} None => {}