mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
servo: Merge #9201 - task -> thread (from ajnirp:8512-task-thread); r=jdm
for #8512 Source-Repo: https://github.com/servo/servo Source-Revision: d3e2f94f2024f4735f836588ed11303a0abafdf8 --HG-- rename : servo/components/canvas/canvas_paint_task.rs => servo/components/canvas/canvas_paint_thread.rs rename : servo/components/canvas/webgl_paint_task.rs => servo/components/canvas/webgl_paint_thread.rs rename : servo/components/compositing/compositor_task.rs => servo/components/compositing/compositor_thread.rs rename : servo/components/gfx/font_cache_task.rs => servo/components/gfx/font_cache_thread.rs rename : servo/components/gfx/paint_task.rs => servo/components/gfx/paint_thread.rs rename : servo/components/layout/layout_task.rs => servo/components/layout/layout_thread.rs rename : servo/components/net/image_cache_task.rs => servo/components/net/image_cache_thread.rs rename : servo/components/net/resource_task.rs => servo/components/net/resource_thread.rs rename : servo/components/net/storage_task.rs => servo/components/net/storage_thread.rs rename : servo/components/net_traits/image_cache_task.rs => servo/components/net_traits/image_cache_thread.rs rename : servo/components/net_traits/storage_task.rs => servo/components/net_traits/storage_thread.rs rename : servo/components/script/script_task.rs => servo/components/script/script_thread.rs rename : servo/components/util/task.rs => servo/components/util/thread.rs rename : servo/tests/unit/gfx/font_cache_task.rs => servo/tests/unit/gfx/font_cache_thread.rs rename : servo/tests/unit/net/resource_task.rs => servo/tests/unit/net/resource_thread.rs rename : servo/tests/unit/util/task.rs => servo/tests/unit/util/thread.rs
This commit is contained in:
parent
561a84a40d
commit
d440ee6a41
@ -22,10 +22,10 @@ use std::borrow::ToOwned;
|
||||
use std::mem;
|
||||
use std::sync::mpsc::{Sender, channel};
|
||||
use util::opts;
|
||||
use util::task::spawn_named;
|
||||
use util::thread::spawn_named;
|
||||
use util::vec::byte_swap;
|
||||
|
||||
impl<'a> CanvasPaintTask<'a> {
|
||||
impl<'a> CanvasPaintThread<'a> {
|
||||
/// It reads image data from the canvas
|
||||
/// canvas_size: The size of the canvas we're reading from
|
||||
/// read_rect: The area of the canvas we want to read from
|
||||
@ -57,7 +57,7 @@ impl<'a> CanvasPaintTask<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct CanvasPaintTask<'a> {
|
||||
pub struct CanvasPaintThread<'a> {
|
||||
drawtarget: DrawTarget,
|
||||
/// TODO(pcwalton): Support multiple paths.
|
||||
path_builder: PathBuilder,
|
||||
@ -101,11 +101,11 @@ impl<'a> CanvasPaintState<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> CanvasPaintTask<'a> {
|
||||
fn new(size: Size2D<i32>) -> CanvasPaintTask<'a> {
|
||||
let draw_target = CanvasPaintTask::create(size);
|
||||
impl<'a> CanvasPaintThread<'a> {
|
||||
fn new(size: Size2D<i32>) -> CanvasPaintThread<'a> {
|
||||
let draw_target = CanvasPaintThread::create(size);
|
||||
let path_builder = draw_target.create_path_builder();
|
||||
CanvasPaintTask {
|
||||
CanvasPaintThread {
|
||||
drawtarget: draw_target,
|
||||
path_builder: path_builder,
|
||||
state: CanvasPaintState::new(),
|
||||
@ -113,7 +113,7 @@ impl<'a> CanvasPaintTask<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates a new `CanvasPaintTask` and returns the out-of-process sender and the in-process
|
||||
/// Creates a new `CanvasPaintThread` and returns the out-of-process sender and the in-process
|
||||
/// sender for it.
|
||||
pub fn start(size: Size2D<i32>) -> (IpcSender<CanvasMsg>, Sender<CanvasMsg>) {
|
||||
// TODO(pcwalton): Ask the pipeline to create this for us instead of spawning it directly.
|
||||
@ -121,8 +121,8 @@ impl<'a> CanvasPaintTask<'a> {
|
||||
let (out_of_process_chan, out_of_process_port) = ipc::channel::<CanvasMsg>().unwrap();
|
||||
let (in_process_chan, in_process_port) = channel();
|
||||
ROUTER.route_ipc_receiver_to_mpsc_sender(out_of_process_port, in_process_chan.clone());
|
||||
spawn_named("CanvasTask".to_owned(), move || {
|
||||
let mut painter = CanvasPaintTask::new(size);
|
||||
spawn_named("CanvasThread".to_owned(), move || {
|
||||
let mut painter = CanvasPaintThread::new(size);
|
||||
loop {
|
||||
let msg = in_process_port.recv();
|
||||
match msg.unwrap() {
|
||||
@ -202,7 +202,7 @@ impl<'a> CanvasPaintTask<'a> {
|
||||
}
|
||||
}
|
||||
}
|
||||
CanvasMsg::WebGL(_) => panic!("Wrong message sent to Canvas2D task"),
|
||||
CanvasMsg::WebGL(_) => panic!("Wrong message sent to Canvas2D thread"),
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -516,7 +516,7 @@ impl<'a> CanvasPaintTask<'a> {
|
||||
}
|
||||
|
||||
fn recreate(&mut self, size: Size2D<i32>) {
|
||||
self.drawtarget = CanvasPaintTask::create(size);
|
||||
self.drawtarget = CanvasPaintThread::create(size);
|
||||
}
|
||||
|
||||
fn send_pixel_contents(&mut self, chan: IpcSender<IpcSharedMemory>) {
|
@ -22,6 +22,6 @@ extern crate num;
|
||||
extern crate offscreen_gl_context;
|
||||
extern crate util;
|
||||
|
||||
pub mod canvas_paint_task;
|
||||
pub mod canvas_paint_thread;
|
||||
mod premultiplytable;
|
||||
pub mod webgl_paint_task;
|
||||
pub mod webgl_paint_thread;
|
||||
|
@ -14,17 +14,17 @@ use layers::platform::surface::NativeSurface;
|
||||
use offscreen_gl_context::{ColorAttachmentType, GLContext, GLContextAttributes, NativeGLContext};
|
||||
use std::borrow::ToOwned;
|
||||
use std::sync::mpsc::{Sender, channel};
|
||||
use util::task::spawn_named;
|
||||
use util::thread::spawn_named;
|
||||
use util::vec::byte_swap;
|
||||
|
||||
pub struct WebGLPaintTask {
|
||||
pub struct WebGLPaintThread {
|
||||
size: Size2D<i32>,
|
||||
original_context_size: Size2D<i32>,
|
||||
gl_context: GLContext<NativeGLContext>,
|
||||
}
|
||||
|
||||
impl WebGLPaintTask {
|
||||
fn new(size: Size2D<i32>, attrs: GLContextAttributes) -> Result<WebGLPaintTask, &'static str> {
|
||||
impl WebGLPaintThread {
|
||||
fn new(size: Size2D<i32>, attrs: GLContextAttributes) -> Result<WebGLPaintThread, &'static str> {
|
||||
let context = try!(GLContext::new(size, attrs, ColorAttachmentType::Texture, None));
|
||||
|
||||
// NOTE: As of right now this is always equal to the size parameter,
|
||||
@ -32,7 +32,7 @@ impl WebGLPaintTask {
|
||||
// the requested size, tries with the nearest powers of two, for example.
|
||||
let real_size = context.borrow_draw_buffer().unwrap().size();
|
||||
|
||||
Ok(WebGLPaintTask {
|
||||
Ok(WebGLPaintThread {
|
||||
size: real_size,
|
||||
original_context_size: real_size,
|
||||
gl_context: context
|
||||
@ -183,7 +183,7 @@ impl WebGLPaintTask {
|
||||
assert!(gl::get_error() == gl::NO_ERROR);
|
||||
}
|
||||
|
||||
/// Creates a new `WebGLPaintTask` and returns the out-of-process sender and the in-process
|
||||
/// Creates a new `WebGLPaintThread` and returns the out-of-process sender and the in-process
|
||||
/// sender for it.
|
||||
pub fn start(size: Size2D<i32>, attrs: GLContextAttributes)
|
||||
-> Result<(IpcSender<CanvasMsg>, Sender<CanvasMsg>), &'static str> {
|
||||
@ -191,11 +191,11 @@ impl WebGLPaintTask {
|
||||
let (in_process_chan, in_process_port) = channel();
|
||||
let (result_chan, result_port) = channel();
|
||||
ROUTER.route_ipc_receiver_to_mpsc_sender(out_of_process_port, in_process_chan.clone());
|
||||
spawn_named("WebGLTask".to_owned(), move || {
|
||||
let mut painter = match WebGLPaintTask::new(size, attrs) {
|
||||
Ok(task) => {
|
||||
spawn_named("WebGLThread".to_owned(), move || {
|
||||
let mut painter = match WebGLPaintThread::new(size, attrs) {
|
||||
Ok(thread) => {
|
||||
result_chan.send(Ok(())).unwrap();
|
||||
task
|
||||
thread
|
||||
},
|
||||
Err(e) => {
|
||||
result_chan.send(Err(e)).unwrap();
|
||||
@ -225,7 +225,7 @@ impl WebGLPaintTask {
|
||||
painter.send_native_surface(chan),
|
||||
}
|
||||
}
|
||||
CanvasMsg::Canvas2d(_) => panic!("Wrong message sent to WebGLTask"),
|
||||
CanvasMsg::Canvas2d(_) => panic!("Wrong message sent to WebGLThread"),
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -279,7 +279,7 @@ impl WebGLPaintTask {
|
||||
}
|
||||
|
||||
fn create_texture(&self, chan: IpcSender<Option<NonZero<u32>>>) {
|
||||
let texture = gl::gen_textures(1)[0];
|
||||
let texture = gl::gen_framebuffers(1)[0];
|
||||
let texture = if texture == 0 {
|
||||
None
|
||||
} else {
|
@ -5,15 +5,15 @@
|
||||
use CompositorMsg as ConstellationMsg;
|
||||
use app_units::Au;
|
||||
use compositor_layer::{CompositorData, CompositorLayer, RcCompositorLayer, WantsScrollEventsFlag};
|
||||
use compositor_task::{CompositorEventListener, CompositorProxy};
|
||||
use compositor_task::{CompositorReceiver, InitialCompositorState, Msg};
|
||||
use compositor_thread::{CompositorEventListener, CompositorProxy};
|
||||
use compositor_thread::{CompositorReceiver, InitialCompositorState, Msg};
|
||||
use constellation::SendableFrameTree;
|
||||
use euclid::point::TypedPoint2D;
|
||||
use euclid::rect::TypedRect;
|
||||
use euclid::scale_factor::ScaleFactor;
|
||||
use euclid::size::TypedSize2D;
|
||||
use euclid::{Matrix4, Point2D, Rect, Size2D};
|
||||
use gfx::paint_task::{ChromeToPaintMsg, PaintRequest};
|
||||
use gfx::paint_thread::{ChromeToPaintMsg, PaintRequest};
|
||||
use gfx_traits::{color, LayerId, LayerKind, LayerProperties, ScrollPolicy};
|
||||
use gleam::gl;
|
||||
use gleam::gl::types::{GLint, GLsizei};
|
||||
@ -375,13 +375,13 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||
pub fn finish_shutting_down(&mut self) {
|
||||
debug!("Compositor received message that constellation shutdown is complete");
|
||||
|
||||
// Clear out the compositor layers so that painting tasks can destroy the buffers.
|
||||
// Clear out the compositor layers so that painting threads can destroy the buffers.
|
||||
if let Some(ref root_layer) = self.scene.root {
|
||||
root_layer.forget_all_tiles();
|
||||
}
|
||||
|
||||
// Drain compositor port, sometimes messages contain channels that are blocking
|
||||
// another task from finishing (i.e. SetFrameTree).
|
||||
// another thread from finishing (i.e. SetFrameTree).
|
||||
while self.port.try_recv_compositor_msg().is_some() {}
|
||||
|
||||
// Tell the profiler, memory profiler, and scrolling timer to shut down.
|
||||
@ -546,7 +546,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||
reply.send(img).unwrap();
|
||||
}
|
||||
|
||||
(Msg::PaintTaskExited(pipeline_id), ShutdownState::NotShuttingDown) => {
|
||||
(Msg::PaintThreadExited(pipeline_id), ShutdownState::NotShuttingDown) => {
|
||||
self.remove_pipeline_root_layer(pipeline_id);
|
||||
}
|
||||
|
||||
@ -580,7 +580,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||
}
|
||||
|
||||
(Msg::CollectMemoryReports(reports_chan), ShutdownState::NotShuttingDown) => {
|
||||
let name = "compositor-task";
|
||||
let name = "compositor-thread";
|
||||
// These are both `ExplicitUnknownLocationSize` because the memory might be in the
|
||||
// GPU or on the heap.
|
||||
let reports = vec![mem::Report {
|
||||
@ -975,7 +975,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||
epoch: Epoch,
|
||||
frame_tree_id: FrameTreeId) {
|
||||
// If the frame tree id has changed since this paint request was sent,
|
||||
// reject the buffers and send them back to the paint task. If this isn't handled
|
||||
// reject the buffers and send them back to the paint thread. If this isn't handled
|
||||
// correctly, the content_age in the tile grid can get out of sync when iframes are
|
||||
// loaded and the frame tree changes. This can result in the compositor thinking it
|
||||
// has already drawn the most recently painted buffer, and missing a frame.
|
||||
@ -1470,7 +1470,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||
}
|
||||
};
|
||||
|
||||
// All the BufferRequests are in layer/device coordinates, but the paint task
|
||||
// All the BufferRequests are in layer/device coordinates, but the paint thread
|
||||
// wants to know the page coordinates. We scale them before sending them.
|
||||
for request in &mut layer_requests {
|
||||
request.page_rect = request.page_rect / scale.get();
|
||||
@ -1568,7 +1568,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||
// If a layer has sent a request for the current epoch, but it hasn't
|
||||
// arrived yet then this layer is waiting for a paint message.
|
||||
//
|
||||
// Also don't check the root layer, because the paint task won't paint
|
||||
// Also don't check the root layer, because the paint thread won't paint
|
||||
// anything for it after first layout.
|
||||
if layer_data.id != LayerId::null() &&
|
||||
layer_data.requested_epoch == current_epoch &&
|
||||
@ -1587,7 +1587,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||
|
||||
/// Query the constellation to see if the current compositor
|
||||
/// output matches the current frame tree output, and if the
|
||||
/// associated script tasks are idle.
|
||||
/// associated script threads are idle.
|
||||
fn is_ready_to_paint_image_output(&mut self) -> Result<(), NotReadyToPaint> {
|
||||
match self.ready_to_save_state {
|
||||
ReadyState::Unknown => {
|
||||
@ -2001,7 +2001,7 @@ fn find_layer_with_pipeline_and_layer_id_for_layer(layer: Rc<Layer<CompositorDat
|
||||
|
||||
impl<Window> CompositorEventListener for IOCompositor<Window> where Window: WindowMethods {
|
||||
fn handle_events(&mut self, messages: Vec<WindowEvent>) -> bool {
|
||||
// Check for new messages coming from the other tasks in the system.
|
||||
// Check for new messages coming from the other threads in the system.
|
||||
while let Some(msg) = self.port.try_recv_compositor_msg() {
|
||||
if !self.handle_browser_message(msg) {
|
||||
break
|
||||
|
@ -97,17 +97,17 @@ pub trait CompositorLayer {
|
||||
|
||||
/// Removes the root layer (and any children) for a given pipeline from the
|
||||
/// compositor. Buffers that the compositor is holding are returned to the
|
||||
/// owning paint task.
|
||||
/// owning paint thread.
|
||||
fn remove_root_layer_with_pipeline_id<Window>(&self,
|
||||
compositor: &mut IOCompositor<Window>,
|
||||
pipeline_id: PipelineId)
|
||||
where Window: WindowMethods;
|
||||
|
||||
/// Destroys all tiles of all layers, including children, *without* sending them back to the
|
||||
/// painter. You must call this only when the paint task is destined to be going down;
|
||||
/// painter. You must call this only when the paint thread is destined to be going down;
|
||||
/// otherwise, you will leak tiles.
|
||||
///
|
||||
/// This is used during shutdown, when we know the paint task is going away.
|
||||
/// This is used during shutdown, when we know the paint thread is going away.
|
||||
fn forget_all_tiles(&self);
|
||||
|
||||
/// Move the layer's descendants that don't want scroll events and scroll by a relative
|
||||
@ -280,7 +280,7 @@ impl CompositorLayer for Layer<CompositorData> {
|
||||
|
||||
match index {
|
||||
Some(index) => {
|
||||
// Remove the root layer, and return buffers to the paint task
|
||||
// Remove the root layer, and return buffers to the paint thread
|
||||
let child = self.children().remove(index);
|
||||
child.clear_all_tiles(compositor);
|
||||
}
|
||||
@ -294,10 +294,10 @@ impl CompositorLayer for Layer<CompositorData> {
|
||||
}
|
||||
|
||||
/// Destroys all tiles of all layers, including children, *without* sending them back to the
|
||||
/// painter. You must call this only when the paint task is destined to be going down;
|
||||
/// painter. You must call this only when the paint thread is destined to be going down;
|
||||
/// otherwise, you will leak tiles.
|
||||
///
|
||||
/// This is used during shutdown, when we know the paint task is going away.
|
||||
/// This is used during shutdown, when we know the paint thread is going away.
|
||||
fn forget_all_tiles(&self) {
|
||||
let tiles = self.collect_buffers();
|
||||
for tile in tiles {
|
||||
|
@ -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/. */
|
||||
|
||||
//! Communication with the compositor task.
|
||||
//! Communication with the compositor thread.
|
||||
|
||||
use CompositorMsg as ConstellationMsg;
|
||||
use compositor;
|
||||
@ -107,10 +107,10 @@ impl PaintListener for Box<CompositorProxy + 'static + Send> {
|
||||
fn native_display(&mut self) -> Option<NativeDisplay> {
|
||||
let (chan, port) = channel();
|
||||
self.send(Msg::GetNativeDisplay(chan));
|
||||
// If the compositor is shutting down when a paint task
|
||||
// If the compositor is shutting down when a paint thread
|
||||
// is being created, the compositor won't respond to
|
||||
// this message, resulting in an eventual panic. Instead,
|
||||
// just return None in this case, since the paint task
|
||||
// just return None in this case, since the paint thread
|
||||
// will exit shortly and never actually be requested
|
||||
// to paint buffers by the compositor.
|
||||
port.recv().unwrap_or(None)
|
||||
@ -146,12 +146,12 @@ impl PaintListener for Box<CompositorProxy + 'static + Send> {
|
||||
self.send(Msg::InitializeLayersForPipeline(pipeline_id, epoch, properties));
|
||||
}
|
||||
|
||||
fn notify_paint_task_exiting(&mut self, pipeline_id: PipelineId) {
|
||||
self.send(Msg::PaintTaskExited(pipeline_id))
|
||||
fn notify_paint_thread_exiting(&mut self, pipeline_id: PipelineId) {
|
||||
self.send(Msg::PaintThreadExited(pipeline_id))
|
||||
}
|
||||
}
|
||||
|
||||
/// Messages from the painting task and the constellation task to the compositor task.
|
||||
/// Messages from the painting thread and the constellation thread to the compositor thread.
|
||||
pub enum Msg {
|
||||
/// Requests that the compositor shut down.
|
||||
Exit(IpcSender<()>),
|
||||
@ -199,8 +199,8 @@ pub enum Msg {
|
||||
SetCursor(Cursor),
|
||||
/// Composite to a PNG file and return the Image over a passed channel.
|
||||
CreatePng(IpcSender<Option<Image>>),
|
||||
/// Informs the compositor that the paint task for the given pipeline has exited.
|
||||
PaintTaskExited(PipelineId),
|
||||
/// Informs the compositor that the paint thread for the given pipeline has exited.
|
||||
PaintThreadExited(PipelineId),
|
||||
/// Alerts the compositor that the viewport has been constrained in some manner
|
||||
ViewportConstrained(PipelineId, ViewportConstraints),
|
||||
/// A reply to the compositor asking if the output image is stable.
|
||||
@ -209,7 +209,7 @@ pub enum Msg {
|
||||
NewFavicon(Url),
|
||||
/// <head> tag finished parsing
|
||||
HeadParsed,
|
||||
/// Signal that the paint task ignored the paint requests that carried
|
||||
/// Signal that the paint thread ignored the paint requests that carried
|
||||
/// these native surfaces, so that they can be re-added to the surface cache.
|
||||
ReturnUnusedNativeSurfaces(Vec<NativeSurface>),
|
||||
/// Collect memory reports and send them back to the given mem::ReportsChan.
|
||||
@ -247,7 +247,7 @@ impl Debug for Msg {
|
||||
Msg::TouchEventProcessed(..) => write!(f, "TouchEventProcessed"),
|
||||
Msg::SetCursor(..) => write!(f, "SetCursor"),
|
||||
Msg::CreatePng(..) => write!(f, "CreatePng"),
|
||||
Msg::PaintTaskExited(..) => write!(f, "PaintTaskExited"),
|
||||
Msg::PaintThreadExited(..) => write!(f, "PaintThreadExited"),
|
||||
Msg::ViewportConstrained(..) => write!(f, "ViewportConstrained"),
|
||||
Msg::IsReadyToSaveImageReply(..) => write!(f, "IsReadyToSaveImageReply"),
|
||||
Msg::NewFavicon(..) => write!(f, "NewFavicon"),
|
||||
@ -263,9 +263,9 @@ impl Debug for Msg {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct CompositorTask;
|
||||
pub struct CompositorThread;
|
||||
|
||||
impl CompositorTask {
|
||||
impl CompositorThread {
|
||||
pub fn create<Window>(window: Option<Rc<Window>>,
|
||||
state: InitialCompositorState)
|
||||
-> Box<CompositorEventListener + 'static>
|
@ -6,26 +6,26 @@
|
||||
//!
|
||||
//! The primary duty of a `Constellation` is to mediate between the
|
||||
//! graphics compositor and the many `Pipeline`s in the browser's
|
||||
//! navigation context, each `Pipeline` encompassing a `ScriptTask`,
|
||||
//! `LayoutTask`, and `PaintTask`.
|
||||
//! navigation context, each `Pipeline` encompassing a `ScriptThread`,
|
||||
//! `LayoutThread`, and `PaintThread`.
|
||||
|
||||
use CompositorMsg as FromCompositorMsg;
|
||||
use canvas::canvas_paint_task::CanvasPaintTask;
|
||||
use canvas::webgl_paint_task::WebGLPaintTask;
|
||||
use canvas::canvas_paint_thread::CanvasPaintThread;
|
||||
use canvas::webgl_paint_thread::WebGLPaintThread;
|
||||
use canvas_traits::CanvasMsg;
|
||||
use clipboard::ClipboardContext;
|
||||
use compositor_task::CompositorProxy;
|
||||
use compositor_task::Msg as ToCompositorMsg;
|
||||
use compositor_thread::CompositorProxy;
|
||||
use compositor_thread::Msg as ToCompositorMsg;
|
||||
use devtools_traits::{ChromeToDevtoolsControlMsg, DevtoolsControlMsg};
|
||||
use euclid::scale_factor::ScaleFactor;
|
||||
use euclid::size::{Size2D, TypedSize2D};
|
||||
use gaol;
|
||||
use gaol::sandbox::{self, Sandbox, SandboxMethods};
|
||||
use gfx::font_cache_task::FontCacheTask;
|
||||
use gfx::font_cache_thread::FontCacheThread;
|
||||
use gfx_traits::PaintMsg as FromPaintMsg;
|
||||
use ipc_channel::ipc::{self, IpcOneShotServer, IpcSender};
|
||||
use ipc_channel::router::ROUTER;
|
||||
use layout_traits::{LayoutControlChan, LayoutTaskFactory};
|
||||
use layout_traits::{LayoutControlChan, LayoutThreadFactory};
|
||||
use msg::compositor_msg::Epoch;
|
||||
use msg::constellation_msg::AnimationState;
|
||||
use msg::constellation_msg::WebDriverCommandMsg;
|
||||
@ -36,16 +36,16 @@ use msg::constellation_msg::{PipelineNamespace, PipelineNamespaceId};
|
||||
use msg::constellation_msg::{SubpageId, WindowSizeData};
|
||||
use msg::constellation_msg::{self, ConstellationChan, Failure};
|
||||
use msg::webdriver_msg;
|
||||
use net_traits::image_cache_task::ImageCacheTask;
|
||||
use net_traits::storage_task::{StorageTask, StorageTaskMsg};
|
||||
use net_traits::{self, ResourceTask};
|
||||
use net_traits::image_cache_thread::ImageCacheThread;
|
||||
use net_traits::storage_thread::{StorageThread, StorageThreadMsg};
|
||||
use net_traits::{self, ResourceThread};
|
||||
use offscreen_gl_context::GLContextAttributes;
|
||||
use pipeline::{CompositionPipeline, InitialPipelineState, Pipeline, UnprivilegedPipelineContent};
|
||||
use profile_traits::mem;
|
||||
use profile_traits::time;
|
||||
use sandboxing;
|
||||
use script_traits::{CompositorEvent, ConstellationControlMsg, LayoutControlMsg};
|
||||
use script_traits::{LayoutMsg as FromLayoutMsg, ScriptMsg as FromScriptMsg, ScriptTaskFactory};
|
||||
use script_traits::{LayoutMsg as FromLayoutMsg, ScriptMsg as FromScriptMsg, ScriptThreadFactory};
|
||||
use script_traits::{TimerEventRequest};
|
||||
use std::borrow::ToOwned;
|
||||
use std::collections::HashMap;
|
||||
@ -60,7 +60,7 @@ use timer_scheduler::TimerScheduler;
|
||||
use url::Url;
|
||||
use util::cursor::Cursor;
|
||||
use util::geometry::PagePx;
|
||||
use util::task::spawn_named;
|
||||
use util::thread::spawn_named;
|
||||
use util::{opts, prefs};
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
@ -76,9 +76,9 @@ enum ReadyToSave {
|
||||
|
||||
/// Maintains the pipelines and navigation context and grants permission to composite.
|
||||
///
|
||||
/// It is parameterized over a `LayoutTaskFactory` and a
|
||||
/// `ScriptTaskFactory` (which in practice are implemented by
|
||||
/// `LayoutTask` in the `layout` crate, and `ScriptTask` in
|
||||
/// It is parameterized over a `LayoutThreadFactory` and a
|
||||
/// `ScriptThreadFactory` (which in practice are implemented by
|
||||
/// `LayoutThread` in the `layout` crate, and `ScriptThread` in
|
||||
/// the `script` crate).
|
||||
pub struct Constellation<LTF, STF> {
|
||||
/// A channel through which script messages can be sent to this object.
|
||||
@ -87,10 +87,10 @@ pub struct Constellation<LTF, STF> {
|
||||
/// A channel through which compositor messages can be sent to this object.
|
||||
pub compositor_sender: Sender<FromCompositorMsg>,
|
||||
|
||||
/// A channel through which layout task messages can be sent to this object.
|
||||
/// A channel through which layout thread messages can be sent to this object.
|
||||
pub layout_sender: ConstellationChan<FromLayoutMsg>,
|
||||
|
||||
/// A channel through which paint task messages can be sent to this object.
|
||||
/// A channel through which paint thread messages can be sent to this object.
|
||||
pub painter_sender: ConstellationChan<FromPaintMsg>,
|
||||
|
||||
/// Receives messages from scripts.
|
||||
@ -99,27 +99,27 @@ pub struct Constellation<LTF, STF> {
|
||||
/// Receives messages from the compositor
|
||||
pub compositor_receiver: Receiver<FromCompositorMsg>,
|
||||
|
||||
/// Receives messages from the layout task
|
||||
/// Receives messages from the layout thread
|
||||
pub layout_receiver: Receiver<FromLayoutMsg>,
|
||||
|
||||
/// Receives messages from paint task.
|
||||
/// Receives messages from paint thread.
|
||||
pub painter_receiver: Receiver<FromPaintMsg>,
|
||||
|
||||
/// A channel (the implementation of which is port-specific) through which messages can be sent
|
||||
/// to the compositor.
|
||||
pub compositor_proxy: Box<CompositorProxy>,
|
||||
|
||||
/// A channel through which messages can be sent to the resource task.
|
||||
pub resource_task: ResourceTask,
|
||||
/// A channel through which messages can be sent to the resource thread.
|
||||
pub resource_thread: ResourceThread,
|
||||
|
||||
/// A channel through which messages can be sent to the image cache task.
|
||||
pub image_cache_task: ImageCacheTask,
|
||||
/// A channel through which messages can be sent to the image cache thread.
|
||||
pub image_cache_thread: ImageCacheThread,
|
||||
|
||||
/// A channel through which messages can be sent to the developer tools.
|
||||
devtools_chan: Option<Sender<DevtoolsControlMsg>>,
|
||||
|
||||
/// A channel through which messages can be sent to the storage task.
|
||||
storage_task: StorageTask,
|
||||
/// A channel through which messages can be sent to the storage thread.
|
||||
storage_thread: StorageThread,
|
||||
|
||||
/// A list of all the pipelines. (See the `pipeline` module for more details.)
|
||||
pipelines: HashMap<PipelineId, Pipeline>,
|
||||
@ -134,7 +134,7 @@ pub struct Constellation<LTF, STF> {
|
||||
subpage_map: HashMap<(PipelineId, SubpageId), PipelineId>,
|
||||
|
||||
/// A channel through which messages can be sent to the font cache.
|
||||
font_cache_task: FontCacheTask,
|
||||
font_cache_thread: FontCacheThread,
|
||||
|
||||
/// ID of the root frame.
|
||||
root_frame_id: Option<FrameId>,
|
||||
@ -167,11 +167,11 @@ pub struct Constellation<LTF, STF> {
|
||||
/// Bits of state used to interact with the webdriver implementation
|
||||
webdriver: WebDriverData,
|
||||
|
||||
/// A list of in-process senders to `CanvasPaintTask`s.
|
||||
canvas_paint_tasks: Vec<Sender<CanvasMsg>>,
|
||||
/// A list of in-process senders to `CanvasPaintThread`s.
|
||||
canvas_paint_threads: Vec<Sender<CanvasMsg>>,
|
||||
|
||||
/// A list of in-process senders to `WebGLPaintTask`s.
|
||||
webgl_paint_tasks: Vec<Sender<CanvasMsg>>,
|
||||
/// A list of in-process senders to `WebGLPaintThread`s.
|
||||
webgl_paint_threads: Vec<Sender<CanvasMsg>>,
|
||||
|
||||
scheduler_chan: IpcSender<TimerEventRequest>,
|
||||
|
||||
@ -188,14 +188,14 @@ pub struct InitialConstellationState {
|
||||
pub compositor_proxy: Box<CompositorProxy + Send>,
|
||||
/// A channel to the developer tools, if applicable.
|
||||
pub devtools_chan: Option<Sender<DevtoolsControlMsg>>,
|
||||
/// A channel to the image cache task.
|
||||
pub image_cache_task: ImageCacheTask,
|
||||
/// A channel to the font cache task.
|
||||
pub font_cache_task: FontCacheTask,
|
||||
/// A channel to the resource task.
|
||||
pub resource_task: ResourceTask,
|
||||
/// A channel to the storage task.
|
||||
pub storage_task: StorageTask,
|
||||
/// A channel to the image cache thread.
|
||||
pub image_cache_thread: ImageCacheThread,
|
||||
/// A channel to the font cache thread.
|
||||
pub font_cache_thread: FontCacheThread,
|
||||
/// A channel to the resource thread.
|
||||
pub resource_thread: ResourceThread,
|
||||
/// A channel to the storage thread.
|
||||
pub storage_thread: StorageThread,
|
||||
/// A channel to the time profiler thread.
|
||||
pub time_profiler_chan: time::ProfilerChan,
|
||||
/// A channel to the memory profiler thread.
|
||||
@ -288,7 +288,7 @@ enum ChildProcess {
|
||||
Unsandboxed(process::Child),
|
||||
}
|
||||
|
||||
impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||
impl<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF> {
|
||||
pub fn start(state: InitialConstellationState) -> Sender<FromCompositorMsg> {
|
||||
let (ipc_script_receiver, ipc_script_sender) = ConstellationChan::<FromScriptMsg>::new();
|
||||
let script_receiver = ROUTER.route_ipc_receiver_to_new_mpsc_receiver(ipc_script_receiver);
|
||||
@ -310,10 +310,10 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||
painter_receiver: painter_receiver,
|
||||
compositor_proxy: state.compositor_proxy,
|
||||
devtools_chan: state.devtools_chan,
|
||||
resource_task: state.resource_task,
|
||||
image_cache_task: state.image_cache_task,
|
||||
font_cache_task: state.font_cache_task,
|
||||
storage_task: state.storage_task,
|
||||
resource_thread: state.resource_thread,
|
||||
image_cache_thread: state.image_cache_thread,
|
||||
font_cache_thread: state.font_cache_thread,
|
||||
storage_thread: state.storage_thread,
|
||||
pipelines: HashMap::new(),
|
||||
frames: HashMap::new(),
|
||||
pipeline_to_frame_map: HashMap::new(),
|
||||
@ -340,8 +340,8 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||
None
|
||||
},
|
||||
webdriver: WebDriverData::new(),
|
||||
canvas_paint_tasks: Vec::new(),
|
||||
webgl_paint_tasks: Vec::new(),
|
||||
canvas_paint_threads: Vec::new(),
|
||||
webgl_paint_threads: Vec::new(),
|
||||
scheduler_chan: TimerScheduler::start(),
|
||||
child_processes: Vec::new(),
|
||||
document_states: HashMap::new(),
|
||||
@ -386,10 +386,10 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||
scheduler_chan: self.scheduler_chan.clone(),
|
||||
compositor_proxy: self.compositor_proxy.clone_compositor_proxy(),
|
||||
devtools_chan: self.devtools_chan.clone(),
|
||||
image_cache_task: self.image_cache_task.clone(),
|
||||
font_cache_task: self.font_cache_task.clone(),
|
||||
resource_task: self.resource_task.clone(),
|
||||
storage_task: self.storage_task.clone(),
|
||||
image_cache_thread: self.image_cache_thread.clone(),
|
||||
font_cache_thread: self.font_cache_thread.clone(),
|
||||
resource_thread: self.resource_thread.clone(),
|
||||
storage_thread: self.storage_thread.clone(),
|
||||
time_profiler_chan: self.time_profiler_chan.clone(),
|
||||
mem_profiler_chan: self.mem_profiler_chan.clone(),
|
||||
window_size: initial_window_size,
|
||||
@ -400,7 +400,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||
});
|
||||
|
||||
if spawning_paint_only {
|
||||
privileged_pipeline_content.start_paint_task();
|
||||
privileged_pipeline_content.start_paint_thread();
|
||||
} else {
|
||||
privileged_pipeline_content.start_all();
|
||||
|
||||
@ -681,13 +681,13 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||
debug!("constellation got head parsed message");
|
||||
self.compositor_proxy.send(ToCompositorMsg::HeadParsed);
|
||||
}
|
||||
Request::Script(FromScriptMsg::CreateCanvasPaintTask(size, sender)) => {
|
||||
debug!("constellation got create-canvas-paint-task message");
|
||||
self.handle_create_canvas_paint_task_msg(&size, sender)
|
||||
Request::Script(FromScriptMsg::CreateCanvasPaintThread(size, sender)) => {
|
||||
debug!("constellation got create-canvas-paint-thread message");
|
||||
self.handle_create_canvas_paint_thread_msg(&size, sender)
|
||||
}
|
||||
Request::Script(FromScriptMsg::CreateWebGLPaintTask(size, attributes, sender)) => {
|
||||
debug!("constellation got create-WebGL-paint-task message");
|
||||
self.handle_create_webgl_paint_task_msg(&size, attributes, sender)
|
||||
Request::Script(FromScriptMsg::CreateWebGLPaintThread(size, attributes, sender)) => {
|
||||
debug!("constellation got create-WebGL-paint-thread message");
|
||||
self.handle_create_webgl_paint_thread_msg(&size, attributes, sender)
|
||||
}
|
||||
Request::Script(FromScriptMsg::NodeStatus(message)) => {
|
||||
debug!("constellation got NodeStatus message");
|
||||
@ -699,7 +699,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||
}
|
||||
|
||||
|
||||
// Messages from layout task
|
||||
// Messages from layout thread
|
||||
|
||||
Request::Layout(FromLayoutMsg::ChangeRunningAnimationsState(pipeline_id, animation_state)) => {
|
||||
self.handle_change_running_animations_state(pipeline_id, animation_state)
|
||||
@ -717,7 +717,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||
}
|
||||
|
||||
|
||||
// Messages from paint task
|
||||
// Messages from paint thread
|
||||
|
||||
|
||||
// Notification that painting has finished and is requesting permission to paint.
|
||||
@ -734,14 +734,14 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||
for (_id, ref pipeline) in &self.pipelines {
|
||||
pipeline.exit();
|
||||
}
|
||||
self.image_cache_task.exit();
|
||||
self.resource_task.send(net_traits::ControlMsg::Exit).unwrap();
|
||||
self.image_cache_thread.exit();
|
||||
self.resource_thread.send(net_traits::ControlMsg::Exit).unwrap();
|
||||
self.devtools_chan.as_ref().map(|chan| {
|
||||
chan.send(DevtoolsControlMsg::FromChrome(
|
||||
ChromeToDevtoolsControlMsg::ServerExitMsg)).unwrap();
|
||||
});
|
||||
self.storage_task.send(StorageTaskMsg::Exit).unwrap();
|
||||
self.font_cache_task.exit();
|
||||
self.storage_thread.send(StorageThreadMsg::Exit).unwrap();
|
||||
self.font_cache_thread.exit();
|
||||
self.compositor_proxy.send(ToCompositorMsg::ShutdownComplete);
|
||||
}
|
||||
|
||||
@ -749,7 +749,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||
pipeline_id: PipelineId,
|
||||
parent_info: Option<(PipelineId, SubpageId)>) {
|
||||
if opts::get().hard_fail {
|
||||
// It's quite difficult to make Servo exit cleanly if some tasks have failed.
|
||||
// It's quite difficult to make Servo exit cleanly if some threads have failed.
|
||||
// Hard fail exists for test runners so we crash and that's good enough.
|
||||
let mut stderr = io::stderr();
|
||||
stderr.write_all("Pipeline failed in hard-fail mode. Crashing!\n".as_bytes()).unwrap();
|
||||
@ -825,7 +825,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||
parent_pipeline.script_chan.send(msg).unwrap();
|
||||
}
|
||||
|
||||
// The script task associated with pipeline_id has loaded a URL in an iframe via script. This
|
||||
// The script thread associated with pipeline_id has loaded a URL in an iframe via script. This
|
||||
// will result in a new pipeline being spawned and a frame tree being added to
|
||||
// containing_page_pipeline_id's frame tree's children. This message is never the result of a
|
||||
// page navigation.
|
||||
@ -842,7 +842,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||
};
|
||||
|
||||
// Compare the pipeline's url to the new url. If the origin is the same,
|
||||
// then reuse the script task in creating the new pipeline
|
||||
// then reuse the script thread in creating the new pipeline
|
||||
let script_chan = {
|
||||
let source_pipeline = self.pipeline(load_info.containing_pipeline_id);
|
||||
|
||||
@ -853,7 +853,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||
load_info.sandbox == IFrameSandboxState::IFrameUnsandboxed;
|
||||
|
||||
// FIXME(tkuehn): Need to follow the standardized spec for checking same-origin
|
||||
// Reuse the script task if the URL is same-origin
|
||||
// Reuse the script thread if the URL is same-origin
|
||||
if same_script {
|
||||
debug!("Constellation: loading same-origin iframe, \
|
||||
parent url {:?}, iframe url {:?}", source_url, new_url);
|
||||
@ -910,13 +910,13 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||
|
||||
fn load_url(&mut self, source_id: PipelineId, load_data: LoadData) -> Option<PipelineId> {
|
||||
// If this load targets an iframe, its framing element may exist
|
||||
// in a separate script task than the framed document that initiated
|
||||
// in a separate script thread than the framed document that initiated
|
||||
// the new load. The framing element must be notified about the
|
||||
// requested change so it can update its internal state.
|
||||
match self.pipeline(source_id).parent_info {
|
||||
Some((parent_pipeline_id, subpage_id)) => {
|
||||
self.handle_load_start_msg(&source_id);
|
||||
// Message the constellation to find the script task for this iframe
|
||||
// Message the constellation to find the script thread for this iframe
|
||||
// and issue an iframe load through there.
|
||||
let parent_pipeline = self.pipeline(parent_pipeline_id);
|
||||
let script_channel = &parent_pipeline.script_chan;
|
||||
@ -944,7 +944,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||
self.new_pipeline(new_pipeline_id, None, window_size, None, load_data);
|
||||
self.push_pending_frame(new_pipeline_id, Some(source_id));
|
||||
|
||||
// Send message to ScriptTask that will suspend all timers
|
||||
// Send message to ScriptThread that will suspend all timers
|
||||
let old_pipeline = self.pipelines.get(&source_id).unwrap();
|
||||
old_pipeline.freeze();
|
||||
Some(new_pipeline_id)
|
||||
@ -1111,7 +1111,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||
assert!(prefs::get_pref("dom.mozbrowser.enabled").as_boolean().unwrap_or(false));
|
||||
|
||||
// Find the script channel for the given parent pipeline,
|
||||
// and pass the event to that script task.
|
||||
// and pass the event to that script thread.
|
||||
let pipeline = self.pipeline(containing_pipeline_id);
|
||||
pipeline.trigger_mozbrowser_event(subpage_id, event);
|
||||
}
|
||||
@ -1171,25 +1171,25 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_create_canvas_paint_task_msg(
|
||||
fn handle_create_canvas_paint_thread_msg(
|
||||
&mut self,
|
||||
size: &Size2D<i32>,
|
||||
response_sender: IpcSender<(IpcSender<CanvasMsg>, usize)>) {
|
||||
let id = self.canvas_paint_tasks.len();
|
||||
let (out_of_process_sender, in_process_sender) = CanvasPaintTask::start(*size);
|
||||
self.canvas_paint_tasks.push(in_process_sender);
|
||||
let id = self.canvas_paint_threads.len();
|
||||
let (out_of_process_sender, in_process_sender) = CanvasPaintThread::start(*size);
|
||||
self.canvas_paint_threads.push(in_process_sender);
|
||||
response_sender.send((out_of_process_sender, id)).unwrap()
|
||||
}
|
||||
|
||||
fn handle_create_webgl_paint_task_msg(
|
||||
fn handle_create_webgl_paint_thread_msg(
|
||||
&mut self,
|
||||
size: &Size2D<i32>,
|
||||
attributes: GLContextAttributes,
|
||||
response_sender: IpcSender<Result<(IpcSender<CanvasMsg>, usize), String>>) {
|
||||
let response = match WebGLPaintTask::start(*size, attributes) {
|
||||
let response = match WebGLPaintThread::start(*size, attributes) {
|
||||
Ok((out_of_process_sender, in_process_sender)) => {
|
||||
let id = self.webgl_paint_tasks.len();
|
||||
self.webgl_paint_tasks.push(in_process_sender);
|
||||
let id = self.webgl_paint_threads.len();
|
||||
self.webgl_paint_threads.push(in_process_sender);
|
||||
Ok((out_of_process_sender, id))
|
||||
},
|
||||
Err(msg) => Err(msg.to_owned()),
|
||||
@ -1200,7 +1200,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||
|
||||
fn handle_webdriver_msg(&mut self, msg: WebDriverCommandMsg) {
|
||||
// Find the script channel for the given parent pipeline,
|
||||
// and pass the event to that script task.
|
||||
// and pass the event to that script thread.
|
||||
match msg {
|
||||
WebDriverCommandMsg::LoadUrl(pipeline_id, load_data, reply) => {
|
||||
self.load_url_for_webdriver(pipeline_id, load_data, reply);
|
||||
@ -1404,7 +1404,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||
}
|
||||
|
||||
// Step through the current frame tree, checking that the script
|
||||
// task is idle, and that the current epoch of the layout task
|
||||
// thread is idle, and that the current epoch of the layout thread
|
||||
// matches what the compositor has painted. If all these conditions
|
||||
// are met, then the output image should not change and a reftest
|
||||
// screenshot can safely be written.
|
||||
@ -1441,7 +1441,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||
if let Some(size) = pipeline.size {
|
||||
// If the rectangle for this pipeline is zero sized, it will
|
||||
// never be painted. In this case, don't query the layout
|
||||
// task as it won't contribute to the final output image.
|
||||
// thread as it won't contribute to the final output image.
|
||||
if size == Size2D::zero() {
|
||||
continue;
|
||||
}
|
||||
@ -1450,15 +1450,15 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||
let compositor_epoch = pipeline_states.get(&frame.current);
|
||||
match compositor_epoch {
|
||||
Some(compositor_epoch) => {
|
||||
// Synchronously query the layout task to see if the current
|
||||
// Synchronously query the layout thread to see if the current
|
||||
// epoch matches what the compositor has drawn. If they match
|
||||
// (and script is idle) then this pipeline won't change again
|
||||
// and can be considered stable.
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
let LayoutControlChan(ref layout_chan) = pipeline.layout_chan;
|
||||
layout_chan.send(LayoutControlMsg::GetCurrentEpoch(sender)).unwrap();
|
||||
let layout_task_epoch = receiver.recv().unwrap();
|
||||
if layout_task_epoch != *compositor_epoch {
|
||||
let layout_thread_epoch = receiver.recv().unwrap();
|
||||
if layout_thread_epoch != *compositor_epoch {
|
||||
return ReadyToSave::EpochMismatch;
|
||||
}
|
||||
}
|
||||
@ -1471,7 +1471,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||
}
|
||||
}
|
||||
|
||||
// All script tasks are idle and layout epochs match compositor, so output image!
|
||||
// All script threads are idle and layout epochs match compositor, so output image!
|
||||
ReadyToSave::Ready
|
||||
}
|
||||
|
||||
|
@ -3,8 +3,8 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use CompositorMsg as ConstellationMsg;
|
||||
use compositor_task::{CompositorEventListener, CompositorReceiver};
|
||||
use compositor_task::{InitialCompositorState, Msg};
|
||||
use compositor_thread::{CompositorEventListener, CompositorReceiver};
|
||||
use compositor_thread::{InitialCompositorState, Msg};
|
||||
use euclid::scale_factor::ScaleFactor;
|
||||
use euclid::{Point2D, Size2D};
|
||||
use msg::constellation_msg::AnimationState;
|
||||
@ -70,7 +70,7 @@ impl CompositorEventListener for NullCompositor {
|
||||
debug!("constellation completed shutdown");
|
||||
|
||||
// Drain compositor port, sometimes messages contain channels that are blocking
|
||||
// another task from finishing (i.e. SetIds)
|
||||
// another thread from finishing (i.e. SetIds)
|
||||
while self.port.try_recv_compositor_msg().is_some() {}
|
||||
|
||||
self.time_profiler_chan.send(time::ProfilerMsg::Exit);
|
||||
@ -123,7 +123,7 @@ impl CompositorEventListener for NullCompositor {
|
||||
Msg::SetCursor(..) |
|
||||
Msg::ViewportConstrained(..) => {}
|
||||
Msg::CreatePng(..) |
|
||||
Msg::PaintTaskExited(..) |
|
||||
Msg::PaintThreadExited(..) |
|
||||
Msg::MoveTo(..) |
|
||||
Msg::ResizeTo(..) |
|
||||
Msg::IsReadyToSaveImageReply(..) => {}
|
||||
|
@ -50,7 +50,7 @@ extern crate url;
|
||||
#[macro_use]
|
||||
extern crate util;
|
||||
|
||||
pub use compositor_task::{CompositorEventListener, CompositorProxy, CompositorTask};
|
||||
pub use compositor_thread::{CompositorEventListener, CompositorProxy, CompositorThread};
|
||||
pub use constellation::Constellation;
|
||||
use euclid::size::{Size2D};
|
||||
use ipc_channel::ipc::{IpcSender};
|
||||
@ -63,7 +63,7 @@ use url::Url;
|
||||
|
||||
mod compositor;
|
||||
mod compositor_layer;
|
||||
pub mod compositor_task;
|
||||
pub mod compositor_thread;
|
||||
pub mod constellation;
|
||||
mod headless;
|
||||
pub mod pipeline;
|
||||
|
@ -3,29 +3,29 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use CompositorProxy;
|
||||
use compositor_task;
|
||||
use compositor_task::Msg as CompositorMsg;
|
||||
use compositor_thread;
|
||||
use compositor_thread::Msg as CompositorMsg;
|
||||
use devtools_traits::{DevtoolsControlMsg, ScriptToDevtoolsControlMsg};
|
||||
use euclid::scale_factor::ScaleFactor;
|
||||
use euclid::size::TypedSize2D;
|
||||
use gfx::font_cache_task::FontCacheTask;
|
||||
use gfx::paint_task::{ChromeToPaintMsg, LayoutToPaintMsg, PaintTask};
|
||||
use gfx::font_cache_thread::FontCacheThread;
|
||||
use gfx::paint_thread::{ChromeToPaintMsg, LayoutToPaintMsg, PaintThread};
|
||||
use gfx_traits::PaintMsg;
|
||||
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
|
||||
use ipc_channel::router::ROUTER;
|
||||
use layers::geometry::DevicePixel;
|
||||
use layout_traits::{LayoutControlChan, LayoutTaskFactory};
|
||||
use layout_traits::{LayoutControlChan, LayoutThreadFactory};
|
||||
use msg::constellation_msg::{ConstellationChan, Failure, FrameId, PipelineId, SubpageId};
|
||||
use msg::constellation_msg::{LoadData, MozBrowserEvent, WindowSizeData};
|
||||
use msg::constellation_msg::{PipelineNamespaceId};
|
||||
use net_traits::ResourceTask;
|
||||
use net_traits::image_cache_task::ImageCacheTask;
|
||||
use net_traits::storage_task::StorageTask;
|
||||
use net_traits::ResourceThread;
|
||||
use net_traits::image_cache_thread::ImageCacheThread;
|
||||
use net_traits::storage_thread::StorageThread;
|
||||
use profile_traits::mem as profile_mem;
|
||||
use profile_traits::time;
|
||||
use script_traits::{ConstellationControlMsg, InitialScriptState};
|
||||
use script_traits::{LayoutControlMsg, LayoutMsg, NewLayoutInfo, ScriptMsg};
|
||||
use script_traits::{ScriptToCompositorMsg, ScriptTaskFactory, TimerEventRequest};
|
||||
use script_traits::{ScriptToCompositorMsg, ScriptThreadFactory, TimerEventRequest};
|
||||
use std::mem;
|
||||
use std::sync::mpsc::{Receiver, Sender, channel};
|
||||
use std::thread;
|
||||
@ -36,7 +36,7 @@ use util::ipc::OptionalIpcSender;
|
||||
use util::opts::{self, Opts};
|
||||
use util::prefs;
|
||||
|
||||
/// A uniquely-identifiable pipeline of script task, layout task, and paint task.
|
||||
/// A uniquely-identifiable pipeline of script thread, layout thread, and paint thread.
|
||||
pub struct Pipeline {
|
||||
pub id: PipelineId,
|
||||
pub parent_info: Option<(PipelineId, SubpageId)>,
|
||||
@ -80,9 +80,9 @@ pub struct InitialPipelineState {
|
||||
pub parent_info: Option<(PipelineId, SubpageId)>,
|
||||
/// A channel to the associated constellation.
|
||||
pub constellation_chan: ConstellationChan<ScriptMsg>,
|
||||
/// A channel for the layout task to send messages to the constellation.
|
||||
/// A channel for the layout thread to send messages to the constellation.
|
||||
pub layout_to_constellation_chan: ConstellationChan<LayoutMsg>,
|
||||
/// A channel to the associated paint task.
|
||||
/// A channel to the associated paint thread.
|
||||
pub painter_chan: ConstellationChan<PaintMsg>,
|
||||
/// A channel to schedule timer events.
|
||||
pub scheduler_chan: IpcSender<TimerEventRequest>,
|
||||
@ -90,14 +90,14 @@ pub struct InitialPipelineState {
|
||||
pub compositor_proxy: Box<CompositorProxy + 'static + Send>,
|
||||
/// A channel to the developer tools, if applicable.
|
||||
pub devtools_chan: Option<Sender<DevtoolsControlMsg>>,
|
||||
/// A channel to the image cache task.
|
||||
pub image_cache_task: ImageCacheTask,
|
||||
/// A channel to the font cache task.
|
||||
pub font_cache_task: FontCacheTask,
|
||||
/// A channel to the resource task.
|
||||
pub resource_task: ResourceTask,
|
||||
/// A channel to the storage task.
|
||||
pub storage_task: StorageTask,
|
||||
/// A channel to the image cache thread.
|
||||
pub image_cache_thread: ImageCacheThread,
|
||||
/// A channel to the font cache thread.
|
||||
pub font_cache_thread: FontCacheThread,
|
||||
/// A channel to the resource thread.
|
||||
pub resource_thread: ResourceThread,
|
||||
/// A channel to the storage thread.
|
||||
pub storage_thread: StorageThread,
|
||||
/// A channel to the time profiler thread.
|
||||
pub time_profiler_chan: time::ProfilerChan,
|
||||
/// A channel to the memory profiler thread.
|
||||
@ -116,11 +116,11 @@ pub struct InitialPipelineState {
|
||||
}
|
||||
|
||||
impl Pipeline {
|
||||
/// Starts a paint task, layout task, and possibly a script task.
|
||||
/// Starts a paint thread, layout thread, and possibly a script thread.
|
||||
/// Returns the channels wrapped in a struct.
|
||||
pub fn create<LTF, STF>(state: InitialPipelineState)
|
||||
-> (Pipeline, UnprivilegedPipelineContent, PrivilegedPipelineContent)
|
||||
where LTF: LayoutTaskFactory, STF: ScriptTaskFactory {
|
||||
where LTF: LayoutThreadFactory, STF: ScriptThreadFactory {
|
||||
let (layout_to_paint_chan, layout_to_paint_port) = util::ipc::optional_ipc_channel();
|
||||
let (chrome_to_paint_chan, chrome_to_paint_port) = channel();
|
||||
let (paint_shutdown_chan, paint_shutdown_port) = ipc::channel().unwrap();
|
||||
@ -202,10 +202,10 @@ impl Pipeline {
|
||||
constellation_chan: state.constellation_chan,
|
||||
scheduler_chan: state.scheduler_chan,
|
||||
devtools_chan: script_to_devtools_chan,
|
||||
image_cache_task: state.image_cache_task,
|
||||
font_cache_task: state.font_cache_task.clone(),
|
||||
resource_task: state.resource_task,
|
||||
storage_task: state.storage_task,
|
||||
image_cache_thread: state.image_cache_thread,
|
||||
font_cache_thread: state.font_cache_thread.clone(),
|
||||
resource_thread: state.resource_thread,
|
||||
storage_thread: state.storage_thread,
|
||||
time_profiler_chan: state.time_profiler_chan.clone(),
|
||||
mem_profiler_chan: state.mem_profiler_chan.clone(),
|
||||
window_size: window_size,
|
||||
@ -231,7 +231,7 @@ impl Pipeline {
|
||||
id: state.id,
|
||||
painter_chan: state.painter_chan,
|
||||
compositor_proxy: state.compositor_proxy,
|
||||
font_cache_task: state.font_cache_task,
|
||||
font_cache_thread: state.font_cache_thread,
|
||||
time_profiler_chan: state.time_profiler_chan,
|
||||
mem_profiler_chan: state.mem_profiler_chan,
|
||||
load_data: state.load_data,
|
||||
@ -286,13 +286,13 @@ impl Pipeline {
|
||||
pub fn exit(&self) {
|
||||
debug!("pipeline {:?} exiting", self.id);
|
||||
|
||||
// Script task handles shutting down layout, and layout handles shutting down the painter.
|
||||
// For now, if the script task has failed, we give up on clean shutdown.
|
||||
// Script thread handles shutting down layout, and layout handles shutting down the painter.
|
||||
// For now, if the script thread has failed, we give up on clean shutdown.
|
||||
if self.script_chan
|
||||
.send(ConstellationControlMsg::ExitPipeline(self.id))
|
||||
.is_ok() {
|
||||
// Wait until all slave tasks have terminated and run destructors
|
||||
// NOTE: We don't wait for script task as we don't always own it
|
||||
// Wait until all slave threads have terminated and run destructors
|
||||
// NOTE: We don't wait for script thread as we don't always own it
|
||||
let _ = self.paint_shutdown_port.recv();
|
||||
let _ = self.layout_shutdown_port.recv();
|
||||
}
|
||||
@ -355,10 +355,10 @@ pub struct UnprivilegedPipelineContent {
|
||||
scheduler_chan: IpcSender<TimerEventRequest>,
|
||||
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
|
||||
script_to_compositor_chan: IpcSender<ScriptToCompositorMsg>,
|
||||
image_cache_task: ImageCacheTask,
|
||||
font_cache_task: FontCacheTask,
|
||||
resource_task: ResourceTask,
|
||||
storage_task: StorageTask,
|
||||
image_cache_thread: ImageCacheThread,
|
||||
font_cache_thread: FontCacheThread,
|
||||
resource_thread: ResourceThread,
|
||||
storage_thread: StorageThread,
|
||||
time_profiler_chan: time::ProfilerChan,
|
||||
mem_profiler_chan: profile_mem::ProfilerChan,
|
||||
window_size: Option<WindowSizeData>,
|
||||
@ -380,10 +380,10 @@ pub struct UnprivilegedPipelineContent {
|
||||
|
||||
impl UnprivilegedPipelineContent {
|
||||
pub fn start_all<LTF, STF>(mut self, wait_for_completion: bool)
|
||||
where LTF: LayoutTaskFactory, STF: ScriptTaskFactory {
|
||||
let layout_pair = ScriptTaskFactory::create_layout_channel(None::<&mut STF>);
|
||||
where LTF: LayoutThreadFactory, STF: ScriptThreadFactory {
|
||||
let layout_pair = ScriptThreadFactory::create_layout_channel(None::<&mut STF>);
|
||||
|
||||
ScriptTaskFactory::create(None::<&mut STF>, InitialScriptState {
|
||||
ScriptThreadFactory::create(None::<&mut STF>, InitialScriptState {
|
||||
id: self.id,
|
||||
parent_info: self.parent_info,
|
||||
compositor: self.script_to_compositor_chan,
|
||||
@ -393,9 +393,9 @@ impl UnprivilegedPipelineContent {
|
||||
layout_to_constellation_chan: self.layout_to_constellation_chan.clone(),
|
||||
scheduler_chan: self.scheduler_chan.clone(),
|
||||
failure_info: self.failure.clone(),
|
||||
resource_task: self.resource_task,
|
||||
storage_task: self.storage_task.clone(),
|
||||
image_cache_task: self.image_cache_task.clone(),
|
||||
resource_thread: self.resource_thread,
|
||||
storage_thread: self.storage_thread.clone(),
|
||||
image_cache_thread: self.image_cache_thread.clone(),
|
||||
time_profiler_chan: self.time_profiler_chan.clone(),
|
||||
mem_profiler_chan: self.mem_profiler_chan.clone(),
|
||||
devtools_chan: self.devtools_chan,
|
||||
@ -404,7 +404,7 @@ impl UnprivilegedPipelineContent {
|
||||
content_process_shutdown_chan: self.script_content_process_shutdown_chan.clone(),
|
||||
}, &layout_pair, self.load_data.clone());
|
||||
|
||||
LayoutTaskFactory::create(None::<&mut LTF>,
|
||||
LayoutThreadFactory::create(None::<&mut LTF>,
|
||||
self.id,
|
||||
self.load_data.url.clone(),
|
||||
self.parent_info.is_some(),
|
||||
@ -414,8 +414,8 @@ impl UnprivilegedPipelineContent {
|
||||
self.failure,
|
||||
self.script_chan.clone(),
|
||||
self.layout_to_paint_chan.clone(),
|
||||
self.image_cache_task,
|
||||
self.font_cache_task,
|
||||
self.image_cache_thread,
|
||||
self.font_cache_thread,
|
||||
self.time_profiler_chan,
|
||||
self.mem_profiler_chan,
|
||||
self.layout_shutdown_chan,
|
||||
@ -437,7 +437,7 @@ pub struct PrivilegedPipelineContent {
|
||||
painter_chan: ConstellationChan<PaintMsg>,
|
||||
compositor_proxy: Box<CompositorProxy + Send + 'static>,
|
||||
script_to_compositor_port: IpcReceiver<ScriptToCompositorMsg>,
|
||||
font_cache_task: FontCacheTask,
|
||||
font_cache_thread: FontCacheThread,
|
||||
time_profiler_chan: time::ProfilerChan,
|
||||
mem_profiler_chan: profile_mem::ProfilerChan,
|
||||
load_data: LoadData,
|
||||
@ -450,14 +450,14 @@ pub struct PrivilegedPipelineContent {
|
||||
|
||||
impl PrivilegedPipelineContent {
|
||||
pub fn start_all(self) {
|
||||
PaintTask::create(self.id,
|
||||
PaintThread::create(self.id,
|
||||
self.load_data.url,
|
||||
self.chrome_to_paint_chan,
|
||||
self.layout_to_paint_port,
|
||||
self.chrome_to_paint_port,
|
||||
self.compositor_proxy.clone_compositor_proxy(),
|
||||
self.painter_chan,
|
||||
self.font_cache_task,
|
||||
self.font_cache_thread,
|
||||
self.failure,
|
||||
self.time_profiler_chan,
|
||||
self.mem_profiler_chan,
|
||||
@ -467,21 +467,21 @@ impl PrivilegedPipelineContent {
|
||||
self.compositor_proxy.clone_compositor_proxy();
|
||||
let script_to_compositor_port = self.script_to_compositor_port;
|
||||
thread::spawn(move || {
|
||||
compositor_task::run_script_listener_thread(
|
||||
compositor_thread::run_script_listener_thread(
|
||||
compositor_proxy_for_script_listener_thread,
|
||||
script_to_compositor_port)
|
||||
});
|
||||
}
|
||||
|
||||
pub fn start_paint_task(self) {
|
||||
PaintTask::create(self.id,
|
||||
pub fn start_paint_thread(self) {
|
||||
PaintThread::create(self.id,
|
||||
self.load_data.url,
|
||||
self.chrome_to_paint_chan,
|
||||
self.layout_to_paint_port,
|
||||
self.chrome_to_paint_port,
|
||||
self.compositor_proxy,
|
||||
self.painter_chan,
|
||||
self.font_cache_task,
|
||||
self.font_cache_thread,
|
||||
self.failure,
|
||||
self.time_profiler_chan,
|
||||
self.mem_profiler_chan,
|
||||
|
@ -2,9 +2,9 @@
|
||||
* 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/. */
|
||||
|
||||
//! A timer thread that gives the painting task a little time to catch up when the user scrolls.
|
||||
//! A timer thread that gives the painting thread a little time to catch up when the user scrolls.
|
||||
|
||||
use compositor_task::{CompositorProxy, Msg};
|
||||
use compositor_thread::{CompositorProxy, Msg};
|
||||
use std::sync::mpsc::{Receiver, Sender, channel};
|
||||
use std::thread::{self, Builder};
|
||||
use time;
|
||||
|
@ -9,7 +9,7 @@ use std::collections::hash_map::Entry::{Occupied, Vacant};
|
||||
use std::hash::{Hash, Hasher};
|
||||
|
||||
/// This is a struct used to store surfaces when they are not in use.
|
||||
/// The paint task can quickly query for a particular size of surface when it
|
||||
/// The paint thread can quickly query for a particular size of surface when it
|
||||
/// needs it.
|
||||
pub struct SurfaceMap {
|
||||
/// A HashMap that stores the Buffers.
|
||||
|
@ -16,7 +16,7 @@ use std::sync::atomic::{self, AtomicBool};
|
||||
use std::sync::mpsc::{channel, Receiver, Select};
|
||||
use std::thread::{self, spawn, Thread};
|
||||
use std::time::Duration;
|
||||
use util::task::spawn_named;
|
||||
use util::thread::spawn_named;
|
||||
|
||||
/// A quick hack to work around the removal of [`std::old_io::timer::Timer`](
|
||||
/// http://doc.rust-lang.org/1.0.0-beta/std/old_io/timer/struct.Timer.html )
|
||||
@ -129,8 +129,8 @@ impl TimerScheduler {
|
||||
}
|
||||
|
||||
fn run_event_loop(&self) {
|
||||
while let Some(task) = self.receive_next_task() {
|
||||
match task {
|
||||
while let Some(thread) = self.receive_next_task() {
|
||||
match thread {
|
||||
Task::HandleRequest(request) => self.handle_request(request),
|
||||
Task::DispatchDueEvents => self.dispatch_due_events(),
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
//! Abstract windowing methods. The concrete implementations of these can be found in `platform/`.
|
||||
|
||||
use compositor_task::{CompositorProxy, CompositorReceiver};
|
||||
use compositor_thread::{CompositorProxy, CompositorReceiver};
|
||||
use euclid::point::TypedPoint2D;
|
||||
use euclid::scale_factor::ScaleFactor;
|
||||
use euclid::size::TypedSize2D;
|
||||
@ -41,7 +41,7 @@ pub enum WindowEvent {
|
||||
///
|
||||
/// FIXME(pcwalton): This is kind of ugly and may not work well with multiprocess Servo.
|
||||
/// It's possible that this should be something like
|
||||
/// `CompositorMessageWindowEvent(compositor_task::Msg)` instead.
|
||||
/// `CompositorMessageWindowEvent(compositor_thread::Msg)` instead.
|
||||
Idle,
|
||||
/// Sent when part of the window is marked dirty and needs to be redrawn. Before sending this
|
||||
/// message, the window must make the same GL context as in `PrepareRenderingEvent` current.
|
||||
|
@ -18,7 +18,7 @@ use std::sync::mpsc::channel;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
use util::task;
|
||||
use util::thread::spawn_named;
|
||||
|
||||
pub struct TimelineActor {
|
||||
name: String,
|
||||
@ -147,7 +147,7 @@ impl TimelineActor {
|
||||
return;
|
||||
}
|
||||
|
||||
task::spawn_named("PullTimelineMarkers".to_owned(), move || {
|
||||
spawn_named("PullTimelineMarkers".to_owned(), move || {
|
||||
loop {
|
||||
if !*is_recording.lock().unwrap() {
|
||||
break;
|
||||
|
@ -58,7 +58,7 @@ use std::net::{Shutdown, TcpListener, TcpStream};
|
||||
use std::sync::mpsc::{Receiver, Sender, channel};
|
||||
use std::sync::{Arc, Mutex};
|
||||
use time::precise_time_ns;
|
||||
use util::task::spawn_named;
|
||||
use util::thread::spawn_named;
|
||||
|
||||
mod actor;
|
||||
/// Corresponds to http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/
|
||||
@ -506,7 +506,7 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
|
||||
|
||||
let sender_clone = sender.clone();
|
||||
spawn_named("DevtoolsClientAcceptor".to_owned(), move || {
|
||||
// accept connections and process them, spawning a new task for each one
|
||||
// accept connections and process them, spawning a new thread for each one
|
||||
for stream in listener.incoming() {
|
||||
// connection succeeded
|
||||
sender_clone.send(DevtoolsControlMsg::FromChrome(
|
||||
|
@ -48,9 +48,9 @@ pub struct DevtoolsPageInfo {
|
||||
/// Messages to instruct the devtools server to update its known actors/state
|
||||
/// according to changes in the browser.
|
||||
pub enum DevtoolsControlMsg {
|
||||
/// Messages from tasks in the chrome process (resource/constellation/devtools)
|
||||
/// Messages from threads in the chrome process (resource/constellation/devtools)
|
||||
FromChrome(ChromeToDevtoolsControlMsg),
|
||||
/// Messages from script tasks
|
||||
/// Messages from script threads
|
||||
FromScript(ScriptToDevtoolsControlMsg),
|
||||
}
|
||||
|
||||
@ -75,7 +75,7 @@ pub enum ScriptToDevtoolsControlMsg {
|
||||
DevtoolsPageInfo),
|
||||
/// A particular page has invoked the console API.
|
||||
ConsoleAPI(PipelineId, ConsoleMessage, Option<WorkerId>),
|
||||
/// An animation frame with the given timestamp was processed in a script task.
|
||||
/// An animation frame with the given timestamp was processed in a script thread.
|
||||
/// The actor with the provided name should be notified.
|
||||
FramerateTick(String, f64),
|
||||
}
|
||||
@ -149,7 +149,7 @@ pub struct ComputedNodeLayout {
|
||||
pub height: f32,
|
||||
}
|
||||
|
||||
/// Messages to process in a particular script task, as instructed by a devtools client.
|
||||
/// Messages to process in a particular script thread, as instructed by a devtools client.
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub enum DevtoolScriptControlMsg {
|
||||
/// Evaluate a JS snippet in the context of the global for the given pipeline.
|
||||
|
@ -25,7 +25,7 @@ use gfx_traits::{color, LayerId, LayerKind, ScrollPolicy};
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use net_traits::image::base::Image;
|
||||
use paint_context::PaintContext;
|
||||
use paint_task::{PaintLayerContents, PaintLayer};
|
||||
use paint_thread::{PaintLayerContents, PaintLayer};
|
||||
use self::DisplayItem::*;
|
||||
use self::DisplayItemIterator::*;
|
||||
use smallvec::SmallVec;
|
||||
@ -1140,7 +1140,7 @@ impl ClippingRegion {
|
||||
}
|
||||
|
||||
|
||||
/// Metadata attached to each display item. This is useful for performing auxiliary tasks with
|
||||
/// Metadata attached to each display item. This is useful for performing auxiliary threads with
|
||||
/// the display list involving hit testing: finding the originating DOM node and determining the
|
||||
/// cursor to use when the element is hovered over.
|
||||
#[derive(Clone, Copy, HeapSizeOf, Deserialize, Serialize)]
|
||||
|
@ -6,7 +6,7 @@ use font_template::{FontTemplate, FontTemplateDescriptor};
|
||||
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
|
||||
use ipc_channel::router::ROUTER;
|
||||
use mime::{TopLevel, SubLevel};
|
||||
use net_traits::{AsyncResponseTarget, LoadContext, PendingAsyncLoad, ResourceTask, ResponseAction};
|
||||
use net_traits::{AsyncResponseTarget, LoadContext, PendingAsyncLoad, ResourceThread, ResponseAction};
|
||||
use platform::font_context::FontContextHandle;
|
||||
use platform::font_list::for_each_available_family;
|
||||
use platform::font_list::for_each_variation;
|
||||
@ -24,7 +24,7 @@ use style::properties::longhands::font_family::computed_value::FontFamily;
|
||||
use url::Url;
|
||||
use util::prefs;
|
||||
use util::str::LowercaseString;
|
||||
use util::task::spawn_named;
|
||||
use util::thread::spawn_named;
|
||||
|
||||
/// A list of font templates that make up a given font family.
|
||||
struct FontTemplates {
|
||||
@ -79,7 +79,7 @@ impl FontTemplates {
|
||||
}
|
||||
}
|
||||
|
||||
/// Commands that the FontContext sends to the font cache task.
|
||||
/// Commands that the FontContext sends to the font cache thread.
|
||||
#[derive(Deserialize, Serialize, Debug)]
|
||||
pub enum Command {
|
||||
GetFontTemplate(FontFamily, FontTemplateDescriptor, IpcSender<Reply>),
|
||||
@ -89,13 +89,13 @@ pub enum Command {
|
||||
Exit(IpcSender<()>),
|
||||
}
|
||||
|
||||
/// Reply messages sent from the font cache task to the FontContext caller.
|
||||
/// Reply messages sent from the font cache thread to the FontContext caller.
|
||||
#[derive(Deserialize, Serialize, Debug)]
|
||||
pub enum Reply {
|
||||
GetFontTemplateReply(Option<Arc<FontTemplateData>>),
|
||||
}
|
||||
|
||||
/// The font cache task itself. It maintains a list of reference counted
|
||||
/// The font cache thread itself. It maintains a list of reference counted
|
||||
/// font templates that are currently in use.
|
||||
struct FontCache {
|
||||
port: IpcReceiver<Command>,
|
||||
@ -104,7 +104,7 @@ struct FontCache {
|
||||
local_families: HashMap<LowercaseString, FontTemplates>,
|
||||
web_families: HashMap<LowercaseString, FontTemplates>,
|
||||
font_context: FontContextHandle,
|
||||
resource_task: ResourceTask,
|
||||
resource_thread: ResourceThread,
|
||||
}
|
||||
|
||||
fn populate_generic_fonts() -> HashMap<FontFamily, LowercaseString> {
|
||||
@ -159,7 +159,7 @@ impl FontCache {
|
||||
Source::Url(ref url_source) => {
|
||||
let url = &url_source.url;
|
||||
let load = PendingAsyncLoad::new(LoadContext::Font,
|
||||
self.resource_task.clone(),
|
||||
self.resource_thread.clone(),
|
||||
url.clone(),
|
||||
None);
|
||||
let (data_sender, data_receiver) = ipc::channel().unwrap();
|
||||
@ -311,19 +311,19 @@ impl FontCache {
|
||||
}
|
||||
}
|
||||
|
||||
/// The public interface to the font cache task, used exclusively by
|
||||
/// the per-thread/task FontContext structures.
|
||||
/// The public interface to the font cache thread, used exclusively by
|
||||
/// the per-thread/thread FontContext structures.
|
||||
#[derive(Clone, Deserialize, Serialize, Debug)]
|
||||
pub struct FontCacheTask {
|
||||
pub struct FontCacheThread {
|
||||
chan: IpcSender<Command>,
|
||||
}
|
||||
|
||||
impl FontCacheTask {
|
||||
pub fn new(resource_task: ResourceTask) -> FontCacheTask {
|
||||
impl FontCacheThread {
|
||||
pub fn new(resource_thread: ResourceThread) -> FontCacheThread {
|
||||
let (chan, port) = ipc::channel().unwrap();
|
||||
|
||||
let channel_to_self = chan.clone();
|
||||
spawn_named("FontCacheTask".to_owned(), move || {
|
||||
spawn_named("FontCacheThread".to_owned(), move || {
|
||||
// TODO: Allow users to specify these.
|
||||
let generic_fonts = populate_generic_fonts();
|
||||
|
||||
@ -334,14 +334,14 @@ impl FontCacheTask {
|
||||
local_families: HashMap::new(),
|
||||
web_families: HashMap::new(),
|
||||
font_context: FontContextHandle::new(),
|
||||
resource_task: resource_task,
|
||||
resource_thread: resource_thread,
|
||||
};
|
||||
|
||||
cache.refresh_local_families();
|
||||
cache.run();
|
||||
});
|
||||
|
||||
FontCacheTask {
|
||||
FontCacheThread {
|
||||
chan: chan,
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@ use fnv::FnvHasher;
|
||||
use font::FontHandleMethods;
|
||||
use font::SpecifiedFontStyle;
|
||||
use font::{Font, FontGroup};
|
||||
use font_cache_task::FontCacheTask;
|
||||
use font_cache_thread::FontCacheThread;
|
||||
use font_template::FontTemplateDescriptor;
|
||||
use platform::font::FontHandle;
|
||||
use platform::font_context::FontContextHandle;
|
||||
@ -55,7 +55,7 @@ struct FallbackFontCacheEntry {
|
||||
font: Rc<RefCell<Font>>,
|
||||
}
|
||||
|
||||
/// A cached azure font (per paint task) that
|
||||
/// A cached azure font (per paint thread) that
|
||||
/// can be shared by multiple text runs.
|
||||
#[derive(Debug)]
|
||||
struct PaintFontCacheEntry {
|
||||
@ -68,14 +68,14 @@ struct PaintFontCacheEntry {
|
||||
/// this one.
|
||||
static FONT_CACHE_EPOCH: AtomicUsize = ATOMIC_USIZE_INIT;
|
||||
|
||||
/// The FontContext represents the per-thread/task state necessary for
|
||||
/// The FontContext represents the per-thread/thread state necessary for
|
||||
/// working with fonts. It is the public API used by the layout and
|
||||
/// paint code. It talks directly to the font cache task where
|
||||
/// paint code. It talks directly to the font cache thread where
|
||||
/// required.
|
||||
#[derive(Debug)]
|
||||
pub struct FontContext {
|
||||
platform_handle: FontContextHandle,
|
||||
font_cache_task: FontCacheTask,
|
||||
font_cache_thread: FontCacheThread,
|
||||
|
||||
/// TODO: See bug https://github.com/servo/servo/issues/3300.
|
||||
layout_font_cache: Vec<LayoutFontCacheEntry>,
|
||||
@ -92,11 +92,11 @@ pub struct FontContext {
|
||||
}
|
||||
|
||||
impl FontContext {
|
||||
pub fn new(font_cache_task: FontCacheTask) -> FontContext {
|
||||
pub fn new(font_cache_thread: FontCacheThread) -> FontContext {
|
||||
let handle = FontContextHandle::new();
|
||||
FontContext {
|
||||
platform_handle: handle,
|
||||
font_cache_task: font_cache_task,
|
||||
font_cache_thread: font_cache_thread,
|
||||
layout_font_cache: vec!(),
|
||||
fallback_font_cache: vec!(),
|
||||
paint_font_cache: vec!(),
|
||||
@ -202,7 +202,7 @@ impl FontContext {
|
||||
}
|
||||
|
||||
if !cache_hit {
|
||||
let font_template = self.font_cache_task.find_font_template(family.clone(),
|
||||
let font_template = self.font_cache_thread.find_font_template(family.clone(),
|
||||
desc.clone());
|
||||
match font_template {
|
||||
Some(font_template) => {
|
||||
@ -251,7 +251,7 @@ impl FontContext {
|
||||
}
|
||||
|
||||
if !cache_hit {
|
||||
let font_template = self.font_cache_task.last_resort_font_template(desc.clone());
|
||||
let font_template = self.font_cache_thread.last_resort_font_template(desc.clone());
|
||||
let layout_font = self.create_layout_font(font_template,
|
||||
desc.clone(),
|
||||
style.font_size,
|
||||
@ -296,9 +296,9 @@ impl FontContext {
|
||||
paint_font
|
||||
}
|
||||
|
||||
/// Returns a reference to the font cache task.
|
||||
pub fn font_cache_task(&self) -> FontCacheTask {
|
||||
self.font_cache_task.clone()
|
||||
/// Returns a reference to the font cache thread.
|
||||
pub fn font_cache_thread(&self) -> FontCacheThread {
|
||||
self.font_cache_thread.clone()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -91,11 +91,11 @@ pub mod display_list;
|
||||
|
||||
// Fonts
|
||||
pub mod font;
|
||||
pub mod font_cache_task;
|
||||
pub mod font_cache_thread;
|
||||
pub mod font_context;
|
||||
pub mod font_template;
|
||||
|
||||
pub mod paint_task;
|
||||
pub mod paint_thread;
|
||||
|
||||
// Platform-specific implementations.
|
||||
#[path = "platform/mod.rs"]
|
||||
|
@ -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/. */
|
||||
|
||||
//! The task that handles all painting.
|
||||
//! The thread that handles all painting.
|
||||
|
||||
use app_units::Au;
|
||||
use azure::AzFloat;
|
||||
@ -13,7 +13,7 @@ use euclid::Matrix4;
|
||||
use euclid::point::Point2D;
|
||||
use euclid::rect::Rect;
|
||||
use euclid::size::Size2D;
|
||||
use font_cache_task::FontCacheTask;
|
||||
use font_cache_thread::FontCacheThread;
|
||||
use font_context::FontContext;
|
||||
use gfx_traits::{color, LayerId, LayerKind, LayerProperties, PaintListener, PaintMsg as ConstellationMsg, ScrollPolicy};
|
||||
use ipc_channel::ipc::IpcSender;
|
||||
@ -34,8 +34,8 @@ use std::sync::mpsc::{Receiver, Select, Sender, channel};
|
||||
use url::Url;
|
||||
use util::geometry::{ExpandToPixelBoundaries};
|
||||
use util::opts;
|
||||
use util::task;
|
||||
use util::task_state;
|
||||
use util::thread;
|
||||
use util::thread_state;
|
||||
|
||||
#[derive(Clone, Deserialize, Serialize, HeapSizeOf)]
|
||||
pub enum PaintLayerContents {
|
||||
@ -43,7 +43,7 @@ pub enum PaintLayerContents {
|
||||
DisplayList(Arc<DisplayList>),
|
||||
}
|
||||
|
||||
/// Information about a hardware graphics layer that layout sends to the painting task.
|
||||
/// Information about a hardware graphics layer that layout sends to the painting thread.
|
||||
#[derive(Clone, Deserialize, Serialize, HeapSizeOf)]
|
||||
pub struct PaintLayer {
|
||||
/// A per-pipeline ID describing this layer that should be stable across reflows.
|
||||
@ -205,7 +205,7 @@ pub enum ChromeToPaintMsg {
|
||||
Exit,
|
||||
}
|
||||
|
||||
pub struct PaintTask<C> {
|
||||
pub struct PaintThread<C> {
|
||||
id: PipelineId,
|
||||
_url: Url,
|
||||
layout_to_paint_port: Receiver<LayoutToPaintMsg>,
|
||||
@ -221,7 +221,7 @@ pub struct PaintTask<C> {
|
||||
/// Permission to send paint messages to the compositor
|
||||
paint_permission: bool,
|
||||
|
||||
/// The current epoch counter is passed by the layout task
|
||||
/// The current epoch counter is passed by the layout thread
|
||||
current_epoch: Option<Epoch>,
|
||||
|
||||
/// Communication handles to each of the worker threads.
|
||||
@ -232,14 +232,14 @@ pub struct PaintTask<C> {
|
||||
}
|
||||
|
||||
// If we implement this as a function, we get borrowck errors from borrowing
|
||||
// the whole PaintTask struct.
|
||||
// the whole PaintThread struct.
|
||||
macro_rules! native_display(
|
||||
($task:expr) => (
|
||||
$task.native_display.as_ref().expect("Need a graphics context to do painting")
|
||||
($thread:expr) => (
|
||||
$thread.native_display.as_ref().expect("Need a graphics context to do painting")
|
||||
)
|
||||
);
|
||||
|
||||
impl<C> PaintTask<C> where C: PaintListener + Send + 'static {
|
||||
impl<C> PaintThread<C> where C: PaintListener + Send + 'static {
|
||||
pub fn create(id: PipelineId,
|
||||
url: Url,
|
||||
chrome_to_paint_chan: Sender<ChromeToPaintMsg>,
|
||||
@ -247,26 +247,26 @@ impl<C> PaintTask<C> where C: PaintListener + Send + 'static {
|
||||
chrome_to_paint_port: Receiver<ChromeToPaintMsg>,
|
||||
compositor: C,
|
||||
constellation_chan: ConstellationChan<ConstellationMsg>,
|
||||
font_cache_task: FontCacheTask,
|
||||
font_cache_thread: FontCacheThread,
|
||||
failure_msg: Failure,
|
||||
time_profiler_chan: time::ProfilerChan,
|
||||
mem_profiler_chan: mem::ProfilerChan,
|
||||
shutdown_chan: IpcSender<()>) {
|
||||
let ConstellationChan(c) = constellation_chan.clone();
|
||||
task::spawn_named_with_send_on_failure(format!("PaintTask {:?}", id),
|
||||
task_state::PAINT,
|
||||
thread::spawn_named_with_send_on_failure(format!("PaintThread {:?}", id),
|
||||
thread_state::PAINT,
|
||||
move || {
|
||||
{
|
||||
// Ensures that the paint task and graphics context are destroyed before the
|
||||
// Ensures that the paint thread and graphics context are destroyed before the
|
||||
// shutdown message.
|
||||
let mut compositor = compositor;
|
||||
let native_display = compositor.native_display().map(
|
||||
|display| display);
|
||||
let worker_threads = WorkerThreadProxy::spawn(native_display.clone(),
|
||||
font_cache_task,
|
||||
font_cache_thread,
|
||||
time_profiler_chan.clone());
|
||||
|
||||
let mut paint_task = PaintTask {
|
||||
let mut paint_thread = PaintThread {
|
||||
id: id,
|
||||
_url: url,
|
||||
layout_to_paint_port: layout_to_paint_port,
|
||||
@ -282,22 +282,22 @@ impl<C> PaintTask<C> where C: PaintListener + Send + 'static {
|
||||
|
||||
let reporter_name = format!("paint-reporter-{}", id);
|
||||
mem_profiler_chan.run_with_memory_reporting(|| {
|
||||
paint_task.start();
|
||||
paint_thread.start();
|
||||
}, reporter_name, chrome_to_paint_chan, ChromeToPaintMsg::CollectReports);
|
||||
|
||||
// Tell all the worker threads to shut down.
|
||||
for worker_thread in &mut paint_task.worker_threads {
|
||||
for worker_thread in &mut paint_thread.worker_threads {
|
||||
worker_thread.exit()
|
||||
}
|
||||
}
|
||||
|
||||
debug!("paint_task: shutdown_chan send");
|
||||
debug!("paint_thread: shutdown_chan send");
|
||||
shutdown_chan.send(()).unwrap();
|
||||
}, ConstellationMsg::Failure(failure_msg), c);
|
||||
}
|
||||
|
||||
fn start(&mut self) {
|
||||
debug!("PaintTask: beginning painting loop");
|
||||
debug!("PaintThread: beginning painting loop");
|
||||
|
||||
loop {
|
||||
let message = {
|
||||
@ -340,14 +340,14 @@ impl<C> PaintTask<C> where C: PaintListener + Send + 'static {
|
||||
if self.current_epoch == Some(epoch) {
|
||||
self.paint(&mut replies, buffer_requests, scale, layer_id, layer_kind);
|
||||
} else {
|
||||
debug!("PaintTask: Ignoring requests with epoch mismatch: {:?} != {:?}",
|
||||
debug!("PaintThread: Ignoring requests with epoch mismatch: {:?} != {:?}",
|
||||
self.current_epoch,
|
||||
epoch);
|
||||
self.compositor.ignore_buffer_requests(buffer_requests);
|
||||
}
|
||||
}
|
||||
|
||||
debug!("PaintTask: returning surfaces");
|
||||
debug!("PaintThread: returning surfaces");
|
||||
self.compositor.assign_painted_buffers(self.id,
|
||||
self.current_epoch.unwrap(),
|
||||
replies,
|
||||
@ -365,24 +365,24 @@ impl<C> PaintTask<C> where C: PaintListener + Send + 'static {
|
||||
self.paint_permission = false;
|
||||
}
|
||||
Msg::FromChrome(ChromeToPaintMsg::CollectReports(ref channel)) => {
|
||||
// FIXME(njn): should eventually measure the paint task.
|
||||
// FIXME(njn): should eventually measure the paint thread.
|
||||
channel.send(Vec::new())
|
||||
}
|
||||
Msg::FromLayout(LayoutToPaintMsg::Exit(ref response_channel)) => {
|
||||
// Ask the compositor to remove any layers it is holding for this paint task.
|
||||
// Ask the compositor to remove any layers it is holding for this paint thread.
|
||||
// FIXME(mrobinson): This can probably move back to the constellation now.
|
||||
self.compositor.notify_paint_task_exiting(self.id);
|
||||
self.compositor.notify_paint_thread_exiting(self.id);
|
||||
|
||||
debug!("PaintTask: Exiting.");
|
||||
debug!("PaintThread: Exiting.");
|
||||
let _ = response_channel.send(());
|
||||
break;
|
||||
}
|
||||
Msg::FromChrome(ChromeToPaintMsg::Exit) => {
|
||||
// Ask the compositor to remove any layers it is holding for this paint task.
|
||||
// Ask the compositor to remove any layers it is holding for this paint thread.
|
||||
// FIXME(mrobinson): This can probably move back to the constellation now.
|
||||
self.compositor.notify_paint_task_exiting(self.id);
|
||||
self.compositor.notify_paint_thread_exiting(self.id);
|
||||
|
||||
debug!("PaintTask: Exiting.");
|
||||
debug!("PaintThread: Exiting.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -546,7 +546,7 @@ struct WorkerThreadProxy {
|
||||
|
||||
impl WorkerThreadProxy {
|
||||
fn spawn(native_display: Option<NativeDisplay>,
|
||||
font_cache_task: FontCacheTask,
|
||||
font_cache_thread: FontCacheThread,
|
||||
time_profiler_chan: time::ProfilerChan)
|
||||
-> Vec<WorkerThreadProxy> {
|
||||
let thread_count = if opts::get().gpu_painting {
|
||||
@ -557,13 +557,13 @@ impl WorkerThreadProxy {
|
||||
(0..thread_count).map(|_| {
|
||||
let (from_worker_sender, from_worker_receiver) = channel();
|
||||
let (to_worker_sender, to_worker_receiver) = channel();
|
||||
let font_cache_task = font_cache_task.clone();
|
||||
let font_cache_thread = font_cache_thread.clone();
|
||||
let time_profiler_chan = time_profiler_chan.clone();
|
||||
task::spawn_named("PaintWorker".to_owned(), move || {
|
||||
thread::spawn_named("PaintWorker".to_owned(), move || {
|
||||
let mut worker_thread = WorkerThread::new(from_worker_sender,
|
||||
to_worker_receiver,
|
||||
native_display,
|
||||
font_cache_task,
|
||||
font_cache_thread,
|
||||
time_profiler_chan);
|
||||
worker_thread.main();
|
||||
});
|
||||
@ -629,7 +629,7 @@ impl WorkerThread {
|
||||
fn new(sender: Sender<MsgFromWorkerThread>,
|
||||
receiver: Receiver<MsgToWorkerThread>,
|
||||
native_display: Option<NativeDisplay>,
|
||||
font_cache_task: FontCacheTask,
|
||||
font_cache_thread: FontCacheThread,
|
||||
time_profiler_sender: time::ProfilerChan)
|
||||
-> WorkerThread {
|
||||
let gl_context = create_gl_context(native_display);
|
||||
@ -637,7 +637,7 @@ impl WorkerThread {
|
||||
sender: sender,
|
||||
receiver: receiver,
|
||||
native_display: native_display,
|
||||
font_context: box FontContext::new(font_cache_task.clone()),
|
||||
font_context: box FontContext::new(font_cache_thread.clone()),
|
||||
time_profiler_sender: time_profiler_sender,
|
||||
gl_context: gl_context,
|
||||
}
|
||||
@ -777,7 +777,7 @@ impl WorkerThread {
|
||||
scale: f32)
|
||||
-> Box<LayerBuffer> {
|
||||
// Create an empty native surface. We mark it as not leaking
|
||||
// in case it dies in transit to the compositor task.
|
||||
// in case it dies in transit to the compositor thread.
|
||||
let width = tile.screen_rect.size.width;
|
||||
let height = tile.screen_rect.size.height;
|
||||
let mut native_surface = tile.native_surface.take().unwrap_or_else(|| {
|
@ -32,5 +32,5 @@ pub trait PaintListener {
|
||||
fn ignore_buffer_requests(&mut self, buffer_requests: Vec<BufferRequest>);
|
||||
|
||||
// Notification that the paint task wants to exit.
|
||||
fn notify_paint_task_exiting(&mut self, pipeline_id: PipelineId);
|
||||
fn notify_paint_thread_exiting(&mut self, pipeline_id: PipelineId);
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ use gfx::display_list::{ClippingRegion, DisplayList};
|
||||
use gfx_traits::LayerId;
|
||||
use incremental::{BUBBLE_ISIZES, REFLOW, REFLOW_OUT_OF_FLOW, REPAINT};
|
||||
use layout_debug;
|
||||
use layout_task::DISPLAY_PORT_SIZE_FACTOR;
|
||||
use layout_thread::DISPLAY_PORT_SIZE_FACTOR;
|
||||
use model::{CollapsibleMargins, MaybeAuto, specified, specified_or_none};
|
||||
use model::{IntrinsicISizes, MarginCollapseInfo};
|
||||
use rustc_serialize::{Encodable, Encoder};
|
||||
|
@ -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/. */
|
||||
|
||||
//! Data needed by the layout task.
|
||||
//! Data needed by the layout thread.
|
||||
|
||||
#![deny(unsafe_code)]
|
||||
|
||||
@ -10,13 +10,13 @@ use app_units::Au;
|
||||
use canvas_traits::CanvasMsg;
|
||||
use euclid::Rect;
|
||||
use fnv::FnvHasher;
|
||||
use gfx::font_cache_task::FontCacheTask;
|
||||
use gfx::font_cache_thread::FontCacheThread;
|
||||
use gfx::font_context::FontContext;
|
||||
use gfx_traits::LayerId;
|
||||
use ipc_channel::ipc::{self, IpcSender};
|
||||
use net_traits::image::base::Image;
|
||||
use net_traits::image_cache_task::{ImageCacheChan, ImageCacheTask, ImageResponse, ImageState};
|
||||
use net_traits::image_cache_task::{UsePlaceholder};
|
||||
use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheThread, ImageResponse, ImageState};
|
||||
use net_traits::image_cache_thread::{UsePlaceholder};
|
||||
use std::cell::{RefCell, RefMut};
|
||||
use std::collections::HashMap;
|
||||
use std::collections::hash_state::DefaultState;
|
||||
@ -59,13 +59,13 @@ fn create_or_get_local_context(shared_layout_context: &SharedLayoutContext)
|
||||
}
|
||||
context
|
||||
} else {
|
||||
let font_cache_task = shared_layout_context.font_cache_task.lock().unwrap().clone();
|
||||
let font_cache_thread = shared_layout_context.font_cache_thread.lock().unwrap().clone();
|
||||
let context = Rc::new(LocalLayoutContext {
|
||||
style_context: LocalStyleContext {
|
||||
applicable_declarations_cache: RefCell::new(ApplicableDeclarationsCache::new()),
|
||||
style_sharing_candidate_cache: RefCell::new(StyleSharingCandidateCache::new()),
|
||||
},
|
||||
font_context: RefCell::new(FontContext::new(font_cache_task)),
|
||||
font_context: RefCell::new(FontContext::new(font_cache_thread)),
|
||||
});
|
||||
*r = Some(context.clone());
|
||||
context
|
||||
@ -78,19 +78,19 @@ pub struct SharedLayoutContext {
|
||||
/// Bits shared by the layout and style system.
|
||||
pub style_context: SharedStyleContext,
|
||||
|
||||
/// The shared image cache task.
|
||||
pub image_cache_task: ImageCacheTask,
|
||||
/// The shared image cache thread.
|
||||
pub image_cache_thread: ImageCacheThread,
|
||||
|
||||
/// A channel for the image cache to send responses to.
|
||||
pub image_cache_sender: Mutex<ImageCacheChan>,
|
||||
|
||||
/// Interface to the font cache task.
|
||||
pub font_cache_task: Mutex<FontCacheTask>,
|
||||
/// Interface to the font cache thread.
|
||||
pub font_cache_thread: Mutex<FontCacheThread>,
|
||||
|
||||
/// The URL.
|
||||
pub url: Url,
|
||||
|
||||
/// A channel to send canvas renderers to paint task, in order to correctly paint the layers
|
||||
/// A channel to send canvas renderers to paint thread, in order to correctly paint the layers
|
||||
pub canvas_layers_sender: Mutex<Sender<(LayerId, IpcSender<CanvasMsg>)>>,
|
||||
|
||||
/// The visible rects for each layer, as reported to us by the compositor.
|
||||
@ -131,7 +131,7 @@ impl<'a> LayoutContext<'a> {
|
||||
pub fn get_or_request_image(&self, url: Url, use_placeholder: UsePlaceholder)
|
||||
-> Option<Arc<Image>> {
|
||||
// See if the image is already available
|
||||
let result = self.shared.image_cache_task.find_image(url.clone(),
|
||||
let result = self.shared.image_cache_thread.find_image(url.clone(),
|
||||
use_placeholder);
|
||||
|
||||
match result {
|
||||
@ -148,7 +148,7 @@ impl<'a> LayoutContext<'a> {
|
||||
// Not loaded, test mode - load the image synchronously
|
||||
(_, true) => {
|
||||
let (sync_tx, sync_rx) = ipc::channel().unwrap();
|
||||
self.shared.image_cache_task.request_image(url,
|
||||
self.shared.image_cache_thread.request_image(url,
|
||||
ImageCacheChan(sync_tx),
|
||||
None);
|
||||
match sync_rx.recv().unwrap().image_response {
|
||||
@ -160,7 +160,7 @@ impl<'a> LayoutContext<'a> {
|
||||
// Not yet requested, async mode - request image from the cache
|
||||
(ImageState::NotRequested, false) => {
|
||||
let sender = self.shared.image_cache_sender.lock().unwrap().clone();
|
||||
self.shared.image_cache_task.request_image(url, sender, None);
|
||||
self.shared.image_cache_thread.request_image(url, sender, None);
|
||||
None
|
||||
}
|
||||
// Image has been requested, is still pending. Return no image
|
||||
|
@ -29,7 +29,7 @@ use gfx::display_list::{GradientDisplayItem};
|
||||
use gfx::display_list::{GradientStop, ImageDisplayItem, LayeredItem, LayerInfo};
|
||||
use gfx::display_list::{LineDisplayItem, OpaqueNode, SolidColorDisplayItem};
|
||||
use gfx::display_list::{StackingContext, TextDisplayItem, TextOrientation};
|
||||
use gfx::paint_task::THREAD_TINT_COLORS;
|
||||
use gfx::paint_thread::THREAD_TINT_COLORS;
|
||||
use gfx::text::glyph::CharIndex;
|
||||
use gfx_traits::{color, ScrollPolicy};
|
||||
use inline::{FIRST_FRAGMENT_OF_ELEMENT, InlineFlow, LAST_FRAGMENT_OF_ELEMENT};
|
||||
@ -37,7 +37,7 @@ use ipc_channel::ipc::{self, IpcSharedMemory};
|
||||
use list_item::ListItemFlow;
|
||||
use model::{self, MaybeAuto, ToGfxMatrix};
|
||||
use net_traits::image::base::{Image, PixelFormat};
|
||||
use net_traits::image_cache_task::UsePlaceholder;
|
||||
use net_traits::image_cache_thread::UsePlaceholder;
|
||||
use std::default::Default;
|
||||
use std::sync::Arc;
|
||||
use std::sync::mpsc::channel;
|
||||
@ -1141,7 +1141,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||
FromLayoutMsg::SendPixelContents(sender))).unwrap();
|
||||
let data = receiver.recv().unwrap();
|
||||
|
||||
// Propagate the layer and the renderer to the paint task.
|
||||
// Propagate the layer and the renderer to the paint thread.
|
||||
layout_context.shared.canvas_layers_sender.lock().unwrap().send(
|
||||
(layer_id, (*ipc_renderer).clone())).unwrap();
|
||||
|
||||
|
@ -27,7 +27,7 @@ use model::{self, IntrinsicISizes, IntrinsicISizesContribution, MaybeAuto, speci
|
||||
use msg::compositor_msg::LayerType;
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use net_traits::image::base::Image;
|
||||
use net_traits::image_cache_task::UsePlaceholder;
|
||||
use net_traits::image_cache_thread::UsePlaceholder;
|
||||
use rustc_serialize::{Encodable, Encoder};
|
||||
use script::dom::htmlcanvaselement::HTMLCanvasData;
|
||||
use std::borrow::ToOwned;
|
||||
@ -575,7 +575,7 @@ impl ReplacedImageFragmentInfo {
|
||||
}
|
||||
|
||||
/// A fragment that represents an inline frame (iframe). This stores the pipeline ID so that the
|
||||
/// size of this iframe can be communicated via the constellation to the iframe's own layout task.
|
||||
/// size of this iframe can be communicated via the constellation to the iframe's own layout thread.
|
||||
#[derive(Clone)]
|
||||
pub struct IframeFragmentInfo {
|
||||
/// The pipeline ID of this iframe.
|
||||
|
@ -116,10 +116,10 @@ pub fn begin_trace(flow_root: FlowRef) {
|
||||
/// trace to disk in the current directory. The output
|
||||
/// file can then be viewed with an external tool.
|
||||
pub fn end_trace() {
|
||||
let mut task_state = STATE_KEY.with(|ref r| r.borrow_mut().take().unwrap());
|
||||
assert!(task_state.scope_stack.len() == 1);
|
||||
let mut root_scope = task_state.scope_stack.pop().unwrap();
|
||||
root_scope.post = json::encode(&flow::base(&*task_state.flow_root)).unwrap();
|
||||
let mut thread_state = STATE_KEY.with(|ref r| r.borrow_mut().take().unwrap());
|
||||
assert!(thread_state.scope_stack.len() == 1);
|
||||
let mut root_scope = thread_state.scope_stack.pop().unwrap();
|
||||
root_scope.post = json::encode(&flow::base(&*thread_state.flow_root)).unwrap();
|
||||
|
||||
let result = json::encode(&root_scope).unwrap();
|
||||
let mut file = File::create("layout_trace.json").unwrap();
|
||||
|
@ -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/. */
|
||||
|
||||
//! The layout task. Performs layout on the DOM, builds display lists and sends them to be
|
||||
//! The layout thread. Performs layout on the DOM, builds display lists and sends them to be
|
||||
//! painted.
|
||||
|
||||
#![allow(unsafe_code)]
|
||||
@ -24,20 +24,20 @@ use flow_ref::{self, FlowRef};
|
||||
use fnv::FnvHasher;
|
||||
use gfx::display_list::{ClippingRegion, DisplayList, LayerInfo, OpaqueNode, StackingContext};
|
||||
use gfx::font;
|
||||
use gfx::font_cache_task::FontCacheTask;
|
||||
use gfx::font_cache_thread::FontCacheThread;
|
||||
use gfx::font_context;
|
||||
use gfx::paint_task::{LayoutToPaintMsg, PaintLayer};
|
||||
use gfx::paint_thread::{LayoutToPaintMsg, PaintLayer};
|
||||
use gfx_traits::{color, LayerId, ScrollPolicy};
|
||||
use incremental::{LayoutDamageComputation, REFLOW, REFLOW_ENTIRE_DOCUMENT, REPAINT};
|
||||
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
|
||||
use ipc_channel::router::ROUTER;
|
||||
use layout_debug;
|
||||
use layout_traits::LayoutTaskFactory;
|
||||
use layout_traits::LayoutThreadFactory;
|
||||
use log;
|
||||
use msg::ParseErrorReporter;
|
||||
use msg::compositor_msg::Epoch;
|
||||
use msg::constellation_msg::{ConstellationChan, Failure, PipelineId};
|
||||
use net_traits::image_cache_task::{ImageCacheChan, ImageCacheResult, ImageCacheTask};
|
||||
use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheResult, ImageCacheThread};
|
||||
use parallel;
|
||||
use profile_traits::mem::{self, Report, ReportKind, ReportsChan};
|
||||
use profile_traits::time::{TimerMetadataFrameType, TimerMetadataReflowType};
|
||||
@ -47,7 +47,7 @@ use query::{process_node_geometry_request, process_offset_parent_query, process_
|
||||
use script::dom::node::OpaqueStyleAndLayoutData;
|
||||
use script::layout_interface::Animation;
|
||||
use script::layout_interface::{LayoutRPC, OffsetParentResponse};
|
||||
use script::layout_interface::{Msg, NewLayoutTaskInfo, Reflow, ReflowGoal, ReflowQueryType};
|
||||
use script::layout_interface::{Msg, NewLayoutThreadInfo, Reflow, ReflowGoal, ReflowQueryType};
|
||||
use script::layout_interface::{ScriptLayoutChan, ScriptReflow};
|
||||
use script::reporter::CSSErrorReporter;
|
||||
use script_traits::ConstellationControlMsg;
|
||||
@ -77,8 +77,8 @@ use util::ipc::OptionalIpcSender;
|
||||
use util::logical_geometry::LogicalPoint;
|
||||
use util::mem::HeapSizeOf;
|
||||
use util::opts;
|
||||
use util::task;
|
||||
use util::task_state;
|
||||
use util::thread;
|
||||
use util::thread_state;
|
||||
use util::workqueue::WorkQueue;
|
||||
use wrapper::{LayoutNode, NonOpaqueStyleAndLayoutData, ServoLayoutNode, ThreadSafeLayoutNode};
|
||||
|
||||
@ -88,10 +88,10 @@ pub const DISPLAY_PORT_SIZE_FACTOR: i32 = 8;
|
||||
/// The number of screens we have to traverse before we decide to generate new display lists.
|
||||
const DISPLAY_PORT_THRESHOLD_SIZE_FACTOR: i32 = 4;
|
||||
|
||||
/// Mutable data belonging to the LayoutTask.
|
||||
/// Mutable data belonging to the LayoutThread.
|
||||
///
|
||||
/// This needs to be protected by a mutex so we can do fast RPCs.
|
||||
pub struct LayoutTaskData {
|
||||
pub struct LayoutThreadData {
|
||||
/// The channel on which messages can be sent to the constellation.
|
||||
pub constellation_chan: ConstellationChan<ConstellationMsg>,
|
||||
|
||||
@ -117,8 +117,8 @@ pub struct LayoutTaskData {
|
||||
pub offset_parent_response: OffsetParentResponse,
|
||||
}
|
||||
|
||||
/// Information needed by the layout task.
|
||||
pub struct LayoutTask {
|
||||
/// Information needed by the layout thread.
|
||||
pub struct LayoutThread {
|
||||
/// The ID of the pipeline that we belong to.
|
||||
id: PipelineId,
|
||||
|
||||
@ -128,7 +128,7 @@ pub struct LayoutTask {
|
||||
/// Is the current reflow of an iframe, as opposed to a root window?
|
||||
is_iframe: bool,
|
||||
|
||||
/// The port on which we receive messages from the script task.
|
||||
/// The port on which we receive messages from the script thread.
|
||||
port: Receiver<Msg>,
|
||||
|
||||
/// The port on which we receive messages from the constellation.
|
||||
@ -140,7 +140,7 @@ pub struct LayoutTask {
|
||||
/// The channel on which the image cache can send messages to ourself.
|
||||
image_cache_sender: ImageCacheChan,
|
||||
|
||||
/// The port on which we receive messages from the font cache task.
|
||||
/// The port on which we receive messages from the font cache thread.
|
||||
font_cache_receiver: Receiver<()>,
|
||||
|
||||
/// The channel on which the font cache can send messages to us.
|
||||
@ -149,10 +149,10 @@ pub struct LayoutTask {
|
||||
/// The channel on which messages can be sent to the constellation.
|
||||
constellation_chan: ConstellationChan<ConstellationMsg>,
|
||||
|
||||
/// The channel on which messages can be sent to the script task.
|
||||
/// The channel on which messages can be sent to the script thread.
|
||||
script_chan: IpcSender<ConstellationControlMsg>,
|
||||
|
||||
/// The channel on which messages can be sent to the painting task.
|
||||
/// The channel on which messages can be sent to the painting thread.
|
||||
paint_chan: OptionalIpcSender<LayoutToPaintMsg>,
|
||||
|
||||
/// The channel on which messages can be sent to the time profiler.
|
||||
@ -162,12 +162,12 @@ pub struct LayoutTask {
|
||||
mem_profiler_chan: mem::ProfilerChan,
|
||||
|
||||
/// The channel on which messages can be sent to the image cache.
|
||||
image_cache_task: ImageCacheTask,
|
||||
image_cache_thread: ImageCacheThread,
|
||||
|
||||
/// Public interface to the font cache task.
|
||||
font_cache_task: FontCacheTask,
|
||||
/// Public interface to the font cache thread.
|
||||
font_cache_thread: FontCacheThread,
|
||||
|
||||
/// Is this the first reflow in this LayoutTask?
|
||||
/// Is this the first reflow in this LayoutThread?
|
||||
first_reflow: bool,
|
||||
|
||||
/// To receive a canvas renderer associated to a layer, this message is propagated
|
||||
@ -213,19 +213,19 @@ pub struct LayoutTask {
|
||||
viewport_size: Size2D<Au>,
|
||||
|
||||
/// A mutex to allow for fast, read-only RPC of layout's internal data
|
||||
/// structures, while still letting the LayoutTask modify them.
|
||||
/// structures, while still letting the LayoutThread modify them.
|
||||
///
|
||||
/// All the other elements of this struct are read-only.
|
||||
rw_data: Arc<Mutex<LayoutTaskData>>,
|
||||
rw_data: Arc<Mutex<LayoutThreadData>>,
|
||||
|
||||
/// The CSS error reporter for all CSS loaded in this layout thread
|
||||
error_reporter: CSSErrorReporter,
|
||||
|
||||
}
|
||||
|
||||
impl LayoutTaskFactory for LayoutTask {
|
||||
/// Spawns a new layout task.
|
||||
fn create(_phantom: Option<&mut LayoutTask>,
|
||||
impl LayoutThreadFactory for LayoutThread {
|
||||
/// Spawns a new layout thread.
|
||||
fn create(_phantom: Option<&mut LayoutThread>,
|
||||
id: PipelineId,
|
||||
url: Url,
|
||||
is_iframe: bool,
|
||||
@ -235,19 +235,19 @@ impl LayoutTaskFactory for LayoutTask {
|
||||
failure_msg: Failure,
|
||||
script_chan: IpcSender<ConstellationControlMsg>,
|
||||
paint_chan: OptionalIpcSender<LayoutToPaintMsg>,
|
||||
image_cache_task: ImageCacheTask,
|
||||
font_cache_task: FontCacheTask,
|
||||
image_cache_thread: ImageCacheThread,
|
||||
font_cache_thread: FontCacheThread,
|
||||
time_profiler_chan: time::ProfilerChan,
|
||||
mem_profiler_chan: mem::ProfilerChan,
|
||||
shutdown_chan: IpcSender<()>,
|
||||
content_process_shutdown_chan: IpcSender<()>) {
|
||||
let ConstellationChan(con_chan) = constellation_chan.clone();
|
||||
task::spawn_named_with_send_on_failure(format!("LayoutTask {:?}", id),
|
||||
task_state::LAYOUT,
|
||||
thread::spawn_named_with_send_on_failure(format!("LayoutThread {:?}", id),
|
||||
thread_state::LAYOUT,
|
||||
move || {
|
||||
{ // Ensures layout task is destroyed before we send shutdown message
|
||||
{ // Ensures layout thread is destroyed before we send shutdown message
|
||||
let sender = chan.sender();
|
||||
let layout = LayoutTask::new(id,
|
||||
let layout = LayoutThread::new(id,
|
||||
url,
|
||||
is_iframe,
|
||||
chan.receiver(),
|
||||
@ -255,8 +255,8 @@ impl LayoutTaskFactory for LayoutTask {
|
||||
constellation_chan,
|
||||
script_chan,
|
||||
paint_chan,
|
||||
image_cache_task,
|
||||
font_cache_task,
|
||||
image_cache_thread,
|
||||
font_cache_thread,
|
||||
time_profiler_chan,
|
||||
mem_profiler_chan.clone());
|
||||
|
||||
@ -271,20 +271,20 @@ impl LayoutTaskFactory for LayoutTask {
|
||||
}
|
||||
}
|
||||
|
||||
/// The `LayoutTask` `rw_data` lock must remain locked until the first reflow,
|
||||
/// The `LayoutThread` `rw_data` lock must remain locked until the first reflow,
|
||||
/// as RPC calls don't make sense until then. Use this in combination with
|
||||
/// `LayoutTask::lock_rw_data` and `LayoutTask::return_rw_data`.
|
||||
/// `LayoutThread::lock_rw_data` and `LayoutThread::return_rw_data`.
|
||||
pub enum RWGuard<'a> {
|
||||
/// If the lock was previously held, from when the task started.
|
||||
Held(MutexGuard<'a, LayoutTaskData>),
|
||||
/// If the lock was previously held, from when the thread started.
|
||||
Held(MutexGuard<'a, LayoutThreadData>),
|
||||
/// If the lock was just used, and has been returned since there has been
|
||||
/// a reflow already.
|
||||
Used(MutexGuard<'a, LayoutTaskData>),
|
||||
Used(MutexGuard<'a, LayoutThreadData>),
|
||||
}
|
||||
|
||||
impl<'a> Deref for RWGuard<'a> {
|
||||
type Target = LayoutTaskData;
|
||||
fn deref(&self) -> &LayoutTaskData {
|
||||
type Target = LayoutThreadData;
|
||||
fn deref(&self) -> &LayoutThreadData {
|
||||
match *self {
|
||||
RWGuard::Held(ref x) => &**x,
|
||||
RWGuard::Used(ref x) => &**x,
|
||||
@ -293,7 +293,7 @@ impl<'a> Deref for RWGuard<'a> {
|
||||
}
|
||||
|
||||
impl<'a> DerefMut for RWGuard<'a> {
|
||||
fn deref_mut(&mut self) -> &mut LayoutTaskData {
|
||||
fn deref_mut(&mut self) -> &mut LayoutThreadData {
|
||||
match *self {
|
||||
RWGuard::Held(ref mut x) => &mut **x,
|
||||
RWGuard::Used(ref mut x) => &mut **x,
|
||||
@ -302,8 +302,8 @@ impl<'a> DerefMut for RWGuard<'a> {
|
||||
}
|
||||
|
||||
struct RwData<'a, 'b: 'a> {
|
||||
rw_data: &'b Arc<Mutex<LayoutTaskData>>,
|
||||
possibly_locked_rw_data: &'a mut Option<MutexGuard<'b, LayoutTaskData>>,
|
||||
rw_data: &'b Arc<Mutex<LayoutThreadData>>,
|
||||
possibly_locked_rw_data: &'a mut Option<MutexGuard<'b, LayoutThreadData>>,
|
||||
}
|
||||
|
||||
impl<'a, 'b: 'a> RwData<'a, 'b> {
|
||||
@ -333,20 +333,20 @@ impl<'a, 'b: 'a> RwData<'a, 'b> {
|
||||
|
||||
fn add_font_face_rules(stylesheet: &Stylesheet,
|
||||
device: &Device,
|
||||
font_cache_task: &FontCacheTask,
|
||||
font_cache_thread: &FontCacheThread,
|
||||
font_cache_sender: &IpcSender<()>,
|
||||
outstanding_web_fonts_counter: &Arc<AtomicUsize>) {
|
||||
for font_face in stylesheet.effective_rules(&device).font_face() {
|
||||
for source in &font_face.sources {
|
||||
if opts::get().load_webfonts_synchronously {
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
font_cache_task.add_web_font(font_face.family.clone(),
|
||||
font_cache_thread.add_web_font(font_face.family.clone(),
|
||||
(*source).clone(),
|
||||
sender);
|
||||
receiver.recv().unwrap();
|
||||
} else {
|
||||
outstanding_web_fonts_counter.fetch_add(1, Ordering::SeqCst);
|
||||
font_cache_task.add_web_font(font_face.family.clone(),
|
||||
font_cache_thread.add_web_font(font_face.family.clone(),
|
||||
(*source).clone(),
|
||||
(*font_cache_sender).clone());
|
||||
}
|
||||
@ -354,8 +354,8 @@ fn add_font_face_rules(stylesheet: &Stylesheet,
|
||||
}
|
||||
}
|
||||
|
||||
impl LayoutTask {
|
||||
/// Creates a new `LayoutTask` structure.
|
||||
impl LayoutThread {
|
||||
/// Creates a new `LayoutThread` structure.
|
||||
fn new(id: PipelineId,
|
||||
url: Url,
|
||||
is_iframe: bool,
|
||||
@ -364,16 +364,16 @@ impl LayoutTask {
|
||||
constellation_chan: ConstellationChan<ConstellationMsg>,
|
||||
script_chan: IpcSender<ConstellationControlMsg>,
|
||||
paint_chan: OptionalIpcSender<LayoutToPaintMsg>,
|
||||
image_cache_task: ImageCacheTask,
|
||||
font_cache_task: FontCacheTask,
|
||||
image_cache_thread: ImageCacheThread,
|
||||
font_cache_thread: FontCacheThread,
|
||||
time_profiler_chan: time::ProfilerChan,
|
||||
mem_profiler_chan: mem::ProfilerChan)
|
||||
-> LayoutTask {
|
||||
-> LayoutThread {
|
||||
let device = Device::new(
|
||||
MediaType::Screen,
|
||||
opts::get().initial_window_size.as_f32() * ScaleFactor::new(1.0));
|
||||
let parallel_traversal = if opts::get().layout_threads != 1 {
|
||||
Some(WorkQueue::new("LayoutWorker", task_state::LAYOUT,
|
||||
Some(WorkQueue::new("LayoutWorker", thread_state::LAYOUT,
|
||||
opts::get().layout_threads))
|
||||
} else {
|
||||
None
|
||||
@ -386,12 +386,12 @@ impl LayoutTask {
|
||||
// Proxy IPC messages from the pipeline to the layout thread.
|
||||
let pipeline_receiver = ROUTER.route_ipc_receiver_to_new_mpsc_receiver(pipeline_port);
|
||||
|
||||
// Ask the router to proxy IPC messages from the image cache task to the layout thread.
|
||||
// Ask the router to proxy IPC messages from the image cache thread to the layout thread.
|
||||
let (ipc_image_cache_sender, ipc_image_cache_receiver) = ipc::channel().unwrap();
|
||||
let image_cache_receiver =
|
||||
ROUTER.route_ipc_receiver_to_new_mpsc_receiver(ipc_image_cache_receiver);
|
||||
|
||||
// Ask the router to proxy IPC messages from the font cache task to the layout thread.
|
||||
// Ask the router to proxy IPC messages from the font cache thread to the layout thread.
|
||||
let (ipc_font_cache_sender, ipc_font_cache_receiver) = ipc::channel().unwrap();
|
||||
let font_cache_receiver =
|
||||
ROUTER.route_ipc_receiver_to_new_mpsc_receiver(ipc_font_cache_receiver);
|
||||
@ -401,12 +401,12 @@ impl LayoutTask {
|
||||
for stylesheet in &*USER_OR_USER_AGENT_STYLESHEETS {
|
||||
add_font_face_rules(stylesheet,
|
||||
&stylist.device,
|
||||
&font_cache_task,
|
||||
&font_cache_thread,
|
||||
&ipc_font_cache_sender,
|
||||
&outstanding_web_fonts_counter);
|
||||
}
|
||||
|
||||
LayoutTask {
|
||||
LayoutThread {
|
||||
id: id,
|
||||
url: RefCell::new(url),
|
||||
is_iframe: is_iframe,
|
||||
@ -417,8 +417,8 @@ impl LayoutTask {
|
||||
paint_chan: paint_chan,
|
||||
time_profiler_chan: time_profiler_chan,
|
||||
mem_profiler_chan: mem_profiler_chan,
|
||||
image_cache_task: image_cache_task,
|
||||
font_cache_task: font_cache_task,
|
||||
image_cache_thread: image_cache_thread,
|
||||
font_cache_thread: font_cache_thread,
|
||||
first_reflow: true,
|
||||
image_cache_receiver: image_cache_receiver,
|
||||
image_cache_sender: ImageCacheChan(ipc_image_cache_sender),
|
||||
@ -438,7 +438,7 @@ impl LayoutTask {
|
||||
epoch: Epoch(0),
|
||||
viewport_size: Size2D::new(Au(0), Au(0)),
|
||||
rw_data: Arc::new(Mutex::new(
|
||||
LayoutTaskData {
|
||||
LayoutThreadData {
|
||||
constellation_chan: constellation_chan,
|
||||
stacking_context: None,
|
||||
stylist: stylist,
|
||||
@ -467,7 +467,7 @@ impl LayoutTask {
|
||||
|
||||
// Create a layout context for use in building display lists, hit testing, &c.
|
||||
fn build_shared_layout_context(&self,
|
||||
rw_data: &LayoutTaskData,
|
||||
rw_data: &LayoutThreadData,
|
||||
screen_size_changed: bool,
|
||||
url: &Url,
|
||||
goal: ReflowGoal)
|
||||
@ -484,16 +484,16 @@ impl LayoutTask {
|
||||
expired_animations: self.expired_animations.clone(),
|
||||
error_reporter: self.error_reporter.clone(),
|
||||
},
|
||||
image_cache_task: self.image_cache_task.clone(),
|
||||
image_cache_thread: self.image_cache_thread.clone(),
|
||||
image_cache_sender: Mutex::new(self.image_cache_sender.clone()),
|
||||
font_cache_task: Mutex::new(self.font_cache_task.clone()),
|
||||
font_cache_thread: Mutex::new(self.font_cache_thread.clone()),
|
||||
canvas_layers_sender: Mutex::new(self.canvas_layers_sender.clone()),
|
||||
url: (*url).clone(),
|
||||
visible_rects: self.visible_rects.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Receives and dispatches messages from the script and constellation tasks
|
||||
/// Receives and dispatches messages from the script and constellation threads
|
||||
fn handle_request<'a, 'b>(&mut self, possibly_locked_rw_data: &mut RwData<'a, 'b>) -> bool {
|
||||
enum Request {
|
||||
FromPipeline(LayoutControlMsg),
|
||||
@ -584,7 +584,7 @@ impl LayoutTask {
|
||||
true
|
||||
}
|
||||
|
||||
/// Receives and dispatches messages from other tasks.
|
||||
/// Receives and dispatches messages from other threads.
|
||||
fn handle_request_helper<'a, 'b>(&mut self,
|
||||
request: Msg,
|
||||
possibly_locked_rw_data: &mut RwData<'a, 'b>)
|
||||
@ -628,8 +628,8 @@ impl LayoutTask {
|
||||
let outstanding_web_fonts = self.outstanding_web_fonts.load(Ordering::SeqCst);
|
||||
sender.send(outstanding_web_fonts != 0).unwrap();
|
||||
},
|
||||
Msg::CreateLayoutTask(info) => {
|
||||
self.create_layout_task(info)
|
||||
Msg::CreateLayoutThread(info) => {
|
||||
self.create_layout_thread(info)
|
||||
}
|
||||
Msg::SetFinalUrl(final_url) => {
|
||||
*self.url.borrow_mut() = final_url;
|
||||
@ -658,14 +658,14 @@ impl LayoutTask {
|
||||
let stacking_context = rw_data.stacking_context.as_ref();
|
||||
let formatted_url = &format!("url({})", *self.url.borrow());
|
||||
reports.push(Report {
|
||||
path: path![formatted_url, "layout-task", "display-list"],
|
||||
path: path![formatted_url, "layout-thread", "display-list"],
|
||||
kind: ReportKind::ExplicitJemallocHeapSize,
|
||||
size: stacking_context.map_or(0, |sc| sc.heap_size_of_children()),
|
||||
});
|
||||
|
||||
// The LayoutTask has a context in TLS...
|
||||
// The LayoutThread has a context in TLS...
|
||||
reports.push(Report {
|
||||
path: path![formatted_url, "layout-task", "local-context"],
|
||||
path: path![formatted_url, "layout-thread", "local-context"],
|
||||
kind: ReportKind::ExplicitJemallocHeapSize,
|
||||
size: heap_size_of_local_context(),
|
||||
});
|
||||
@ -686,8 +686,8 @@ impl LayoutTask {
|
||||
reports_chan.send(reports);
|
||||
}
|
||||
|
||||
fn create_layout_task(&self, info: NewLayoutTaskInfo) {
|
||||
LayoutTaskFactory::create(None::<&mut LayoutTask>,
|
||||
fn create_layout_thread(&self, info: NewLayoutThreadInfo) {
|
||||
LayoutThreadFactory::create(None::<&mut LayoutThread>,
|
||||
info.id,
|
||||
info.url.clone(),
|
||||
info.is_parent,
|
||||
@ -697,8 +697,8 @@ impl LayoutTask {
|
||||
info.failure,
|
||||
info.script_chan.clone(),
|
||||
info.paint_chan.to::<LayoutToPaintMsg>(),
|
||||
self.image_cache_task.clone(),
|
||||
self.font_cache_task.clone(),
|
||||
self.image_cache_thread.clone(),
|
||||
self.font_cache_thread.clone(),
|
||||
self.time_profiler_chan.clone(),
|
||||
self.mem_profiler_chan.clone(),
|
||||
info.layout_shutdown_chan,
|
||||
@ -717,7 +717,7 @@ impl LayoutTask {
|
||||
}
|
||||
}
|
||||
Msg::ExitNow => {
|
||||
debug!("layout task is exiting...");
|
||||
debug!("layout thread is exiting...");
|
||||
self.exit_now();
|
||||
break
|
||||
}
|
||||
@ -731,7 +731,7 @@ impl LayoutTask {
|
||||
}
|
||||
}
|
||||
|
||||
/// Shuts down the layout task now. If there are any DOM nodes left, layout will now (safely)
|
||||
/// Shuts down the layout thread now. If there are any DOM nodes left, layout will now (safely)
|
||||
/// crash.
|
||||
fn exit_now(&mut self) {
|
||||
if let Some(ref mut traversal) = self.parallel_traversal {
|
||||
@ -753,7 +753,7 @@ impl LayoutTask {
|
||||
if stylesheet.is_effective_for_device(&rw_data.stylist.device) {
|
||||
add_font_face_rules(&*stylesheet,
|
||||
&rw_data.stylist.device,
|
||||
&self.font_cache_task,
|
||||
&self.font_cache_thread,
|
||||
&self.font_cache_sender,
|
||||
&self.outstanding_web_fonts);
|
||||
}
|
||||
@ -829,7 +829,7 @@ impl LayoutTask {
|
||||
data: &Reflow,
|
||||
layout_root: &mut FlowRef,
|
||||
shared_layout_context: &mut SharedLayoutContext,
|
||||
rw_data: &mut LayoutTaskData) {
|
||||
rw_data: &mut LayoutThreadData) {
|
||||
let writing_mode = flow::base(&**layout_root).writing_mode;
|
||||
let (metadata, sender) = (self.profiler_metadata(), self.time_profiler_chan.clone());
|
||||
profile(time::ProfilerCategory::LayoutDispListBuild,
|
||||
@ -912,7 +912,7 @@ impl LayoutTask {
|
||||
});
|
||||
}
|
||||
|
||||
/// The high-level routine that performs layout tasks.
|
||||
/// The high-level routine that performs layout threads.
|
||||
fn handle_reflow<'a, 'b>(&mut self,
|
||||
data: &ScriptReflow,
|
||||
possibly_locked_rw_data: &mut RwData<'a, 'b>) {
|
||||
@ -994,12 +994,12 @@ impl LayoutTask {
|
||||
let needs_reflow = viewport_size_changed && !needs_dirtying;
|
||||
unsafe {
|
||||
if needs_dirtying {
|
||||
LayoutTask::dirty_all_nodes(node);
|
||||
LayoutThread::dirty_all_nodes(node);
|
||||
}
|
||||
}
|
||||
if needs_reflow {
|
||||
if let Some(mut flow) = self.try_get_layout_root(node) {
|
||||
LayoutTask::reflow_all_nodes(flow_ref::deref_mut(&mut flow));
|
||||
LayoutThread::reflow_all_nodes(flow_ref::deref_mut(&mut flow));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1052,7 +1052,7 @@ impl LayoutTask {
|
||||
self.root_flow = self.try_get_layout_root(node);
|
||||
}
|
||||
|
||||
// Send new canvas renderers to the paint task
|
||||
// Send new canvas renderers to the paint thread
|
||||
while let Ok((layer_id, renderer)) = self.canvas_layers_receiver.try_recv() {
|
||||
// Just send if there's an actual renderer
|
||||
self.paint_chan.send(LayoutToPaintMsg::CanvasLayer(layer_id, renderer)).unwrap();
|
||||
@ -1157,7 +1157,7 @@ impl LayoutTask {
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
pub fn tick_animations(&mut self, rw_data: &mut LayoutTaskData) {
|
||||
pub fn tick_animations(&mut self, rw_data: &mut LayoutThreadData) {
|
||||
let reflow_info = Reflow {
|
||||
goal: ReflowGoal::ForDisplay,
|
||||
page_clip_rect: MAX_RECT,
|
||||
@ -1210,7 +1210,7 @@ impl LayoutTask {
|
||||
|
||||
fn perform_post_style_recalc_layout_passes(&mut self,
|
||||
data: &Reflow,
|
||||
rw_data: &mut LayoutTaskData,
|
||||
rw_data: &mut LayoutThreadData,
|
||||
layout_context: &mut SharedLayoutContext) {
|
||||
if let Some(mut root_flow) = self.root_flow.clone() {
|
||||
// Kick off animations if any were triggered, expire completed ones.
|
||||
@ -1251,11 +1251,11 @@ impl LayoutTask {
|
||||
match self.parallel_traversal {
|
||||
None => {
|
||||
// Sequential mode.
|
||||
LayoutTask::solve_constraints(&mut root_flow, &layout_context)
|
||||
LayoutThread::solve_constraints(&mut root_flow, &layout_context)
|
||||
}
|
||||
Some(ref mut parallel) => {
|
||||
// Parallel mode.
|
||||
LayoutTask::solve_constraints_parallel(parallel,
|
||||
LayoutThread::solve_constraints_parallel(parallel,
|
||||
&mut root_flow,
|
||||
profiler_metadata,
|
||||
self.time_profiler_chan.clone(),
|
||||
@ -1270,7 +1270,7 @@ impl LayoutTask {
|
||||
|
||||
fn perform_post_main_layout_passes(&mut self,
|
||||
data: &Reflow,
|
||||
rw_data: &mut LayoutTaskData,
|
||||
rw_data: &mut LayoutThreadData,
|
||||
layout_context: &mut SharedLayoutContext) {
|
||||
// Build the display list if necessary, and send it to the painter.
|
||||
if let Some(mut root_flow) = self.root_flow.clone() {
|
||||
@ -1307,11 +1307,11 @@ impl LayoutTask {
|
||||
flow::mut_base(flow).restyle_damage.insert(REFLOW | REPAINT);
|
||||
|
||||
for child in flow::child_iter(flow) {
|
||||
LayoutTask::reflow_all_nodes(child);
|
||||
LayoutThread::reflow_all_nodes(child);
|
||||
}
|
||||
}
|
||||
|
||||
/// Handles a message to destroy layout data. Layout data must be destroyed on *this* task
|
||||
/// Handles a message to destroy layout data. Layout data must be destroyed on *this* thread
|
||||
/// because the struct type is transmuted to a different type on the script side.
|
||||
unsafe fn handle_reap_style_and_layout_data(&self, data: OpaqueStyleAndLayoutData) {
|
||||
let non_opaque: NonOpaqueStyleAndLayoutData = transmute(data.ptr);
|
@ -78,7 +78,7 @@ mod fragment;
|
||||
mod generated_content;
|
||||
mod incremental;
|
||||
mod inline;
|
||||
pub mod layout_task;
|
||||
pub mod layout_thread;
|
||||
mod list_item;
|
||||
mod model;
|
||||
mod multicol;
|
||||
|
@ -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/. */
|
||||
|
||||
//! Utilities for querying the layout, as needed by the layout task.
|
||||
//! Utilities for querying the layout, as needed by the layout thread.
|
||||
|
||||
use app_units::Au;
|
||||
use construct::ConstructionResult;
|
||||
@ -12,7 +12,7 @@ use flow;
|
||||
use flow_ref::FlowRef;
|
||||
use fragment::{Fragment, FragmentBorderBoxIterator, SpecificFragmentInfo};
|
||||
use gfx::display_list::{DisplayItemMetadata, OpaqueNode};
|
||||
use layout_task::LayoutTaskData;
|
||||
use layout_thread::LayoutThreadData;
|
||||
use msg::constellation_msg::ConstellationChan;
|
||||
use opaque_node::OpaqueNodeMethods;
|
||||
use script::layout_interface::{ContentBoxResponse, ContentBoxesResponse, NodeGeometryResponse};
|
||||
@ -32,7 +32,7 @@ use util::cursor::Cursor;
|
||||
use util::logical_geometry::WritingMode;
|
||||
use wrapper::{LayoutNode, ThreadSafeLayoutNode};
|
||||
|
||||
pub struct LayoutRPCImpl(pub Arc<Mutex<LayoutTaskData>>);
|
||||
pub struct LayoutRPCImpl(pub Arc<Mutex<LayoutThreadData>>);
|
||||
|
||||
impl LayoutRPC for LayoutRPCImpl {
|
||||
|
||||
|
@ -15,7 +15,7 @@ use std::mem;
|
||||
use style::context::StyleContext;
|
||||
use style::matching::MatchMethods;
|
||||
use style::traversal::{DomTraversalContext, STYLE_BLOOM};
|
||||
use style::traversal::{put_task_local_bloom_filter, recalc_style_at};
|
||||
use style::traversal::{put_thread_local_bloom_filter, recalc_style_at};
|
||||
use util::opts;
|
||||
use util::tid::tid;
|
||||
use wrapper::{LayoutNode, ThreadSafeLayoutNode};
|
||||
@ -57,7 +57,7 @@ impl<'lc, 'ln, N: LayoutNode<'ln>> DomTraversalContext<'ln, N> for RecalcStyleAn
|
||||
//
|
||||
// [1] For example, the WorkQueue type needs to be parameterized on the concrete type of
|
||||
// DomTraversalContext::SharedContext, and the WorkQueue lifetime is similar to that of the
|
||||
// LayoutTask, generally much longer than that of a given SharedLayoutContext borrow.
|
||||
// LayoutThread, generally much longer than that of a given SharedLayoutContext borrow.
|
||||
let shared_lc: &'lc SharedLayoutContext = unsafe { mem::transmute(shared) };
|
||||
RecalcStyleAndConstructFlows {
|
||||
context: LayoutContext::new(shared_lc),
|
||||
@ -120,13 +120,13 @@ fn construct_flows_at<'a, 'ln, N: LayoutNode<'ln>>(context: &'a LayoutContext<'a
|
||||
match node.layout_parent_node(root) {
|
||||
None => {
|
||||
debug!("[{}] - {:X}, and deleting BF.", tid(), unsafe_layout_node.0);
|
||||
// If this is the reflow root, eat the task-local bloom filter.
|
||||
// If this is the reflow root, eat the thread-local bloom filter.
|
||||
}
|
||||
Some(parent) => {
|
||||
// Otherwise, put it back, but remove this node.
|
||||
node.remove_from_bloom_filter(&mut *bf);
|
||||
let unsafe_parent = parent.to_unsafe();
|
||||
put_task_local_bloom_filter(bf, &unsafe_parent, &context.shared_context());
|
||||
put_thread_local_bloom_filter(bf, &unsafe_parent, &context.shared_context());
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
//! onto these objects and cause use-after-free.
|
||||
//!
|
||||
//! When implementing wrapper functions, be careful that you do not touch the borrow flags, or you
|
||||
//! will race and cause spurious task failure. (Note that I do not believe these races are
|
||||
//! will race and cause spurious thread failure. (Note that I do not believe these races are
|
||||
//! exploitable, but they'll result in brokenness nonetheless.)
|
||||
//!
|
||||
//! Rules of the road for this file:
|
||||
|
@ -21,11 +21,11 @@ extern crate util;
|
||||
// The traits are here instead of in layout so
|
||||
// that these modules won't have to depend on layout.
|
||||
|
||||
use gfx::font_cache_task::FontCacheTask;
|
||||
use gfx::paint_task::LayoutToPaintMsg;
|
||||
use gfx::font_cache_thread::FontCacheThread;
|
||||
use gfx::paint_thread::LayoutToPaintMsg;
|
||||
use ipc_channel::ipc::{IpcReceiver, IpcSender};
|
||||
use msg::constellation_msg::{ConstellationChan, Failure, PipelineId};
|
||||
use net_traits::image_cache_task::ImageCacheTask;
|
||||
use net_traits::image_cache_thread::ImageCacheThread;
|
||||
use profile_traits::{mem, time};
|
||||
use script_traits::LayoutMsg as ConstellationMsg;
|
||||
use script_traits::{LayoutControlMsg, ConstellationControlMsg, OpaqueScriptLayoutChannel};
|
||||
@ -36,9 +36,9 @@ use util::ipc::OptionalIpcSender;
|
||||
#[derive(Clone, Deserialize, Serialize)]
|
||||
pub struct LayoutControlChan(pub IpcSender<LayoutControlMsg>);
|
||||
|
||||
// A static method creating a layout task
|
||||
// A static method creating a layout thread
|
||||
// Here to remove the compositor -> layout dependency
|
||||
pub trait LayoutTaskFactory {
|
||||
pub trait LayoutThreadFactory {
|
||||
// FIXME: use a proper static method
|
||||
fn create(_phantom: Option<&mut Self>,
|
||||
id: PipelineId,
|
||||
@ -50,8 +50,8 @@ pub trait LayoutTaskFactory {
|
||||
failure_msg: Failure,
|
||||
script_chan: IpcSender<ConstellationControlMsg>,
|
||||
layout_to_paint_chan: OptionalIpcSender<LayoutToPaintMsg>,
|
||||
image_cache_task: ImageCacheTask,
|
||||
font_cache_task: FontCacheTask,
|
||||
image_cache_thread: ImageCacheThread,
|
||||
font_cache_thread: FontCacheThread,
|
||||
time_profiler_chan: time::ProfilerChan,
|
||||
mem_profiler_chan: mem::ProfilerChan,
|
||||
shutdown_chan: IpcSender<()>,
|
||||
|
@ -42,7 +42,7 @@ pub enum IFrameSandboxState {
|
||||
IFrameUnsandboxed
|
||||
}
|
||||
|
||||
// We pass this info to various tasks, so it lives in a separate, cloneable struct.
|
||||
// We pass this info to various threads, so it lives in a separate, cloneable struct.
|
||||
#[derive(Clone, Copy, Deserialize, Serialize)]
|
||||
pub struct Failure {
|
||||
pub pipeline_id: PipelineId,
|
||||
@ -339,7 +339,7 @@ pub struct Image {
|
||||
pub bytes: IpcSharedMemory,
|
||||
}
|
||||
|
||||
/// Similar to net::resource_task::LoadData
|
||||
/// Similar to net::resource_thread::LoadData
|
||||
/// can be passed to LoadUrl to load a page with GET/POST
|
||||
/// parameters or headers
|
||||
#[derive(Clone, Deserialize, Serialize)]
|
||||
|
@ -9,7 +9,7 @@ use hyper::mime::{Mime, SubLevel, TopLevel};
|
||||
use mime_classifier::MIMEClassifier;
|
||||
use net_traits::ProgressMsg::Done;
|
||||
use net_traits::{LoadConsumer, LoadData, Metadata};
|
||||
use resource_task::{CancellationListener, send_error, start_sending_sniffed_opt};
|
||||
use resource_thread::{CancellationListener, send_error, start_sending_sniffed_opt};
|
||||
use std::sync::Arc;
|
||||
use url::Url;
|
||||
use util::resource_files::resources_dir_path;
|
||||
|
@ -6,7 +6,7 @@ use hyper::mime::{Mime, TopLevel, SubLevel, Attr, Value};
|
||||
use mime_classifier::MIMEClassifier;
|
||||
use net_traits::ProgressMsg::{Done, Payload};
|
||||
use net_traits::{LoadConsumer, LoadData, Metadata};
|
||||
use resource_task::{CancellationListener, send_error, start_sending_sniffed_opt};
|
||||
use resource_thread::{CancellationListener, send_error, start_sending_sniffed_opt};
|
||||
use rustc_serialize::base64::FromBase64;
|
||||
use std::sync::Arc;
|
||||
use url::SchemeData;
|
||||
@ -16,10 +16,10 @@ pub fn factory(load_data: LoadData,
|
||||
senders: LoadConsumer,
|
||||
classifier: Arc<MIMEClassifier>,
|
||||
cancel_listener: CancellationListener) {
|
||||
// NB: we don't spawn a new task.
|
||||
// NB: we don't spawn a new thread.
|
||||
// Hypothesis: data URLs are too small for parallel base64 etc. to be worth it.
|
||||
// Should be tested at some point.
|
||||
// Left in separate function to allow easy moving to a task, if desired.
|
||||
// Left in separate function to allow easy moving to a thread, if desired.
|
||||
load(load_data, senders, classifier, cancel_listener)
|
||||
}
|
||||
|
||||
|
@ -196,8 +196,8 @@ impl CORSCache for BasicCORSCache {
|
||||
}
|
||||
}
|
||||
|
||||
/// Various messages that can be sent to a CORSCacheTask
|
||||
pub enum CORSCacheTaskMsg {
|
||||
/// Various messages that can be sent to a CORSCacheThread
|
||||
pub enum CORSCacheThreadMsg {
|
||||
Clear(CacheRequestDetails, Sender<()>),
|
||||
Cleanup(Sender<()>),
|
||||
MatchHeader(CacheRequestDetails, String, Sender<bool>),
|
||||
@ -208,119 +208,119 @@ pub enum CORSCacheTaskMsg {
|
||||
ExitMsg
|
||||
}
|
||||
|
||||
/// A Sender to a CORSCacheTask
|
||||
/// A Sender to a CORSCacheThread
|
||||
///
|
||||
/// This can be used as a CORS Cache.
|
||||
/// The methods on this type block until they can run, and it behaves similar to a mutex
|
||||
pub type CORSCacheSender = Sender<CORSCacheTaskMsg>;
|
||||
pub type CORSCacheSender = Sender<CORSCacheThreadMsg>;
|
||||
|
||||
impl CORSCache for CORSCacheSender {
|
||||
fn clear (&mut self, request: CacheRequestDetails) {
|
||||
let (tx, rx) = channel();
|
||||
let _ = self.send(CORSCacheTaskMsg::Clear(request, tx));
|
||||
let _ = self.send(CORSCacheThreadMsg::Clear(request, tx));
|
||||
let _ = rx.recv();
|
||||
}
|
||||
|
||||
fn cleanup(&mut self) {
|
||||
let (tx, rx) = channel();
|
||||
let _ = self.send(CORSCacheTaskMsg::Cleanup(tx));
|
||||
let _ = self.send(CORSCacheThreadMsg::Cleanup(tx));
|
||||
let _ = rx.recv();
|
||||
}
|
||||
|
||||
fn match_header(&mut self, request: CacheRequestDetails, header_name: &str) -> bool {
|
||||
let (tx, rx) = channel();
|
||||
let _ = self.send(CORSCacheTaskMsg::MatchHeader(request, header_name.to_owned(), tx));
|
||||
let _ = self.send(CORSCacheThreadMsg::MatchHeader(request, header_name.to_owned(), tx));
|
||||
rx.recv().unwrap_or(false)
|
||||
}
|
||||
|
||||
fn match_header_and_update(&mut self, request: CacheRequestDetails, header_name: &str, new_max_age: u32) -> bool {
|
||||
let (tx, rx) = channel();
|
||||
let _ = self.send(CORSCacheTaskMsg::MatchHeaderUpdate(request, header_name.to_owned(), new_max_age, tx));
|
||||
let _ = self.send(CORSCacheThreadMsg::MatchHeaderUpdate(request, header_name.to_owned(), new_max_age, tx));
|
||||
rx.recv().unwrap_or(false)
|
||||
}
|
||||
|
||||
fn match_method(&mut self, request: CacheRequestDetails, method: Method) -> bool {
|
||||
let (tx, rx) = channel();
|
||||
let _ = self.send(CORSCacheTaskMsg::MatchMethod(request, method, tx));
|
||||
let _ = self.send(CORSCacheThreadMsg::MatchMethod(request, method, tx));
|
||||
rx.recv().unwrap_or(false)
|
||||
}
|
||||
|
||||
fn match_method_and_update(&mut self, request: CacheRequestDetails, method: Method, new_max_age: u32) -> bool {
|
||||
let (tx, rx) = channel();
|
||||
let _ = self.send(CORSCacheTaskMsg::MatchMethodUpdate(request, method, new_max_age, tx));
|
||||
let _ = self.send(CORSCacheThreadMsg::MatchMethodUpdate(request, method, new_max_age, tx));
|
||||
rx.recv().unwrap_or(false)
|
||||
}
|
||||
|
||||
fn insert(&mut self, entry: CORSCacheEntry) {
|
||||
let (tx, rx) = channel();
|
||||
let _ = self.send(CORSCacheTaskMsg::Insert(entry, tx));
|
||||
let _ = self.send(CORSCacheThreadMsg::Insert(entry, tx));
|
||||
let _ = rx.recv();
|
||||
}
|
||||
}
|
||||
|
||||
/// A simple task-based CORS Cache that can be sent messages
|
||||
/// A simple thread-based CORS Cache that can be sent messages
|
||||
///
|
||||
/// #Example
|
||||
/// ```ignore
|
||||
/// let task = CORSCacheTask::new();
|
||||
/// let builder = TaskBuilder::new().named("XHRTask");
|
||||
/// let mut sender = task.sender();
|
||||
/// builder.spawn(move || { task.run() });
|
||||
/// let thread = CORSCacheThread::new();
|
||||
/// let builder = ThreadBuilder::new().named("XHRThread");
|
||||
/// let mut sender = thread.sender();
|
||||
/// builder.spawn(move || { thread.run() });
|
||||
/// sender.insert(CORSCacheEntry::new(/* parameters here */));
|
||||
/// ```
|
||||
pub struct CORSCacheTask {
|
||||
receiver: Receiver<CORSCacheTaskMsg>,
|
||||
pub struct CORSCacheThread {
|
||||
receiver: Receiver<CORSCacheThreadMsg>,
|
||||
cache: BasicCORSCache,
|
||||
sender: CORSCacheSender
|
||||
}
|
||||
|
||||
impl CORSCacheTask {
|
||||
pub fn new() -> CORSCacheTask {
|
||||
impl CORSCacheThread {
|
||||
pub fn new() -> CORSCacheThread {
|
||||
let (tx, rx) = channel();
|
||||
CORSCacheTask {
|
||||
CORSCacheThread {
|
||||
receiver: rx,
|
||||
cache: BasicCORSCache(vec![]),
|
||||
sender: tx
|
||||
}
|
||||
}
|
||||
|
||||
/// Provides a sender to the cache task
|
||||
/// Provides a sender to the cache thread
|
||||
pub fn sender(&self) -> CORSCacheSender {
|
||||
self.sender.clone()
|
||||
}
|
||||
|
||||
/// Runs the cache task
|
||||
/// This blocks the current task, so it is advised
|
||||
/// to spawn a new task for this
|
||||
/// Runs the cache thread
|
||||
/// This blocks the current thread, so it is advised
|
||||
/// to spawn a new thread for this
|
||||
/// Send ExitMsg to the associated Sender to exit
|
||||
pub fn run(&mut self) {
|
||||
loop {
|
||||
match self.receiver.recv().unwrap() {
|
||||
CORSCacheTaskMsg::Clear(request, tx) => {
|
||||
CORSCacheThreadMsg::Clear(request, tx) => {
|
||||
self.cache.clear(request);
|
||||
let _ = tx.send(());
|
||||
},
|
||||
CORSCacheTaskMsg::Cleanup(tx) => {
|
||||
CORSCacheThreadMsg::Cleanup(tx) => {
|
||||
self.cache.cleanup();
|
||||
let _ = tx.send(());
|
||||
},
|
||||
CORSCacheTaskMsg::MatchHeader(request, header, tx) => {
|
||||
CORSCacheThreadMsg::MatchHeader(request, header, tx) => {
|
||||
let _ = tx.send(self.cache.match_header(request, &header));
|
||||
},
|
||||
CORSCacheTaskMsg::MatchHeaderUpdate(request, header, new_max_age, tx) => {
|
||||
CORSCacheThreadMsg::MatchHeaderUpdate(request, header, new_max_age, tx) => {
|
||||
let _ = tx.send(self.cache.match_header_and_update(request, &header, new_max_age));
|
||||
},
|
||||
CORSCacheTaskMsg::MatchMethod(request, method, tx) => {
|
||||
CORSCacheThreadMsg::MatchMethod(request, method, tx) => {
|
||||
let _ = tx.send(self.cache.match_method(request, method));
|
||||
},
|
||||
CORSCacheTaskMsg::MatchMethodUpdate(request, method, new_max_age, tx) => {
|
||||
CORSCacheThreadMsg::MatchMethodUpdate(request, method, new_max_age, tx) => {
|
||||
let _ = tx.send(self.cache.match_method_and_update(request, method, new_max_age));
|
||||
},
|
||||
CORSCacheTaskMsg::Insert(entry, tx) => {
|
||||
CORSCacheThreadMsg::Insert(entry, tx) => {
|
||||
self.cache.insert(entry);
|
||||
let _ = tx.send(());
|
||||
},
|
||||
CORSCacheTaskMsg::ExitMsg => break
|
||||
CORSCacheThreadMsg::ExitMsg => break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,14 +17,14 @@ use hyper::mime::{Attr, Mime, SubLevel, TopLevel, Value};
|
||||
use hyper::status::StatusCode;
|
||||
use net_traits::response::{CacheState, HttpsState, Response, ResponseType, TerminationReason};
|
||||
use net_traits::{AsyncFetchListener, Metadata};
|
||||
use resource_task::CancellationListener;
|
||||
use resource_thread::CancellationListener;
|
||||
use std::ascii::AsciiExt;
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::rc::Rc;
|
||||
use std::str::FromStr;
|
||||
use std::thread;
|
||||
use url::{Origin, Url, UrlParser};
|
||||
use util::task::spawn_named;
|
||||
use util::thread::spawn_named;
|
||||
|
||||
/// A [request context](https://fetch.spec.whatwg.org/#concept-request-context)
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
|
@ -7,8 +7,8 @@ use mime_classifier::MIMEClassifier;
|
||||
use mime_guess::guess_mime_type;
|
||||
use net_traits::ProgressMsg::{Done, Payload};
|
||||
use net_traits::{LoadConsumer, LoadData, Metadata};
|
||||
use resource_task::{CancellationListener, ProgressSender};
|
||||
use resource_task::{send_error, start_sending_sniffed, start_sending_sniffed_opt};
|
||||
use resource_thread::{CancellationListener, ProgressSender};
|
||||
use resource_thread::{send_error, start_sending_sniffed, start_sending_sniffed_opt};
|
||||
use std::borrow::ToOwned;
|
||||
use std::error::Error;
|
||||
use std::fs::File;
|
||||
@ -16,7 +16,7 @@ use std::io::Read;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
use url::Url;
|
||||
use util::task::spawn_named;
|
||||
use util::thread::spawn_named;
|
||||
|
||||
static READ_SIZE: usize = 8192;
|
||||
|
||||
|
@ -29,7 +29,7 @@ use net_traits::hosts::replace_hosts;
|
||||
use net_traits::{CookieSource, IncludeSubdomains, LoadConsumer, LoadContext, LoadData, Metadata};
|
||||
use openssl::ssl::error::{SslError, OpensslError};
|
||||
use openssl::ssl::{SSL_OP_NO_SSLV2, SSL_OP_NO_SSLV3, SSL_VERIFY_PEER, SslContext, SslMethod};
|
||||
use resource_task::{CancellationListener, send_error, start_sending_sniffed_opt};
|
||||
use resource_thread::{CancellationListener, send_error, start_sending_sniffed_opt};
|
||||
use std::borrow::ToOwned;
|
||||
use std::boxed::FnBox;
|
||||
use std::collections::HashSet;
|
||||
@ -41,7 +41,7 @@ use time;
|
||||
use time::Tm;
|
||||
use url::Url;
|
||||
use util::resource_files::resources_dir_path;
|
||||
use util::task::spawn_named;
|
||||
use util::thread::spawn_named;
|
||||
use uuid;
|
||||
|
||||
pub type Connector = HttpsConnector<Openssl>;
|
||||
|
@ -5,10 +5,10 @@
|
||||
use ipc_channel::ipc::{self, IpcSender};
|
||||
use ipc_channel::router::ROUTER;
|
||||
use net_traits::image::base::{Image, load_from_memory};
|
||||
use net_traits::image_cache_task::ImageResponder;
|
||||
use net_traits::image_cache_task::{ImageCacheChan, ImageCacheCommand, ImageCacheTask, ImageState};
|
||||
use net_traits::image_cache_task::{ImageCacheResult, ImageResponse, UsePlaceholder};
|
||||
use net_traits::{AsyncResponseTarget, ControlMsg, LoadConsumer, LoadData, ResourceTask};
|
||||
use net_traits::image_cache_thread::ImageResponder;
|
||||
use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheCommand, ImageCacheThread, ImageState};
|
||||
use net_traits::image_cache_thread::{ImageCacheResult, ImageResponse, UsePlaceholder};
|
||||
use net_traits::{AsyncResponseTarget, ControlMsg, LoadConsumer, LoadData, ResourceThread};
|
||||
use net_traits::{ResponseAction, LoadContext};
|
||||
use std::borrow::ToOwned;
|
||||
use std::collections::HashMap;
|
||||
@ -20,19 +20,19 @@ use std::sync::Arc;
|
||||
use std::sync::mpsc::{Receiver, Select, Sender, channel};
|
||||
use url::Url;
|
||||
use util::resource_files::resources_dir_path;
|
||||
use util::task::spawn_named;
|
||||
use util::taskpool::TaskPool;
|
||||
use util::thread::spawn_named;
|
||||
use util::threadpool::ThreadPool;
|
||||
|
||||
///
|
||||
/// TODO(gw): Remaining work on image cache:
|
||||
/// * Make use of the prefetch support in various parts of the code.
|
||||
/// * Profile time in GetImageIfAvailable - might be worth caching these results per paint / layout task.
|
||||
/// * Profile time in GetImageIfAvailable - might be worth caching these results per paint / layout thread.
|
||||
///
|
||||
/// MAYBE(Yoric):
|
||||
/// * For faster lookups, it might be useful to store the LoadKey in the DOM once we have performed a first load.
|
||||
|
||||
/// Represents an image that is either being loaded
|
||||
/// by the resource task, or decoded by a worker thread.
|
||||
/// by the resource thread, or decoded by a worker thread.
|
||||
struct PendingLoad {
|
||||
// The bytes loaded so far. Reset to an empty vector once loading
|
||||
// is complete and the buffer has been transmitted to the decoder.
|
||||
@ -215,7 +215,7 @@ struct ImageCache {
|
||||
// Receive commands from clients
|
||||
cmd_receiver: Receiver<ImageCacheCommand>,
|
||||
|
||||
// Receive notifications from the resource task
|
||||
// Receive notifications from the resource thread
|
||||
progress_receiver: Receiver<ResourceLoadInfo>,
|
||||
progress_sender: Sender<ResourceLoadInfo>,
|
||||
|
||||
@ -224,10 +224,10 @@ struct ImageCache {
|
||||
decoder_sender: Sender<DecoderMsg>,
|
||||
|
||||
// Worker threads for decoding images.
|
||||
task_pool: TaskPool,
|
||||
thread_pool: ThreadPool,
|
||||
|
||||
// Resource task handle
|
||||
resource_task: ResourceTask,
|
||||
// Resource thread handle
|
||||
resource_thread: ResourceThread,
|
||||
|
||||
// Images that are loading over network, or decoding.
|
||||
pending_loads: AllPendingLoads,
|
||||
@ -239,13 +239,13 @@ struct ImageCache {
|
||||
placeholder_image: Option<Arc<Image>>,
|
||||
}
|
||||
|
||||
/// Message that the decoder worker threads send to main image cache task.
|
||||
/// Message that the decoder worker threads send to main image cache thread.
|
||||
struct DecoderMsg {
|
||||
key: LoadKey,
|
||||
image: Option<Image>,
|
||||
}
|
||||
|
||||
/// The types of messages that the main image cache task receives.
|
||||
/// The types of messages that the main image cache thread receives.
|
||||
enum SelectResult {
|
||||
Command(ImageCacheCommand),
|
||||
Progress(ResourceLoadInfo),
|
||||
@ -338,7 +338,7 @@ impl ImageCache {
|
||||
None
|
||||
}
|
||||
|
||||
// Handle progress messages from the resource task
|
||||
// Handle progress messages from the resource thread
|
||||
fn handle_progress(&mut self, msg: ResourceLoadInfo) {
|
||||
match (msg.action, msg.key) {
|
||||
(ResponseAction::HeadersAvailable(_), _) => {}
|
||||
@ -355,7 +355,7 @@ impl ImageCache {
|
||||
let bytes = mem::replace(&mut pending_load.bytes, vec!());
|
||||
let sender = self.decoder_sender.clone();
|
||||
|
||||
self.task_pool.execute(move || {
|
||||
self.thread_pool.execute(move || {
|
||||
let image = load_from_memory(&bytes);
|
||||
let msg = DecoderMsg {
|
||||
key: key,
|
||||
@ -423,7 +423,7 @@ impl ImageCache {
|
||||
match cache_result {
|
||||
CacheResult::Miss => {
|
||||
// A new load request! Request the load from
|
||||
// the resource task.
|
||||
// the resource thread.
|
||||
let load_data = LoadData::new(LoadContext::Image, (*ref_url).clone(), None);
|
||||
let (action_sender, action_receiver) = ipc::channel().unwrap();
|
||||
let response_target = AsyncResponseTarget {
|
||||
@ -440,7 +440,7 @@ impl ImageCache {
|
||||
key: load_key,
|
||||
}).unwrap();
|
||||
});
|
||||
self.resource_task.send(msg).unwrap();
|
||||
self.resource_thread.send(msg).unwrap();
|
||||
}
|
||||
CacheResult::Hit => {
|
||||
// Request is already on its way.
|
||||
@ -452,7 +452,7 @@ impl ImageCache {
|
||||
}
|
||||
|
||||
/// Create a new image cache.
|
||||
pub fn new_image_cache_task(resource_task: ResourceTask) -> ImageCacheTask {
|
||||
pub fn new_image_cache_thread(resource_thread: ResourceThread) -> ImageCacheThread {
|
||||
let (ipc_command_sender, ipc_command_receiver) = ipc::channel().unwrap();
|
||||
let (progress_sender, progress_receiver) = channel();
|
||||
let (decoder_sender, decoder_receiver) = channel();
|
||||
@ -480,15 +480,15 @@ pub fn new_image_cache_task(resource_task: ResourceTask) -> ImageCacheTask {
|
||||
progress_receiver: progress_receiver,
|
||||
decoder_sender: decoder_sender,
|
||||
decoder_receiver: decoder_receiver,
|
||||
task_pool: TaskPool::new(4),
|
||||
thread_pool: ThreadPool::new(4),
|
||||
pending_loads: AllPendingLoads::new(),
|
||||
completed_loads: HashMap::new(),
|
||||
resource_task: resource_task,
|
||||
resource_thread: resource_thread,
|
||||
placeholder_image: placeholder_image,
|
||||
};
|
||||
|
||||
cache.run();
|
||||
});
|
||||
|
||||
ImageCacheTask::new(ipc_command_sender)
|
||||
ImageCacheThread::new(ipc_command_sender)
|
||||
}
|
@ -36,11 +36,11 @@ pub mod data_loader;
|
||||
pub mod file_loader;
|
||||
pub mod hsts;
|
||||
pub mod http_loader;
|
||||
pub mod image_cache_task;
|
||||
pub mod image_cache_thread;
|
||||
pub mod mime_classifier;
|
||||
pub mod pub_domains;
|
||||
pub mod resource_task;
|
||||
pub mod storage_task;
|
||||
pub mod resource_thread;
|
||||
pub mod storage_thread;
|
||||
pub mod websocket_loader;
|
||||
|
||||
/// An implementation of the [Fetch spec](https://fetch.spec.whatwg.org/)
|
||||
|
@ -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/. */
|
||||
|
||||
//! A task that takes a URL and streams back the binary data.
|
||||
//! A thread that takes a URL and streams back the binary data.
|
||||
|
||||
use about_loader;
|
||||
use cookie;
|
||||
@ -19,7 +19,7 @@ use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
|
||||
use mime_classifier::{ApacheBugFlag, MIMEClassifier, NoSniffFlag};
|
||||
use net_traits::LoadContext;
|
||||
use net_traits::ProgressMsg::Done;
|
||||
use net_traits::{AsyncResponseTarget, Metadata, ProgressMsg, ResourceTask, ResponseAction};
|
||||
use net_traits::{AsyncResponseTarget, Metadata, ProgressMsg, ResourceThread, ResponseAction};
|
||||
use net_traits::{ControlMsg, CookieSource, LoadConsumer, LoadData, LoadResponse, ResourceId};
|
||||
use net_traits::{WebSocketCommunicate, WebSocketConnectData};
|
||||
use std::borrow::ToOwned;
|
||||
@ -30,7 +30,7 @@ use std::sync::mpsc::{Receiver, Sender, channel};
|
||||
use std::sync::{Arc, RwLock};
|
||||
use url::Url;
|
||||
use util::prefs;
|
||||
use util::task::spawn_named;
|
||||
use util::thread::spawn_named;
|
||||
use websocket_loader;
|
||||
|
||||
pub enum ProgressSender {
|
||||
@ -145,9 +145,9 @@ fn start_sending_opt(start_chan: LoadConsumer, metadata: Metadata) -> Result<Pro
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a ResourceTask
|
||||
pub fn new_resource_task(user_agent: String,
|
||||
devtools_chan: Option<Sender<DevtoolsControlMsg>>) -> ResourceTask {
|
||||
/// Create a ResourceThread
|
||||
pub fn new_resource_thread(user_agent: String,
|
||||
devtools_chan: Option<Sender<DevtoolsControlMsg>>) -> ResourceThread {
|
||||
let hsts_preload = match preload_hsts_domains() {
|
||||
Some(list) => list,
|
||||
None => HSTSList::new()
|
||||
@ -175,7 +175,7 @@ struct ResourceChannelManager {
|
||||
}
|
||||
|
||||
impl ResourceChannelManager {
|
||||
fn start(&mut self, control_sender: ResourceTask) {
|
||||
fn start(&mut self, control_sender: ResourceThread) {
|
||||
loop {
|
||||
match self.from_client.recv().unwrap() {
|
||||
ControlMsg::Load(load_data, consumer, id_sender) =>
|
||||
@ -213,15 +213,15 @@ pub struct CancellableResource {
|
||||
/// If we haven't initiated any cancel requests, then the loaders ask
|
||||
/// the listener to remove the `ResourceId` in the `HashMap` of
|
||||
/// `ResourceManager` once they finish loading
|
||||
resource_task: ResourceTask,
|
||||
resource_thread: ResourceThread,
|
||||
}
|
||||
|
||||
impl CancellableResource {
|
||||
pub fn new(receiver: Receiver<()>, res_id: ResourceId, res_task: ResourceTask) -> CancellableResource {
|
||||
pub fn new(receiver: Receiver<()>, res_id: ResourceId, res_thread: ResourceThread) -> CancellableResource {
|
||||
CancellableResource {
|
||||
cancel_receiver: receiver,
|
||||
resource_id: res_id,
|
||||
resource_task: res_task,
|
||||
resource_thread: res_thread,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -264,7 +264,7 @@ impl Drop for CancellationListener {
|
||||
fn drop(&mut self) {
|
||||
if let Some(ref resource) = self.cancel_resource {
|
||||
// Ensure that the resource manager stops tracking this request now that it's terminated.
|
||||
let _ = resource.resource_task.send(ControlMsg::Cancel(resource.resource_id));
|
||||
let _ = resource.resource_thread.send(ControlMsg::Cancel(resource.resource_id));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -313,7 +313,7 @@ impl ResourceManager {
|
||||
load_data: LoadData,
|
||||
consumer: LoadConsumer,
|
||||
id_sender: Option<IpcSender<ResourceId>>,
|
||||
resource_task: ResourceTask) {
|
||||
resource_thread: ResourceThread) {
|
||||
|
||||
fn from_factory(factory: fn(LoadData, LoadConsumer, Arc<MIMEClassifier>, CancellationListener))
|
||||
-> Box<FnBox(LoadData,
|
||||
@ -331,7 +331,7 @@ impl ResourceManager {
|
||||
let (cancel_sender, cancel_receiver) = channel();
|
||||
self.cancel_load_map.insert(current_res_id, cancel_sender);
|
||||
self.next_resource_id.0 += 1;
|
||||
CancellableResource::new(cancel_receiver, current_res_id, resource_task)
|
||||
CancellableResource::new(cancel_receiver, current_res_id, resource_thread)
|
||||
});
|
||||
|
||||
let cancel_listener = CancellationListener::new(cancel_resource);
|
||||
@ -346,12 +346,12 @@ impl ResourceManager {
|
||||
"data" => from_factory(data_loader::factory),
|
||||
"about" => from_factory(about_loader::factory),
|
||||
_ => {
|
||||
debug!("resource_task: no loader for scheme {}", load_data.url.scheme);
|
||||
debug!("resource_thread: no loader for scheme {}", load_data.url.scheme);
|
||||
send_error(load_data.url, "no loader for scheme".to_owned(), consumer);
|
||||
return
|
||||
}
|
||||
};
|
||||
debug!("resource_task: loading url: {}", load_data.url.serialize());
|
||||
debug!("resource_thread: loading url: {}", load_data.url.serialize());
|
||||
|
||||
loader.call_box((load_data,
|
||||
consumer,
|
@ -3,23 +3,23 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
|
||||
use net_traits::storage_task::{StorageTask, StorageTaskMsg, StorageType};
|
||||
use net_traits::storage_thread::{StorageThread, StorageThreadMsg, StorageType};
|
||||
use std::borrow::ToOwned;
|
||||
use std::collections::BTreeMap;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::mpsc::channel;
|
||||
use url::Url;
|
||||
use util::task::spawn_named;
|
||||
use util::thread::spawn_named;
|
||||
|
||||
const QUOTA_SIZE_LIMIT: usize = 5 * 1024 * 1024;
|
||||
|
||||
pub trait StorageTaskFactory {
|
||||
pub trait StorageThreadFactory {
|
||||
fn new() -> Self;
|
||||
}
|
||||
|
||||
impl StorageTaskFactory for StorageTask {
|
||||
/// Create a StorageTask
|
||||
fn new() -> StorageTask {
|
||||
impl StorageThreadFactory for StorageThread {
|
||||
/// Create a StorageThread
|
||||
fn new() -> StorageThread {
|
||||
let (chan, port) = ipc::channel().unwrap();
|
||||
spawn_named("StorageManager".to_owned(), move || {
|
||||
StorageManager::new(port).start();
|
||||
@ -29,13 +29,13 @@ impl StorageTaskFactory for StorageTask {
|
||||
}
|
||||
|
||||
struct StorageManager {
|
||||
port: IpcReceiver<StorageTaskMsg>,
|
||||
port: IpcReceiver<StorageThreadMsg>,
|
||||
session_data: HashMap<String, (usize, BTreeMap<String, String>)>,
|
||||
local_data: HashMap<String, (usize, BTreeMap<String, String>)>,
|
||||
}
|
||||
|
||||
impl StorageManager {
|
||||
fn new(port: IpcReceiver<StorageTaskMsg>) -> StorageManager {
|
||||
fn new(port: IpcReceiver<StorageThreadMsg>) -> StorageManager {
|
||||
StorageManager {
|
||||
port: port,
|
||||
session_data: HashMap::new(),
|
||||
@ -48,28 +48,28 @@ impl StorageManager {
|
||||
fn start(&mut self) {
|
||||
loop {
|
||||
match self.port.recv().unwrap() {
|
||||
StorageTaskMsg::Length(sender, url, storage_type) => {
|
||||
StorageThreadMsg::Length(sender, url, storage_type) => {
|
||||
self.length(sender, url, storage_type)
|
||||
}
|
||||
StorageTaskMsg::Key(sender, url, storage_type, index) => {
|
||||
StorageThreadMsg::Key(sender, url, storage_type, index) => {
|
||||
self.key(sender, url, storage_type, index)
|
||||
}
|
||||
StorageTaskMsg::Keys(sender, url, storage_type) => {
|
||||
StorageThreadMsg::Keys(sender, url, storage_type) => {
|
||||
self.keys(sender, url, storage_type)
|
||||
}
|
||||
StorageTaskMsg::SetItem(sender, url, storage_type, name, value) => {
|
||||
StorageThreadMsg::SetItem(sender, url, storage_type, name, value) => {
|
||||
self.set_item(sender, url, storage_type, name, value)
|
||||
}
|
||||
StorageTaskMsg::GetItem(sender, url, storage_type, name) => {
|
||||
StorageThreadMsg::GetItem(sender, url, storage_type, name) => {
|
||||
self.request_item(sender, url, storage_type, name)
|
||||
}
|
||||
StorageTaskMsg::RemoveItem(sender, url, storage_type, name) => {
|
||||
StorageThreadMsg::RemoveItem(sender, url, storage_type, name) => {
|
||||
self.remove_item(sender, url, storage_type, name)
|
||||
}
|
||||
StorageTaskMsg::Clear(sender, url, storage_type) => {
|
||||
StorageThreadMsg::Clear(sender, url, storage_type) => {
|
||||
self.clear(sender, url, storage_type)
|
||||
}
|
||||
StorageTaskMsg::Exit => {
|
||||
StorageThreadMsg::Exit => {
|
||||
break
|
||||
}
|
||||
}
|
@ -10,7 +10,7 @@ use net_traits::{WebSocketCommunicate, WebSocketConnectData, WebSocketDomAction,
|
||||
use std::ascii::AsciiExt;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::thread;
|
||||
use util::task::spawn_named;
|
||||
use util::thread::spawn_named;
|
||||
use websocket::client::receiver::Receiver;
|
||||
use websocket::client::request::Url;
|
||||
use websocket::client::sender::Sender;
|
||||
|
@ -71,10 +71,10 @@ pub enum ImageCacheCommand {
|
||||
/// Synchronously check the state of an image in the cache.
|
||||
/// TODO(gw): Profile this on some real world sites and see
|
||||
/// if it's worth caching the results of this locally in each
|
||||
/// layout / paint task.
|
||||
/// layout / paint thread.
|
||||
GetImageIfAvailable(Url, UsePlaceholder, IpcSender<Result<Arc<Image>, ImageState>>),
|
||||
|
||||
/// Clients must wait for a response before shutting down the ResourceTask
|
||||
/// Clients must wait for a response before shutting down the ResourceThread
|
||||
Exit(IpcSender<()>),
|
||||
}
|
||||
|
||||
@ -84,19 +84,19 @@ pub enum UsePlaceholder {
|
||||
Yes,
|
||||
}
|
||||
|
||||
/// The client side of the image cache task. This can be safely cloned
|
||||
/// and passed to different tasks.
|
||||
/// The client side of the image cache thread. This can be safely cloned
|
||||
/// and passed to different threads.
|
||||
#[derive(Clone, Deserialize, Serialize)]
|
||||
pub struct ImageCacheTask {
|
||||
pub struct ImageCacheThread {
|
||||
chan: IpcSender<ImageCacheCommand>,
|
||||
}
|
||||
|
||||
/// The public API for the image cache task.
|
||||
impl ImageCacheTask {
|
||||
/// The public API for the image cache thread.
|
||||
impl ImageCacheThread {
|
||||
|
||||
/// Construct a new image cache
|
||||
pub fn new(chan: IpcSender<ImageCacheCommand>) -> ImageCacheTask {
|
||||
ImageCacheTask {
|
||||
pub fn new(chan: IpcSender<ImageCacheCommand>) -> ImageCacheThread {
|
||||
ImageCacheThread {
|
||||
chan: chan,
|
||||
}
|
||||
}
|
||||
@ -119,7 +119,7 @@ impl ImageCacheTask {
|
||||
receiver.recv().unwrap()
|
||||
}
|
||||
|
||||
/// Shutdown the image cache task.
|
||||
/// Shutdown the image cache thread.
|
||||
pub fn exit(&self) {
|
||||
let (response_chan, response_port) = ipc::channel().unwrap();
|
||||
self.chan.send(ImageCacheCommand::Exit(response_chan)).unwrap();
|
@ -37,10 +37,10 @@ use util::mem::HeapSizeOf;
|
||||
use websocket::header;
|
||||
|
||||
pub mod hosts;
|
||||
pub mod image_cache_task;
|
||||
pub mod image_cache_thread;
|
||||
pub mod net_error_list;
|
||||
pub mod response;
|
||||
pub mod storage_task;
|
||||
pub mod storage_thread;
|
||||
|
||||
/// Image handling.
|
||||
///
|
||||
@ -160,8 +160,8 @@ pub enum LoadConsumer {
|
||||
Listener(AsyncResponseTarget),
|
||||
}
|
||||
|
||||
/// Handle to a resource task
|
||||
pub type ResourceTask = IpcSender<ControlMsg>;
|
||||
/// Handle to a resource thread
|
||||
pub type ResourceThread = IpcSender<ControlMsg>;
|
||||
|
||||
#[derive(PartialEq, Copy, Clone, Deserialize, Serialize)]
|
||||
pub enum IncludeSubdomains {
|
||||
@ -220,10 +220,10 @@ pub enum ControlMsg {
|
||||
}
|
||||
|
||||
/// Initialized but unsent request. Encapsulates everything necessary to instruct
|
||||
/// the resource task to make a new request. The `load` method *must* be called before
|
||||
/// destruction or the task will panic.
|
||||
/// the resource thread to make a new request. The `load` method *must* be called before
|
||||
/// destruction or the thread will panic.
|
||||
pub struct PendingAsyncLoad {
|
||||
resource_task: ResourceTask,
|
||||
resource_thread: ResourceThread,
|
||||
url: Url,
|
||||
pipeline: Option<PipelineId>,
|
||||
guard: PendingLoadGuard,
|
||||
@ -249,10 +249,10 @@ impl Drop for PendingLoadGuard {
|
||||
}
|
||||
|
||||
impl PendingAsyncLoad {
|
||||
pub fn new(context: LoadContext, resource_task: ResourceTask, url: Url, pipeline: Option<PipelineId>)
|
||||
pub fn new(context: LoadContext, resource_thread: ResourceThread, url: Url, pipeline: Option<PipelineId>)
|
||||
-> PendingAsyncLoad {
|
||||
PendingAsyncLoad {
|
||||
resource_task: resource_task,
|
||||
resource_thread: resource_thread,
|
||||
url: url,
|
||||
pipeline: pipeline,
|
||||
guard: PendingLoadGuard { loaded: false, },
|
||||
@ -265,7 +265,7 @@ impl PendingAsyncLoad {
|
||||
self.guard.neuter();
|
||||
let load_data = LoadData::new(self.context, self.url, self.pipeline);
|
||||
let consumer = LoadConsumer::Listener(listener);
|
||||
self.resource_task.send(ControlMsg::Load(load_data, consumer, None)).unwrap();
|
||||
self.resource_thread.send(ControlMsg::Load(load_data, consumer, None)).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
@ -360,12 +360,12 @@ pub enum ProgressMsg {
|
||||
|
||||
/// Convenience function for synchronously loading a whole resource.
|
||||
pub fn load_whole_resource(context: LoadContext,
|
||||
resource_task: &ResourceTask,
|
||||
resource_thread: &ResourceThread,
|
||||
url: Url,
|
||||
pipeline_id: Option<PipelineId>)
|
||||
-> Result<(Metadata, Vec<u8>), String> {
|
||||
let (start_chan, start_port) = ipc::channel().unwrap();
|
||||
resource_task.send(ControlMsg::Load(LoadData::new(context, url, pipeline_id),
|
||||
resource_thread.send(ControlMsg::Load(LoadData::new(context, url, pipeline_id),
|
||||
LoadConsumer::Channel(start_chan), None)).unwrap();
|
||||
let response = start_port.recv().unwrap();
|
||||
|
||||
|
@ -13,7 +13,7 @@ pub enum StorageType {
|
||||
|
||||
/// Request operations on the storage data associated with a particular url
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub enum StorageTaskMsg {
|
||||
pub enum StorageThreadMsg {
|
||||
/// gets the number of key/value pairs present in the associated storage data
|
||||
Length(IpcSender<usize>, Url, StorageType),
|
||||
|
||||
@ -35,11 +35,11 @@ pub enum StorageTaskMsg {
|
||||
/// clears the associated storage data by removing all the key/value pairs
|
||||
Clear(IpcSender<bool>, Url, StorageType),
|
||||
|
||||
/// shut down this task
|
||||
/// shut down this thread
|
||||
Exit
|
||||
}
|
||||
|
||||
/// Handle to a storage task
|
||||
pub type StorageTask = IpcSender<StorageTaskMsg>;
|
||||
/// Handle to a storage thread
|
||||
pub type StorageThread = IpcSender<StorageThreadMsg>;
|
||||
|
||||
|
@ -29,7 +29,7 @@ declare_lint!(UNROOTED_MUST_ROOT, Deny,
|
||||
/// This helps catch most situations where pointers like `JS<T>` are used in a way that they can be invalidated by a
|
||||
/// GC pass.
|
||||
///
|
||||
/// Structs which have their own mechanism of rooting their unrooted contents (e.g. `ScriptTask`)
|
||||
/// Structs which have their own mechanism of rooting their unrooted contents (e.g. `ScriptThread`)
|
||||
/// can be marked as `#[allow(unrooted_must_root)]`. Smart pointers which root their interior type
|
||||
/// can be marked as `#[allow_unrooted_interior]`
|
||||
pub struct UnrootedPass;
|
||||
|
@ -12,7 +12,7 @@ use std::borrow::ToOwned;
|
||||
use std::cmp::Ordering;
|
||||
use std::collections::HashMap;
|
||||
use std::thread;
|
||||
use util::task::spawn_named;
|
||||
use util::thread::spawn_named;
|
||||
use util::time::duration_from_seconds;
|
||||
|
||||
pub struct Profiler {
|
||||
|
@ -15,7 +15,7 @@ use std::collections::BTreeMap;
|
||||
use std::time::Duration;
|
||||
use std::{thread, f64};
|
||||
use std_time::precise_time_ns;
|
||||
use util::task::spawn_named;
|
||||
use util::thread::spawn_named;
|
||||
use util::time::duration_from_seconds;
|
||||
|
||||
pub trait Formattable {
|
||||
|
@ -50,7 +50,7 @@ impl ProfilerChan {
|
||||
// Register the memory reporter.
|
||||
let (reporter_sender, reporter_receiver) = ipc::channel().unwrap();
|
||||
ROUTER.add_route(reporter_receiver.to_opaque(), box move |message| {
|
||||
// Just injects an appropriate event into the paint task's queue.
|
||||
// Just injects an appropriate event into the paint thread's queue.
|
||||
let request: ReporterRequest = message.to().unwrap();
|
||||
channel_for_reporter.send(msg(request.reports_channel));
|
||||
});
|
||||
|
@ -20,7 +20,7 @@ use hyper::mime::{Mime, SubLevel, TopLevel};
|
||||
use hyper::status::StatusClass::Success;
|
||||
use net_traits::{AsyncResponseListener, Metadata, ResponseAction};
|
||||
use network_listener::{NetworkListener, PreInvoke};
|
||||
use script_task::ScriptChan;
|
||||
use script_thread::ScriptChan;
|
||||
use std::ascii::AsciiExt;
|
||||
use std::borrow::ToOwned;
|
||||
use std::sync::{Arc, Mutex};
|
||||
@ -28,7 +28,7 @@ use time::{self, Timespec, now};
|
||||
use unicase::UniCase;
|
||||
use url::{SchemeData, Url};
|
||||
use util::mem::HeapSizeOf;
|
||||
use util::task::spawn_named;
|
||||
use util::thread::spawn_named;
|
||||
|
||||
/// Interface for network listeners concerned with CORS checks. Proper network requests
|
||||
/// should be initiated from this method, based on the response provided.
|
||||
@ -141,7 +141,7 @@ impl CORSRequest {
|
||||
};
|
||||
|
||||
// TODO: this exists only to make preflight check non-blocking
|
||||
// perhaps should be handled by the resource task?
|
||||
// perhaps should be handled by the resource thread?
|
||||
let req = self.clone();
|
||||
spawn_named("cors".to_owned(), move || {
|
||||
let response = req.http_fetch();
|
||||
|
@ -19,7 +19,7 @@ use js::jsapi::{ObjectClassName, RootedObject, RootedValue};
|
||||
use js::jsval::UndefinedValue;
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use page::{IterablePage, Page};
|
||||
use script_task::get_page;
|
||||
use script_thread::get_page;
|
||||
use std::ffi::CStr;
|
||||
use std::rc::Rc;
|
||||
use std::str;
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use net_traits::AsyncResponseTarget;
|
||||
use net_traits::{PendingAsyncLoad, ResourceTask, LoadContext};
|
||||
use net_traits::{PendingAsyncLoad, ResourceThread, LoadContext};
|
||||
use std::sync::Arc;
|
||||
use url::Url;
|
||||
|
||||
@ -43,10 +43,10 @@ impl LoadType {
|
||||
|
||||
#[derive(JSTraceable, HeapSizeOf)]
|
||||
pub struct DocumentLoader {
|
||||
/// We use an `Arc<ResourceTask>` here in order to avoid file descriptor exhaustion when there
|
||||
/// We use an `Arc<ResourceThread>` here in order to avoid file descriptor exhaustion when there
|
||||
/// are lots of iframes.
|
||||
#[ignore_heap_size_of = "channels are hard"]
|
||||
pub resource_task: Arc<ResourceTask>,
|
||||
pub resource_thread: Arc<ResourceThread>,
|
||||
pipeline: Option<PipelineId>,
|
||||
blocking_loads: Vec<LoadType>,
|
||||
events_inhibited: bool,
|
||||
@ -54,19 +54,19 @@ pub struct DocumentLoader {
|
||||
|
||||
impl DocumentLoader {
|
||||
pub fn new(existing: &DocumentLoader) -> DocumentLoader {
|
||||
DocumentLoader::new_with_task(existing.resource_task.clone(), None, None)
|
||||
DocumentLoader::new_with_thread(existing.resource_thread.clone(), None, None)
|
||||
}
|
||||
|
||||
/// We use an `Arc<ResourceTask>` here in order to avoid file descriptor exhaustion when there
|
||||
/// We use an `Arc<ResourceThread>` here in order to avoid file descriptor exhaustion when there
|
||||
/// are lots of iframes.
|
||||
pub fn new_with_task(resource_task: Arc<ResourceTask>,
|
||||
pub fn new_with_thread(resource_thread: Arc<ResourceThread>,
|
||||
pipeline: Option<PipelineId>,
|
||||
initial_load: Option<Url>)
|
||||
-> DocumentLoader {
|
||||
let initial_loads = initial_load.into_iter().map(LoadType::PageSource).collect();
|
||||
|
||||
DocumentLoader {
|
||||
resource_task: resource_task,
|
||||
resource_thread: resource_thread,
|
||||
pipeline: pipeline,
|
||||
blocking_loads: initial_loads,
|
||||
events_inhibited: false,
|
||||
@ -79,7 +79,7 @@ impl DocumentLoader {
|
||||
let context = load.to_load_context();
|
||||
let url = load.url().clone();
|
||||
self.blocking_loads.push(load);
|
||||
PendingAsyncLoad::new(context, (*self.resource_task).clone(), url, self.pipeline)
|
||||
PendingAsyncLoad::new(context, (*self.resource_thread).clone(), url, self.pipeline)
|
||||
}
|
||||
|
||||
/// Create and initiate a new network request.
|
||||
|
@ -7,8 +7,8 @@
|
||||
use dom::bindings::trace::JSTraceable;
|
||||
use js::jsapi::JSTracer;
|
||||
use std::cell::{BorrowState, Ref, RefCell, RefMut};
|
||||
use util::task_state;
|
||||
use util::task_state::SCRIPT;
|
||||
use util::thread_state;
|
||||
use util::thread_state::SCRIPT;
|
||||
|
||||
/// A mutable field in the DOM.
|
||||
///
|
||||
@ -25,10 +25,10 @@ pub struct DOMRefCell<T> {
|
||||
impl<T> DOMRefCell<T> {
|
||||
/// Return a reference to the contents.
|
||||
///
|
||||
/// For use in the layout task only.
|
||||
/// For use in the layout thread only.
|
||||
#[allow(unsafe_code)]
|
||||
pub unsafe fn borrow_for_layout(&self) -> &T {
|
||||
debug_assert!(task_state::get().is_layout());
|
||||
debug_assert!(thread_state::get().is_layout());
|
||||
&*self.value.as_unsafe_cell().get()
|
||||
}
|
||||
|
||||
@ -40,7 +40,7 @@ impl<T> DOMRefCell<T> {
|
||||
pub unsafe fn borrow_for_gc_trace(&self) -> &T {
|
||||
// FIXME: IN_GC isn't reliable enough - doesn't catch minor GCs
|
||||
// https://github.com/servo/servo/issues/6389
|
||||
// debug_assert!(task_state::get().contains(SCRIPT | IN_GC));
|
||||
// debug_assert!(thread_state::get().contains(SCRIPT | IN_GC));
|
||||
&*self.value.as_unsafe_cell().get()
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ impl<T> DOMRefCell<T> {
|
||||
///
|
||||
#[allow(unsafe_code)]
|
||||
pub unsafe fn borrow_for_script_deallocation(&self) -> &mut T {
|
||||
debug_assert!(task_state::get().contains(SCRIPT));
|
||||
debug_assert!(thread_state::get().contains(SCRIPT));
|
||||
&mut *self.value.as_unsafe_cell().get()
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ impl<T> DOMRefCell<T> {
|
||||
///
|
||||
/// Panics if this is called off the script thread.
|
||||
pub fn try_borrow(&self) -> Option<Ref<T>> {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
match self.value.borrow_state() {
|
||||
BorrowState::Writing => None,
|
||||
_ => Some(self.value.borrow()),
|
||||
@ -88,17 +88,17 @@ impl<T> DOMRefCell<T> {
|
||||
///
|
||||
/// Panics if this is called off the script thread.
|
||||
pub fn try_borrow_mut(&self) -> Option<RefMut<T>> {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
match self.value.borrow_state() {
|
||||
BorrowState::Unused => Some(self.value.borrow_mut()),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Version of the above that we use during restyle while the script task
|
||||
/// Version of the above that we use during restyle while the script thread
|
||||
/// is blocked.
|
||||
pub fn borrow_mut_for_layout(&self) -> RefMut<T> {
|
||||
debug_assert!(task_state::get().is_layout());
|
||||
debug_assert!(thread_state::get().is_layout());
|
||||
self.value.borrow_mut()
|
||||
}
|
||||
}
|
||||
|
@ -19,9 +19,9 @@ use js::jsapi::GetGlobalForObjectCrossCompartment;
|
||||
use js::jsapi::{JSContext, JSObject, JS_GetClass, MutableHandleValue};
|
||||
use js::{JSCLASS_IS_DOMJSCLASS, JSCLASS_IS_GLOBAL};
|
||||
use msg::constellation_msg::{ConstellationChan, PipelineId};
|
||||
use net_traits::ResourceTask;
|
||||
use net_traits::ResourceThread;
|
||||
use profile_traits::mem;
|
||||
use script_task::{CommonScriptMsg, ScriptChan, ScriptPort, ScriptTask};
|
||||
use script_thread::{CommonScriptMsg, ScriptChan, ScriptPort, ScriptThread};
|
||||
use script_traits::{MsDuration, ScriptMsg as ConstellationMsg, TimerEventRequest};
|
||||
use timers::{ScheduledCallback, TimerHandle};
|
||||
use url::Url;
|
||||
@ -65,7 +65,7 @@ impl<'a> GlobalRef<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Extract a `Window`, causing task failure if the global object is not
|
||||
/// Extract a `Window`, causing thread failure if the global object is not
|
||||
/// a `Window`.
|
||||
pub fn as_window(&self) -> &window::Window {
|
||||
match *self {
|
||||
@ -82,7 +82,7 @@ impl<'a> GlobalRef<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Get a `mem::ProfilerChan` to send messages to the memory profiler task.
|
||||
/// Get a `mem::ProfilerChan` to send messages to the memory profiler thread.
|
||||
pub fn mem_profiler_chan(&self) -> mem::ProfilerChan {
|
||||
match *self {
|
||||
GlobalRef::Window(window) => window.mem_profiler_chan(),
|
||||
@ -107,7 +107,7 @@ impl<'a> GlobalRef<'a> {
|
||||
}
|
||||
|
||||
/// Get an `IpcSender<ScriptToDevtoolsControlMsg>` to send messages to Devtools
|
||||
/// task when available.
|
||||
/// thread when available.
|
||||
pub fn devtools_chan(&self) -> Option<IpcSender<ScriptToDevtoolsControlMsg>> {
|
||||
match *self {
|
||||
GlobalRef::Window(window) => window.devtools_chan(),
|
||||
@ -115,16 +115,16 @@ impl<'a> GlobalRef<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the `ResourceTask` for this global scope.
|
||||
pub fn resource_task(&self) -> ResourceTask {
|
||||
/// Get the `ResourceThread` for this global scope.
|
||||
pub fn resource_thread(&self) -> ResourceThread {
|
||||
match *self {
|
||||
GlobalRef::Window(ref window) => {
|
||||
let doc = window.Document();
|
||||
let doc = doc.r();
|
||||
let loader = doc.loader();
|
||||
(*loader.resource_task).clone()
|
||||
(*loader.resource_thread).clone()
|
||||
}
|
||||
GlobalRef::Worker(ref worker) => worker.resource_task().clone(),
|
||||
GlobalRef::Worker(ref worker) => worker.resource_thread().clone(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -154,45 +154,45 @@ impl<'a> GlobalRef<'a> {
|
||||
|
||||
/// `ScriptChan` used to send messages to the event loop of this global's
|
||||
/// thread.
|
||||
pub fn dom_manipulation_task_source(&self) -> Box<ScriptChan + Send> {
|
||||
pub fn dom_manipulation_thread_source(&self) -> Box<ScriptChan + Send> {
|
||||
match *self {
|
||||
GlobalRef::Window(ref window) => window.dom_manipulation_task_source(),
|
||||
GlobalRef::Window(ref window) => window.dom_manipulation_thread_source(),
|
||||
GlobalRef::Worker(ref worker) => worker.script_chan(),
|
||||
}
|
||||
}
|
||||
|
||||
/// `ScriptChan` used to send messages to the event loop of this global's
|
||||
/// thread.
|
||||
pub fn user_interaction_task_source(&self) -> Box<ScriptChan + Send> {
|
||||
pub fn user_interaction_thread_source(&self) -> Box<ScriptChan + Send> {
|
||||
match *self {
|
||||
GlobalRef::Window(ref window) => window.user_interaction_task_source(),
|
||||
GlobalRef::Window(ref window) => window.user_interaction_thread_source(),
|
||||
GlobalRef::Worker(ref worker) => worker.script_chan(),
|
||||
}
|
||||
}
|
||||
|
||||
/// `ScriptChan` used to send messages to the event loop of this global's
|
||||
/// thread.
|
||||
pub fn networking_task_source(&self) -> Box<ScriptChan + Send> {
|
||||
pub fn networking_thread_source(&self) -> Box<ScriptChan + Send> {
|
||||
match *self {
|
||||
GlobalRef::Window(ref window) => window.networking_task_source(),
|
||||
GlobalRef::Window(ref window) => window.networking_thread_source(),
|
||||
GlobalRef::Worker(ref worker) => worker.script_chan(),
|
||||
}
|
||||
}
|
||||
|
||||
/// `ScriptChan` used to send messages to the event loop of this global's
|
||||
/// thread.
|
||||
pub fn history_traversal_task_source(&self) -> Box<ScriptChan + Send> {
|
||||
pub fn history_traversal_thread_source(&self) -> Box<ScriptChan + Send> {
|
||||
match *self {
|
||||
GlobalRef::Window(ref window) => window.history_traversal_task_source(),
|
||||
GlobalRef::Window(ref window) => window.history_traversal_thread_source(),
|
||||
GlobalRef::Worker(ref worker) => worker.script_chan(),
|
||||
}
|
||||
}
|
||||
|
||||
/// `ScriptChan` used to send messages to the event loop of this global's
|
||||
/// thread.
|
||||
pub fn file_reading_task_source(&self) -> Box<ScriptChan + Send> {
|
||||
pub fn file_reading_thread_source(&self) -> Box<ScriptChan + Send> {
|
||||
match *self {
|
||||
GlobalRef::Window(ref window) => window.file_reading_task_source(),
|
||||
GlobalRef::Window(ref window) => window.file_reading_thread_source(),
|
||||
GlobalRef::Worker(ref worker) => worker.script_chan(),
|
||||
}
|
||||
}
|
||||
@ -207,11 +207,11 @@ impl<'a> GlobalRef<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Process a single event as if it were the next event in the task queue for
|
||||
/// Process a single event as if it were the next event in the thread queue for
|
||||
/// this global.
|
||||
pub fn process_event(&self, msg: CommonScriptMsg) {
|
||||
match *self {
|
||||
GlobalRef::Window(_) => ScriptTask::process_event(msg),
|
||||
GlobalRef::Window(_) => ScriptThread::process_event(msg),
|
||||
GlobalRef::Worker(ref worker) => worker.process_event(msg),
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ use dom::node::Node;
|
||||
use js::jsapi::{Heap, JSObject, JSTracer};
|
||||
use js::jsval::JSVal;
|
||||
use layout_interface::TrustedNodeAddress;
|
||||
use script_task::STACK_ROOTS;
|
||||
use script_thread::STACK_ROOTS;
|
||||
use std::cell::UnsafeCell;
|
||||
use std::default::Default;
|
||||
use std::hash::{Hash, Hasher};
|
||||
@ -41,7 +41,7 @@ use std::mem;
|
||||
use std::ops::Deref;
|
||||
use std::ptr;
|
||||
use util::mem::HeapSizeOf;
|
||||
use util::task_state;
|
||||
use util::thread_state;
|
||||
|
||||
/// A traced reference to a DOM object
|
||||
///
|
||||
@ -66,7 +66,7 @@ impl<T> HeapSizeOf for JS<T> {
|
||||
impl<T> JS<T> {
|
||||
/// Returns `LayoutJS<T>` containing the same pointer.
|
||||
pub unsafe fn to_layout(&self) -> LayoutJS<T> {
|
||||
debug_assert!(task_state::get().is_layout());
|
||||
debug_assert!(thread_state::get().is_layout());
|
||||
LayoutJS {
|
||||
ptr: self.ptr.clone(),
|
||||
}
|
||||
@ -78,7 +78,7 @@ impl<T: Reflectable> JS<T> {
|
||||
/// XXX Not a great API. Should be a call on Root<T> instead
|
||||
#[allow(unrooted_must_root)]
|
||||
pub fn from_rooted(root: &Root<T>) -> JS<T> {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
JS {
|
||||
ptr: unsafe { NonZero::new(&**root) },
|
||||
}
|
||||
@ -86,7 +86,7 @@ impl<T: Reflectable> JS<T> {
|
||||
/// Create a JS<T> from a &T
|
||||
#[allow(unrooted_must_root)]
|
||||
pub fn from_ref(obj: &T) -> JS<T> {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
JS {
|
||||
ptr: unsafe { NonZero::new(&*obj) },
|
||||
}
|
||||
@ -97,7 +97,7 @@ impl<T: Reflectable> Deref for JS<T> {
|
||||
type Target = T;
|
||||
|
||||
fn deref(&self) -> &T {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
// We can only have &JS<T> from a rooted thing, so it's safe to deref
|
||||
// it to &T.
|
||||
unsafe { &**self.ptr }
|
||||
@ -123,7 +123,7 @@ impl<T: Castable> LayoutJS<T> {
|
||||
where U: Castable,
|
||||
T: DerivedFrom<U>
|
||||
{
|
||||
debug_assert!(task_state::get().is_layout());
|
||||
debug_assert!(thread_state::get().is_layout());
|
||||
unsafe { mem::transmute_copy(self) }
|
||||
}
|
||||
|
||||
@ -131,7 +131,7 @@ impl<T: Castable> LayoutJS<T> {
|
||||
pub fn downcast<U>(&self) -> Option<LayoutJS<U>>
|
||||
where U: DerivedFrom<T>
|
||||
{
|
||||
debug_assert!(task_state::get().is_layout());
|
||||
debug_assert!(thread_state::get().is_layout());
|
||||
unsafe {
|
||||
if (*self.unsafe_get()).is::<U>() {
|
||||
Some(mem::transmute_copy(self))
|
||||
@ -145,7 +145,7 @@ impl<T: Castable> LayoutJS<T> {
|
||||
impl<T: Reflectable> LayoutJS<T> {
|
||||
/// Get the reflector.
|
||||
pub unsafe fn get_jsobject(&self) -> *mut JSObject {
|
||||
debug_assert!(task_state::get().is_layout());
|
||||
debug_assert!(thread_state::get().is_layout());
|
||||
(**self.ptr).reflector().get_jsobject().get()
|
||||
}
|
||||
}
|
||||
@ -184,7 +184,7 @@ impl <T> Clone for JS<T> {
|
||||
#[inline]
|
||||
#[allow(unrooted_must_root)]
|
||||
fn clone(&self) -> JS<T> {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
JS {
|
||||
ptr: self.ptr.clone(),
|
||||
}
|
||||
@ -194,7 +194,7 @@ impl <T> Clone for JS<T> {
|
||||
impl <T> Clone for LayoutJS<T> {
|
||||
#[inline]
|
||||
fn clone(&self) -> LayoutJS<T> {
|
||||
debug_assert!(task_state::get().is_layout());
|
||||
debug_assert!(thread_state::get().is_layout());
|
||||
LayoutJS {
|
||||
ptr: self.ptr.clone(),
|
||||
}
|
||||
@ -205,7 +205,7 @@ impl LayoutJS<Node> {
|
||||
/// Create a new JS-owned value wrapped from an address known to be a
|
||||
/// `Node` pointer.
|
||||
pub unsafe fn from_trusted_node_address(inner: TrustedNodeAddress) -> LayoutJS<Node> {
|
||||
debug_assert!(task_state::get().is_layout());
|
||||
debug_assert!(thread_state::get().is_layout());
|
||||
let TrustedNodeAddress(addr) = inner;
|
||||
LayoutJS {
|
||||
ptr: NonZero::new(addr as *const Node),
|
||||
@ -240,7 +240,7 @@ pub struct MutHeapJSVal {
|
||||
impl MutHeapJSVal {
|
||||
/// Create a new `MutHeapJSVal`.
|
||||
pub fn new() -> MutHeapJSVal {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
MutHeapJSVal {
|
||||
val: UnsafeCell::new(Heap::default()),
|
||||
}
|
||||
@ -249,7 +249,7 @@ impl MutHeapJSVal {
|
||||
/// Set this `MutHeapJSVal` to the given value, calling write barriers as
|
||||
/// appropriate.
|
||||
pub fn set(&self, val: JSVal) {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
unsafe {
|
||||
let cell = self.val.get();
|
||||
(*cell).set(val);
|
||||
@ -258,7 +258,7 @@ impl MutHeapJSVal {
|
||||
|
||||
/// Get the value in this `MutHeapJSVal`, calling read barriers as appropriate.
|
||||
pub fn get(&self) -> JSVal {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
unsafe { (*self.val.get()).get() }
|
||||
}
|
||||
}
|
||||
@ -278,7 +278,7 @@ pub struct MutHeap<T: HeapGCValue> {
|
||||
impl<T: Reflectable> MutHeap<JS<T>> {
|
||||
/// Create a new `MutHeap`.
|
||||
pub fn new(initial: &T) -> MutHeap<JS<T>> {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
MutHeap {
|
||||
val: UnsafeCell::new(JS::from_ref(initial)),
|
||||
}
|
||||
@ -286,7 +286,7 @@ impl<T: Reflectable> MutHeap<JS<T>> {
|
||||
|
||||
/// Set this `MutHeap` to the given value.
|
||||
pub fn set(&self, val: &T) {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
unsafe {
|
||||
*self.val.get() = JS::from_ref(val);
|
||||
}
|
||||
@ -294,7 +294,7 @@ impl<T: Reflectable> MutHeap<JS<T>> {
|
||||
|
||||
/// Get the value in this `MutHeap`.
|
||||
pub fn get(&self) -> Root<T> {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
unsafe {
|
||||
Root::from_ref(&*ptr::read(self.val.get()))
|
||||
}
|
||||
@ -339,7 +339,7 @@ pub struct MutNullableHeap<T: HeapGCValue> {
|
||||
impl<T: Reflectable> MutNullableHeap<JS<T>> {
|
||||
/// Create a new `MutNullableHeap`.
|
||||
pub fn new(initial: Option<&T>) -> MutNullableHeap<JS<T>> {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
MutNullableHeap {
|
||||
ptr: UnsafeCell::new(initial.map(JS::from_ref)),
|
||||
}
|
||||
@ -350,7 +350,7 @@ impl<T: Reflectable> MutNullableHeap<JS<T>> {
|
||||
pub fn or_init<F>(&self, cb: F) -> Root<T>
|
||||
where F: FnOnce() -> Root<T>
|
||||
{
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
match self.get() {
|
||||
Some(inner) => inner,
|
||||
None => {
|
||||
@ -365,14 +365,14 @@ impl<T: Reflectable> MutNullableHeap<JS<T>> {
|
||||
/// For use by layout, which can't use safe types like Temporary.
|
||||
#[allow(unrooted_must_root)]
|
||||
pub unsafe fn get_inner_as_layout(&self) -> Option<LayoutJS<T>> {
|
||||
debug_assert!(task_state::get().is_layout());
|
||||
debug_assert!(thread_state::get().is_layout());
|
||||
ptr::read(self.ptr.get()).map(|js| js.to_layout())
|
||||
}
|
||||
|
||||
/// Get a rooted value out of this object
|
||||
#[allow(unrooted_must_root)]
|
||||
pub fn get(&self) -> Option<Root<T>> {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
unsafe {
|
||||
ptr::read(self.ptr.get()).map(|o| Root::from_ref(&*o))
|
||||
}
|
||||
@ -380,7 +380,7 @@ impl<T: Reflectable> MutNullableHeap<JS<T>> {
|
||||
|
||||
/// Set this `MutNullableHeap` to the given value.
|
||||
pub fn set(&self, val: Option<&T>) {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
unsafe {
|
||||
*self.ptr.get() = val.map(|p| JS::from_ref(p));
|
||||
}
|
||||
@ -407,7 +407,7 @@ impl<'a, T: Reflectable> PartialEq<Option<&'a T>> for MutNullableHeap<JS<T>> {
|
||||
impl<T: HeapGCValue> Default for MutNullableHeap<T> {
|
||||
#[allow(unrooted_must_root)]
|
||||
fn default() -> MutNullableHeap<T> {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
MutNullableHeap {
|
||||
ptr: UnsafeCell::new(None),
|
||||
}
|
||||
@ -426,7 +426,7 @@ impl<T: Reflectable> LayoutJS<T> {
|
||||
/// the only method that be safely accessed from layout. (The fact that
|
||||
/// this is unsafe is what necessitates the layout wrappers.)
|
||||
pub unsafe fn unsafe_get(&self) -> *const T {
|
||||
debug_assert!(task_state::get().is_layout());
|
||||
debug_assert!(thread_state::get().is_layout());
|
||||
*self.ptr
|
||||
}
|
||||
}
|
||||
@ -479,7 +479,7 @@ impl Clone for RootCollectionPtr {
|
||||
impl RootCollection {
|
||||
/// Create an empty collection of roots
|
||||
pub fn new() -> RootCollection {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
RootCollection {
|
||||
roots: UnsafeCell::new(vec![]),
|
||||
}
|
||||
@ -487,7 +487,7 @@ impl RootCollection {
|
||||
|
||||
/// Start tracking a stack-based root
|
||||
fn root(&self, untracked_reflector: *const Reflector) {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
unsafe {
|
||||
let mut roots = &mut *self.roots.get();
|
||||
roots.push(untracked_reflector);
|
||||
@ -497,7 +497,7 @@ impl RootCollection {
|
||||
|
||||
/// Stop tracking a stack-based root, asserting if the reflector isn't found
|
||||
fn unroot<T: Reflectable>(&self, rooted: &Root<T>) {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
unsafe {
|
||||
let mut roots = &mut *self.roots.get();
|
||||
let old_reflector = &*rooted.reflector();
|
||||
@ -562,7 +562,7 @@ impl<T: Reflectable> Root<T> {
|
||||
/// It cannot not outlive its associated `RootCollection`, and it gives
|
||||
/// out references which cannot outlive this new `Root`.
|
||||
pub fn new(unrooted: NonZero<*const T>) -> Root<T> {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
STACK_ROOTS.with(|ref collection| {
|
||||
let RootCollectionPtr(collection) = collection.get().unwrap();
|
||||
unsafe { (*collection).root(&*(**unrooted).reflector()) }
|
||||
@ -588,7 +588,7 @@ impl<T: Reflectable> Root<T> {
|
||||
impl<T: Reflectable> Deref for Root<T> {
|
||||
type Target = T;
|
||||
fn deref(&self) -> &T {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
unsafe { &**self.ptr.deref() }
|
||||
}
|
||||
}
|
||||
|
@ -3,21 +3,21 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
//! A generic, safe mechanism by which DOM objects can be pinned and transferred
|
||||
//! between tasks (or intra-task for asynchronous events). Akin to Gecko's
|
||||
//! between threads (or intra-thread for asynchronous events). Akin to Gecko's
|
||||
//! nsMainThreadPtrHandle, this uses thread-safe reference counting and ensures
|
||||
//! that the actual SpiderMonkey GC integration occurs on the script task via
|
||||
//! that the actual SpiderMonkey GC integration occurs on the script thread via
|
||||
//! message passing. Ownership of a `Trusted<T>` object means the DOM object of
|
||||
//! type T to which it points remains alive. Any other behaviour is undefined.
|
||||
//! To guarantee the lifetime of a DOM object when performing asynchronous operations,
|
||||
//! obtain a `Trusted<T>` from that object and pass it along with each operation.
|
||||
//! A usable pointer to the original DOM object can be obtained on the script task
|
||||
//! A usable pointer to the original DOM object can be obtained on the script thread
|
||||
//! from a `Trusted<T>` via the `to_temporary` method.
|
||||
//!
|
||||
//! The implementation of Trusted<T> is as follows:
|
||||
//! A hashtable resides in the script task, keyed on the pointer to the Rust DOM object.
|
||||
//! A hashtable resides in the script thread, keyed on the pointer to the Rust DOM object.
|
||||
//! The values in this hashtable are atomic reference counts. When a Trusted<T> object is
|
||||
//! created or cloned, this count is increased. When a Trusted<T> is dropped, the count
|
||||
//! decreases. If the count hits zero, a message is dispatched to the script task to remove
|
||||
//! decreases. If the count hits zero, a message is dispatched to the script thread to remove
|
||||
//! the entry from the hashmap if the count is still zero. The JS reflector for the DOM object
|
||||
//! is rooted when a hashmap entry is first created, and unrooted when the hashmap entry
|
||||
//! is removed.
|
||||
@ -28,7 +28,7 @@ use dom::bindings::reflector::{Reflectable, Reflector};
|
||||
use dom::bindings::trace::trace_reflector;
|
||||
use js::jsapi::JSTracer;
|
||||
use libc;
|
||||
use script_task::{CommonScriptMsg, ScriptChan};
|
||||
use script_thread::{CommonScriptMsg, ScriptChan};
|
||||
use std::cell::RefCell;
|
||||
use std::collections::hash_map::Entry::{Occupied, Vacant};
|
||||
use std::collections::hash_map::HashMap;
|
||||
@ -52,13 +52,13 @@ pub struct TrustedReference(*const libc::c_void);
|
||||
unsafe impl Send for TrustedReference {}
|
||||
|
||||
/// A safe wrapper around a raw pointer to a DOM object that can be
|
||||
/// shared among tasks for use in asynchronous operations. The underlying
|
||||
/// shared among threads for use in asynchronous operations. The underlying
|
||||
/// DOM object is guaranteed to live at least as long as the last outstanding
|
||||
/// `Trusted<T>` instance.
|
||||
#[allow_unrooted_interior]
|
||||
pub struct Trusted<T: Reflectable> {
|
||||
/// A pointer to the Rust DOM object of type T, but void to allow
|
||||
/// sending `Trusted<T>` between tasks, regardless of T's sendability.
|
||||
/// sending `Trusted<T>` between threads, regardless of T's sendability.
|
||||
ptr: *const libc::c_void,
|
||||
refcount: Arc<Mutex<usize>>,
|
||||
script_chan: Box<ScriptChan + Send>,
|
||||
@ -125,7 +125,7 @@ impl<T: Reflectable> Drop for Trusted<T> {
|
||||
assert!(*refcount > 0);
|
||||
*refcount -= 1;
|
||||
if *refcount == 0 {
|
||||
// It's possible this send will fail if the script task
|
||||
// It's possible this send will fail if the script thread
|
||||
// has already exited. There's not much we can do at this
|
||||
// point though.
|
||||
let msg = CommonScriptMsg::RefcountCleanup(TrustedReference(self.ptr));
|
||||
@ -142,7 +142,7 @@ pub struct LiveDOMReferences {
|
||||
}
|
||||
|
||||
impl LiveDOMReferences {
|
||||
/// Set up the task-local data required for storing the outstanding DOM references.
|
||||
/// Set up the thread-local data required for storing the outstanding DOM references.
|
||||
pub fn initialize() {
|
||||
LIVE_REFERENCES.with(|ref r| {
|
||||
*r.borrow_mut() = Some(LiveDOMReferences {
|
||||
|
@ -58,11 +58,11 @@ use msg::constellation_msg::ConstellationChan;
|
||||
use msg::constellation_msg::{PipelineId, SubpageId, WindowSizeData};
|
||||
use net_traits::Metadata;
|
||||
use net_traits::image::base::Image;
|
||||
use net_traits::image_cache_task::{ImageCacheChan, ImageCacheTask};
|
||||
use net_traits::storage_task::StorageType;
|
||||
use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheThread};
|
||||
use net_traits::storage_thread::StorageType;
|
||||
use profile_traits::mem::ProfilerChan as MemProfilerChan;
|
||||
use profile_traits::time::ProfilerChan as TimeProfilerChan;
|
||||
use script_task::ScriptChan;
|
||||
use script_thread::ScriptChan;
|
||||
use script_traits::{LayoutMsg, ScriptMsg, TimerEventId, TimerSource, UntrustedNodeAddress};
|
||||
use selectors::parser::PseudoElement;
|
||||
use selectors::states::*;
|
||||
@ -262,7 +262,7 @@ no_jsmanaged_fields!(Receiver<T>);
|
||||
no_jsmanaged_fields!(Rect<T>);
|
||||
no_jsmanaged_fields!(Size2D<T>);
|
||||
no_jsmanaged_fields!(Arc<T>);
|
||||
no_jsmanaged_fields!(Image, ImageCacheChan, ImageCacheTask);
|
||||
no_jsmanaged_fields!(Image, ImageCacheChan, ImageCacheThread);
|
||||
no_jsmanaged_fields!(Metadata);
|
||||
no_jsmanaged_fields!(Atom, Namespace, QualName);
|
||||
no_jsmanaged_fields!(Trusted<T: Reflectable>);
|
||||
|
@ -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 canvas::canvas_paint_task::RectToi32;
|
||||
use canvas::canvas_paint_thread::RectToi32;
|
||||
use canvas_traits::{Canvas2dMsg, CanvasCommonMsg, CanvasMsg};
|
||||
use canvas_traits::{CompositionOrBlending, LineCapStyle, LineJoinStyle};
|
||||
use canvas_traits::{FillOrStrokeStyle, FillRule, LinearGradientStyle, RadialGradientStyle, RepetitionStyle};
|
||||
@ -36,7 +36,7 @@ use euclid::rect::Rect;
|
||||
use euclid::size::Size2D;
|
||||
use ipc_channel::ipc::{self, IpcSender};
|
||||
use net_traits::image::base::PixelFormat;
|
||||
use net_traits::image_cache_task::ImageResponse;
|
||||
use net_traits::image_cache_thread::ImageResponse;
|
||||
use num::{Float, ToPrimitive};
|
||||
use script_traits::ScriptMsg as ConstellationMsg;
|
||||
use std::cell::Cell;
|
||||
@ -124,7 +124,7 @@ impl CanvasRenderingContext2D {
|
||||
-> CanvasRenderingContext2D {
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
let constellation_chan = global.constellation_chan();
|
||||
constellation_chan.0.send(ConstellationMsg::CreateCanvasPaintTask(size, sender)).unwrap();
|
||||
constellation_chan.0.send(ConstellationMsg::CreateCanvasPaintThread(size, sender)).unwrap();
|
||||
let (ipc_renderer, renderer_id) = receiver.recv().unwrap();
|
||||
CanvasRenderingContext2D {
|
||||
reflector_: Reflector::new(),
|
||||
|
@ -11,7 +11,7 @@ use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::bindings::reflector::reflect_dom_object;
|
||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||
use script_task::ScriptChan;
|
||||
use script_thread::ScriptChan;
|
||||
use string_cache::Atom;
|
||||
use util::str::DOMString;
|
||||
|
||||
|
@ -28,17 +28,17 @@ use js::rust::Runtime;
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use net_traits::{LoadContext, load_whole_resource};
|
||||
use rand::random;
|
||||
use script_task::ScriptTaskEventCategory::WorkerEvent;
|
||||
use script_task::{ScriptTask, ScriptChan, ScriptPort, StackRootTLS, CommonScriptMsg};
|
||||
use script_thread::ScriptThreadEventCategory::WorkerEvent;
|
||||
use script_thread::{ScriptThread, ScriptChan, ScriptPort, StackRootTLS, CommonScriptMsg};
|
||||
use script_traits::{TimerEvent, TimerSource};
|
||||
use std::mem::replace;
|
||||
use std::rc::Rc;
|
||||
use std::sync::mpsc::{Receiver, RecvError, Select, Sender, channel};
|
||||
use url::Url;
|
||||
use util::str::DOMString;
|
||||
use util::task::spawn_named;
|
||||
use util::task_state;
|
||||
use util::task_state::{IN_WORKER, SCRIPT};
|
||||
use util::thread::spawn_named;
|
||||
use util::thread_state;
|
||||
use util::thread_state::{IN_WORKER, SCRIPT};
|
||||
|
||||
/// Messages used to control the worker event loops
|
||||
pub enum WorkerScriptMsg {
|
||||
@ -215,12 +215,15 @@ impl DedicatedWorkerGlobalScope {
|
||||
receiver: Receiver<(TrustedWorkerAddress, WorkerScriptMsg)>) {
|
||||
let serialized_worker_url = worker_url.serialize();
|
||||
spawn_named(format!("WebWorker for {}", serialized_worker_url), move || {
|
||||
task_state::initialize(SCRIPT | IN_WORKER);
|
||||
thread_state::initialize(SCRIPT | IN_WORKER);
|
||||
|
||||
let roots = RootCollection::new();
|
||||
let _stack_roots_tls = StackRootTLS::new(&roots);
|
||||
|
||||
let (url, source) = match load_whole_resource(LoadContext::Script, &init.resource_task, worker_url, None) {
|
||||
let (url, source) = match load_whole_resource(LoadContext::Script,
|
||||
&init.resource_thread,
|
||||
worker_url,
|
||||
None) {
|
||||
Err(_) => {
|
||||
println!("error loading script {}", serialized_worker_url);
|
||||
parent_sender.send(CommonScriptMsg::RunnableMsg(WorkerEvent,
|
||||
@ -232,7 +235,7 @@ impl DedicatedWorkerGlobalScope {
|
||||
}
|
||||
};
|
||||
|
||||
let runtime = Rc::new(ScriptTask::new_rt_and_cx());
|
||||
let runtime = Rc::new(ScriptThread::new_rt_and_cx());
|
||||
|
||||
let (devtools_mpsc_chan, devtools_mpsc_port) = channel();
|
||||
ROUTER.route_ipc_receiver_to_mpsc_sender(from_devtools_receiver, devtools_mpsc_chan);
|
||||
@ -343,7 +346,7 @@ impl DedicatedWorkerGlobalScope {
|
||||
let scope = self.upcast::<WorkerGlobalScope>();
|
||||
let cx = scope.get_cx();
|
||||
let path_seg = format!("url({})", scope.get_url());
|
||||
let reports = ScriptTask::get_reports(cx, path_seg);
|
||||
let reports = ScriptThread::get_reports(cx, path_seg);
|
||||
reports_chan.send(reports);
|
||||
},
|
||||
}
|
||||
|
@ -88,8 +88,8 @@ use net_traits::ControlMsg::{GetCookiesForUrl, SetCookiesForUrl};
|
||||
use net_traits::CookieSource::NonHTTP;
|
||||
use net_traits::{AsyncResponseTarget, PendingAsyncLoad};
|
||||
use num::ToPrimitive;
|
||||
use script_task::CSSError;
|
||||
use script_task::{MainThreadScriptMsg, Runnable};
|
||||
use script_thread::CSSError;
|
||||
use script_thread::{MainThreadScriptMsg, Runnable};
|
||||
use script_traits::{ScriptMsg as ConstellationMsg, ScriptToCompositorMsg};
|
||||
use script_traits::{TouchEventType, TouchId, UntrustedNodeAddress};
|
||||
use std::ascii::AsciiExt;
|
||||
@ -2318,7 +2318,7 @@ impl DocumentMethods for Document {
|
||||
return Err(Error::Security);
|
||||
}
|
||||
let (tx, rx) = ipc::channel().unwrap();
|
||||
let _ = self.window.resource_task().send(GetCookiesForUrl((*url).clone(), tx, NonHTTP));
|
||||
let _ = self.window.resource_thread().send(GetCookiesForUrl((*url).clone(), tx, NonHTTP));
|
||||
let cookies = rx.recv().unwrap();
|
||||
Ok(cookies.map_or(DOMString::new(), DOMString::from))
|
||||
}
|
||||
@ -2331,7 +2331,7 @@ impl DocumentMethods for Document {
|
||||
return Err(Error::Security);
|
||||
}
|
||||
let _ = self.window
|
||||
.resource_task()
|
||||
.resource_thread()
|
||||
.send(SetCookiesForUrl((*url).clone(), String::from(cookie), NonHTTP));
|
||||
Ok(())
|
||||
}
|
||||
|
@ -22,12 +22,12 @@ use encoding::label::encoding_from_whatwg_label;
|
||||
use encoding::types::{DecoderTrap, EncodingRef};
|
||||
use hyper::mime::{Attr, Mime};
|
||||
use rustc_serialize::base64::{CharacterSet, Config, Newline, ToBase64};
|
||||
use script_task::ScriptTaskEventCategory::FileRead;
|
||||
use script_task::{CommonScriptMsg, Runnable, ScriptChan};
|
||||
use script_thread::ScriptThreadEventCategory::FileRead;
|
||||
use script_thread::{CommonScriptMsg, Runnable, ScriptChan};
|
||||
use std::cell::Cell;
|
||||
use string_cache::Atom;
|
||||
use util::str::DOMString;
|
||||
use util::task::spawn_named;
|
||||
use util::thread::spawn_named;
|
||||
|
||||
#[derive(PartialEq, Clone, Copy, JSTraceable, HeapSizeOf)]
|
||||
pub enum FileReaderFunction {
|
||||
@ -360,10 +360,10 @@ impl FileReader {
|
||||
|
||||
let load_data = ReadMetaData::new(String::from(type_), label.map(String::from), function);
|
||||
|
||||
let fr = Trusted::new(self, global.file_reading_task_source());
|
||||
let fr = Trusted::new(self, global.file_reading_thread_source());
|
||||
let gen_id = self.generation_id.get();
|
||||
|
||||
let script_chan = global.file_reading_task_source();
|
||||
let script_chan = global.file_reading_thread_source();
|
||||
|
||||
spawn_named("file reader async operation".to_owned(), move || {
|
||||
perform_annotated_read_operation(gen_id, load_data, blob_contents, fr, script_chan)
|
||||
@ -404,17 +404,17 @@ impl Runnable for FileReaderEvent {
|
||||
}
|
||||
}
|
||||
|
||||
// https://w3c.github.io/FileAPI/#task-read-operation
|
||||
// https://w3c.github.io/FileAPI/#thread-read-operation
|
||||
fn perform_annotated_read_operation(gen_id: GenerationId, data: ReadMetaData, blob_contents: DataSlice,
|
||||
filereader: TrustedFileReader, script_chan: Box<ScriptChan + Send>) {
|
||||
let chan = &script_chan;
|
||||
// Step 4
|
||||
let task = box FileReaderEvent::ProcessRead(filereader.clone(), gen_id);
|
||||
chan.send(CommonScriptMsg::RunnableMsg(FileRead, task)).unwrap();
|
||||
let thread = box FileReaderEvent::ProcessRead(filereader.clone(), gen_id);
|
||||
chan.send(CommonScriptMsg::RunnableMsg(FileRead, thread)).unwrap();
|
||||
|
||||
let task = box FileReaderEvent::ProcessReadData(filereader.clone(), gen_id);
|
||||
chan.send(CommonScriptMsg::RunnableMsg(FileRead, task)).unwrap();
|
||||
let thread = box FileReaderEvent::ProcessReadData(filereader.clone(), gen_id);
|
||||
chan.send(CommonScriptMsg::RunnableMsg(FileRead, thread)).unwrap();
|
||||
|
||||
let task = box FileReaderEvent::ProcessReadEOF(filereader, gen_id, data, blob_contents);
|
||||
chan.send(CommonScriptMsg::RunnableMsg(FileRead, task)).unwrap();
|
||||
let thread = box FileReaderEvent::ProcessReadEOF(filereader, gen_id, data, blob_contents);
|
||||
chan.send(CommonScriptMsg::RunnableMsg(FileRead, thread)).unwrap();
|
||||
}
|
||||
|
@ -332,11 +332,11 @@ impl<'a> From<&'a WebGLContextAttributes> for GLContextAttributes {
|
||||
pub mod utils {
|
||||
use dom::window::Window;
|
||||
use ipc_channel::ipc;
|
||||
use net_traits::image_cache_task::{ImageCacheChan, ImageResponse};
|
||||
use net_traits::image_cache_thread::{ImageCacheChan, ImageResponse};
|
||||
use url::Url;
|
||||
|
||||
pub fn request_image_from_cache(window: &Window, url: Url) -> ImageResponse {
|
||||
let image_cache = window.image_cache_task();
|
||||
let image_cache = window.image_cache_thread();
|
||||
let (response_chan, response_port) = ipc::channel().unwrap();
|
||||
image_cache.request_image(url, ImageCacheChan(response_chan), None);
|
||||
let result = response_port.recv().unwrap();
|
||||
|
@ -32,7 +32,7 @@ use hyper::header::ContentType;
|
||||
use hyper::method::Method;
|
||||
use hyper::mime;
|
||||
use msg::constellation_msg::LoadData;
|
||||
use script_task::{MainThreadScriptMsg, ScriptChan};
|
||||
use script_thread::{MainThreadScriptMsg, ScriptChan};
|
||||
use std::borrow::ToOwned;
|
||||
use std::cell::Cell;
|
||||
use string_cache::Atom;
|
||||
|
@ -22,9 +22,9 @@ use dom::virtualmethods::VirtualMethods;
|
||||
use ipc_channel::ipc;
|
||||
use ipc_channel::router::ROUTER;
|
||||
use net_traits::image::base::Image;
|
||||
use net_traits::image_cache_task::{ImageResponder, ImageResponse};
|
||||
use script_task::ScriptTaskEventCategory::UpdateReplacedElement;
|
||||
use script_task::{CommonScriptMsg, Runnable, ScriptChan};
|
||||
use net_traits::image_cache_thread::{ImageResponder, ImageResponse};
|
||||
use script_thread::ScriptThreadEventCategory::UpdateReplacedElement;
|
||||
use script_thread::{CommonScriptMsg, Runnable, ScriptChan};
|
||||
use std::sync::Arc;
|
||||
use string_cache::Atom;
|
||||
use url::Url;
|
||||
@ -89,7 +89,7 @@ impl HTMLImageElement {
|
||||
fn update_image(&self, value: Option<(DOMString, Url)>) {
|
||||
let document = document_from_node(self);
|
||||
let window = document.window();
|
||||
let image_cache = window.image_cache_task();
|
||||
let image_cache = window.image_cache_thread();
|
||||
match value {
|
||||
None => {
|
||||
*self.url.borrow_mut() = None;
|
||||
@ -101,12 +101,12 @@ impl HTMLImageElement {
|
||||
let img_url = img_url.unwrap();
|
||||
*self.url.borrow_mut() = Some(img_url.clone());
|
||||
|
||||
let trusted_node = Trusted::new(self, window.networking_task_source());
|
||||
let trusted_node = Trusted::new(self, window.networking_thread_source());
|
||||
let (responder_sender, responder_receiver) = ipc::channel().unwrap();
|
||||
let script_chan = window.networking_task_source();
|
||||
let script_chan = window.networking_thread_source();
|
||||
let wrapper = window.get_runnable_wrapper();
|
||||
ROUTER.add_route(responder_receiver.to_opaque(), box move |message| {
|
||||
// Return the image via a message to the script task, which marks the element
|
||||
// Return the image via a message to the script thread, which marks the element
|
||||
// as dirty and triggers a reflow.
|
||||
let image_response = message.to().unwrap();
|
||||
let runnable = ImageResponseHandlerRunnable::new(
|
||||
|
@ -29,8 +29,8 @@ use dom::node::{document_from_node, window_from_node};
|
||||
use dom::nodelist::NodeList;
|
||||
use dom::virtualmethods::VirtualMethods;
|
||||
use msg::constellation_msg::ConstellationChan;
|
||||
use script_task::ScriptTaskEventCategory::InputEvent;
|
||||
use script_task::{CommonScriptMsg, Runnable};
|
||||
use script_thread::ScriptThreadEventCategory::InputEvent;
|
||||
use script_thread::{CommonScriptMsg, Runnable};
|
||||
use script_traits::ScriptMsg as ConstellationMsg;
|
||||
use selectors::states::*;
|
||||
use std::borrow::ToOwned;
|
||||
@ -937,7 +937,7 @@ impl ChangeEventRunnable {
|
||||
pub fn send(node: &Node) {
|
||||
let window = window_from_node(node);
|
||||
let window = window.r();
|
||||
let chan = window.user_interaction_task_source();
|
||||
let chan = window.user_interaction_thread_source();
|
||||
let handler = Trusted::new(node, chan.clone());
|
||||
let dispatcher = ChangeEventRunnable {
|
||||
element: handler,
|
||||
|
@ -197,7 +197,7 @@ impl HTMLLinkElement {
|
||||
|
||||
// TODO: #8085 - Don't load external stylesheets if the node's mq doesn't match.
|
||||
let doc = window.Document();
|
||||
let script_chan = window.networking_task_source();
|
||||
let script_chan = window.networking_thread_source();
|
||||
let elem = Trusted::new(self, script_chan.clone());
|
||||
|
||||
let context = Arc::new(Mutex::new(StylesheetContext {
|
||||
|
@ -34,8 +34,8 @@ use js::jsapi::RootedValue;
|
||||
use js::jsval::UndefinedValue;
|
||||
use net_traits::{AsyncResponseListener, AsyncResponseTarget, Metadata};
|
||||
use network_listener::{NetworkListener, PreInvoke};
|
||||
use script_task::ScriptTaskEventCategory::ScriptEvent;
|
||||
use script_task::{CommonScriptMsg, Runnable, ScriptChan};
|
||||
use script_thread::ScriptThreadEventCategory::ScriptEvent;
|
||||
use script_thread::{CommonScriptMsg, Runnable, ScriptChan};
|
||||
use std::ascii::AsciiExt;
|
||||
use std::cell::Cell;
|
||||
use std::mem;
|
||||
@ -272,7 +272,7 @@ impl HTMLScriptElement {
|
||||
Ok(url) => {
|
||||
// Step 14.5-7.
|
||||
// TODO(#9186): use the fetch infrastructure.
|
||||
let script_chan = window.networking_task_source();
|
||||
let script_chan = window.networking_thread_source();
|
||||
let elem = Trusted::new(self, script_chan.clone());
|
||||
|
||||
let context = Arc::new(Mutex::new(ScriptContext {
|
||||
@ -432,7 +432,7 @@ impl HTMLScriptElement {
|
||||
if external {
|
||||
self.dispatch_load_event();
|
||||
} else {
|
||||
let chan = window.dom_manipulation_task_source();
|
||||
let chan = window.dom_manipulation_thread_source();
|
||||
let handler = Trusted::new(self, chan.clone());
|
||||
let dispatcher = box EventDispatcher {
|
||||
element: handler,
|
||||
@ -445,7 +445,7 @@ impl HTMLScriptElement {
|
||||
pub fn queue_error_event(&self) {
|
||||
let window = window_from_node(self);
|
||||
let window = window.r();
|
||||
let chan = window.dom_manipulation_task_source();
|
||||
let chan = window.dom_manipulation_thread_source();
|
||||
let handler = Trusted::new(self, chan.clone());
|
||||
let dispatcher = box EventDispatcher {
|
||||
element: handler,
|
||||
|
@ -35,7 +35,7 @@
|
||||
//! [`MutNullableJS`](bindings/js/struct.MutNullableJS.html) and
|
||||
//! [`MutHeap`](bindings/js/struct.MutHeap.html) smart pointers and
|
||||
//! [the tracing implementation](bindings/trace/index.html);
|
||||
//! * rooting pointers from across task boundaries or in channels: the
|
||||
//! * rooting pointers from across thread boundaries or in channels: the
|
||||
//! [`Trusted`](bindings/refcounted/struct.Trusted.html) smart pointer;
|
||||
//! * extracting pointers to DOM objects from their reflectors: the
|
||||
//! [`Unrooted`](bindings/js/struct.Unrooted.html) smart pointer.
|
||||
@ -196,7 +196,7 @@
|
||||
//! Layout code can access the DOM through the
|
||||
//! [`LayoutJS`](bindings/js/struct.LayoutJS.html) smart pointer. This does not
|
||||
//! keep the DOM object alive; we ensure that no DOM code (Garbage Collection
|
||||
//! in particular) runs while the layout task is accessing the DOM.
|
||||
//! in particular) runs while the layout thread is accessing the DOM.
|
||||
//!
|
||||
//! Methods accessible to layout are implemented on `LayoutJS<Foo>` using
|
||||
//! `LayoutFooHelpers` traits.
|
||||
|
@ -64,7 +64,7 @@ use std::iter::{self, FilterMap, Peekable};
|
||||
use std::mem;
|
||||
use string_cache::{Atom, Namespace, QualName};
|
||||
use util::str::DOMString;
|
||||
use util::task_state;
|
||||
use util::thread_state;
|
||||
use uuid::Uuid;
|
||||
|
||||
//
|
||||
@ -113,9 +113,9 @@ pub struct Node {
|
||||
/// are this node.
|
||||
ranges: WeakRangeVec,
|
||||
|
||||
/// Style+Layout information. Only the layout task may touch this data.
|
||||
/// Style+Layout information. Only the layout thread may touch this data.
|
||||
///
|
||||
/// Must be sent back to the layout task to be destroyed when this
|
||||
/// Must be sent back to the layout thread to be destroyed when this
|
||||
/// node is finalized.
|
||||
style_and_layout_data: Cell<Option<OpaqueStyleAndLayoutData>>,
|
||||
|
||||
@ -183,9 +183,9 @@ no_jsmanaged_fields!(OpaqueStyleAndLayoutData);
|
||||
|
||||
|
||||
impl OpaqueStyleAndLayoutData {
|
||||
/// Sends the style and layout data, if any, back to the layout task to be destroyed.
|
||||
/// Sends the style and layout data, if any, back to the layout thread to be destroyed.
|
||||
pub fn dispose(self, node: &Node) {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
let win = window_from_node(node);
|
||||
let LayoutChan(chan) = win.layout_chan();
|
||||
node.style_and_layout_data.set(None);
|
||||
|
@ -29,7 +29,7 @@ use msg::constellation_msg::{PipelineId, SubpageId};
|
||||
use net_traits::{AsyncResponseListener, Metadata};
|
||||
use network_listener::PreInvoke;
|
||||
use parse::Parser;
|
||||
use script_task::{ScriptChan, ScriptTask};
|
||||
use script_thread::{ScriptChan, ScriptThread};
|
||||
use std::cell::Cell;
|
||||
use std::cell::UnsafeCell;
|
||||
use std::default::Default;
|
||||
@ -241,7 +241,7 @@ impl AsyncResponseListener for ParserContext {
|
||||
fn headers_available(&mut self, metadata: Metadata) {
|
||||
let content_type = metadata.content_type.clone();
|
||||
|
||||
let parser = ScriptTask::page_fetch_complete(self.id.clone(), self.subpage.clone(),
|
||||
let parser = ScriptThread::page_fetch_complete(self.id.clone(), self.subpage.clone(),
|
||||
metadata);
|
||||
let parser = match parser {
|
||||
Some(parser) => parser,
|
||||
@ -366,7 +366,7 @@ impl<'a> Parser for &'a ServoHTMLParser {
|
||||
self.document.set_current_parser(None);
|
||||
|
||||
if let Some(pipeline) = self.pipeline {
|
||||
ScriptTask::parsing_complete(pipeline);
|
||||
ScriptThread::parsing_complete(pipeline);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ use dom::window::Window;
|
||||
use js::jsapi::JSTracer;
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use parse::Parser;
|
||||
use script_task::ScriptTask;
|
||||
use script_thread::ScriptThread;
|
||||
use std::cell::Cell;
|
||||
use url::Url;
|
||||
use xml5ever::tokenizer;
|
||||
@ -68,7 +68,7 @@ impl<'a> Parser for &'a ServoXMLParser {
|
||||
self.document.set_current_parser(None);
|
||||
|
||||
if let Some(pipeline) = self.pipeline {
|
||||
ScriptTask::parsing_complete(pipeline);
|
||||
ScriptThread::parsing_complete(pipeline);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,9 +14,9 @@ use dom::event::{Event, EventBubbles, EventCancelable};
|
||||
use dom::storageevent::StorageEvent;
|
||||
use dom::urlhelper::UrlHelper;
|
||||
use ipc_channel::ipc;
|
||||
use net_traits::storage_task::{StorageTask, StorageTaskMsg, StorageType};
|
||||
use net_traits::storage_thread::{StorageThread, StorageThreadMsg, StorageType};
|
||||
use page::IterablePage;
|
||||
use script_task::{MainThreadRunnable, MainThreadScriptMsg, ScriptTask};
|
||||
use script_thread::{MainThreadRunnable, MainThreadScriptMsg, ScriptThread};
|
||||
use std::sync::mpsc::channel;
|
||||
use url::Url;
|
||||
use util::str::DOMString;
|
||||
@ -47,10 +47,10 @@ impl Storage {
|
||||
global_ref.get_url()
|
||||
}
|
||||
|
||||
fn get_storage_task(&self) -> StorageTask {
|
||||
fn get_storage_thread(&self) -> StorageThread {
|
||||
let global_root = self.global.root();
|
||||
let global_ref = global_root.r();
|
||||
global_ref.as_window().storage_task()
|
||||
global_ref.as_window().storage_thread()
|
||||
}
|
||||
|
||||
}
|
||||
@ -60,7 +60,7 @@ impl StorageMethods for Storage {
|
||||
fn Length(&self) -> u32 {
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
|
||||
self.get_storage_task().send(StorageTaskMsg::Length(sender, self.get_url(), self.storage_type)).unwrap();
|
||||
self.get_storage_thread().send(StorageThreadMsg::Length(sender, self.get_url(), self.storage_type)).unwrap();
|
||||
receiver.recv().unwrap() as u32
|
||||
}
|
||||
|
||||
@ -68,7 +68,9 @@ impl StorageMethods for Storage {
|
||||
fn Key(&self, index: u32) -> Option<DOMString> {
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
|
||||
self.get_storage_task().send(StorageTaskMsg::Key(sender, self.get_url(), self.storage_type, index)).unwrap();
|
||||
self.get_storage_thread()
|
||||
.send(StorageThreadMsg::Key(sender, self.get_url(), self.storage_type, index))
|
||||
.unwrap();
|
||||
receiver.recv().unwrap().map(DOMString::from)
|
||||
}
|
||||
|
||||
@ -77,8 +79,8 @@ impl StorageMethods for Storage {
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
let name = String::from(name);
|
||||
|
||||
let msg = StorageTaskMsg::GetItem(sender, self.get_url(), self.storage_type, name);
|
||||
self.get_storage_task().send(msg).unwrap();
|
||||
let msg = StorageThreadMsg::GetItem(sender, self.get_url(), self.storage_type, name);
|
||||
self.get_storage_thread().send(msg).unwrap();
|
||||
receiver.recv().unwrap().map(DOMString::from)
|
||||
}
|
||||
|
||||
@ -88,8 +90,8 @@ impl StorageMethods for Storage {
|
||||
let name = String::from(name);
|
||||
let value = String::from(value);
|
||||
|
||||
let msg = StorageTaskMsg::SetItem(sender, self.get_url(), self.storage_type, name.clone(), value.clone());
|
||||
self.get_storage_task().send(msg).unwrap();
|
||||
let msg = StorageThreadMsg::SetItem(sender, self.get_url(), self.storage_type, name.clone(), value.clone());
|
||||
self.get_storage_thread().send(msg).unwrap();
|
||||
match receiver.recv().unwrap() {
|
||||
Err(_) => Err(Error::QuotaExceeded),
|
||||
Ok((changed, old_value)) => {
|
||||
@ -106,8 +108,8 @@ impl StorageMethods for Storage {
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
let name = String::from(name);
|
||||
|
||||
let msg = StorageTaskMsg::RemoveItem(sender, self.get_url(), self.storage_type, name.clone());
|
||||
self.get_storage_task().send(msg).unwrap();
|
||||
let msg = StorageThreadMsg::RemoveItem(sender, self.get_url(), self.storage_type, name.clone());
|
||||
self.get_storage_thread().send(msg).unwrap();
|
||||
if let Some(old_value) = receiver.recv().unwrap() {
|
||||
self.broadcast_change_notification(Some(name), Some(old_value), None);
|
||||
}
|
||||
@ -117,7 +119,7 @@ impl StorageMethods for Storage {
|
||||
fn Clear(&self) {
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
|
||||
self.get_storage_task().send(StorageTaskMsg::Clear(sender, self.get_url(), self.storage_type)).unwrap();
|
||||
self.get_storage_thread().send(StorageThreadMsg::Clear(sender, self.get_url(), self.storage_type)).unwrap();
|
||||
if receiver.recv().unwrap() {
|
||||
self.broadcast_change_notification(None, None, None);
|
||||
}
|
||||
@ -127,7 +129,7 @@ impl StorageMethods for Storage {
|
||||
fn SupportedPropertyNames(&self) -> Vec<DOMString> {
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
|
||||
self.get_storage_task().send(StorageTaskMsg::Keys(sender, self.get_url(), self.storage_type)).unwrap();
|
||||
self.get_storage_thread().send(StorageThreadMsg::Keys(sender, self.get_url(), self.storage_type)).unwrap();
|
||||
receiver.recv().unwrap().iter().cloned().map(DOMString::from).collect() // FIXME: inefficient?
|
||||
}
|
||||
|
||||
@ -155,7 +157,7 @@ impl Storage {
|
||||
let global_root = self.global.root();
|
||||
let global_ref = global_root.r();
|
||||
let main_script_chan = global_ref.as_window().main_thread_script_chan();
|
||||
let script_chan = global_ref.dom_manipulation_task_source();
|
||||
let script_chan = global_ref.dom_manipulation_thread_source();
|
||||
let trusted_storage = Trusted::new(self, script_chan);
|
||||
main_script_chan.send(MainThreadScriptMsg::MainThreadRunnableMsg(
|
||||
box StorageEventRunnable::new(trusted_storage, key, old_value, new_value))).unwrap();
|
||||
@ -177,7 +179,7 @@ impl StorageEventRunnable {
|
||||
}
|
||||
|
||||
impl MainThreadRunnable for StorageEventRunnable {
|
||||
fn handler(self: Box<StorageEventRunnable>, script_task: &ScriptTask) {
|
||||
fn handler(self: Box<StorageEventRunnable>, script_thread: &ScriptThread) {
|
||||
let this = *self;
|
||||
let storage_root = this.element.root();
|
||||
let storage = storage_root.r();
|
||||
@ -195,7 +197,7 @@ impl MainThreadRunnable for StorageEventRunnable {
|
||||
Some(storage)
|
||||
);
|
||||
|
||||
let root_page = script_task.root_page();
|
||||
let root_page = script_thread.root_page();
|
||||
for it_page in root_page.iter() {
|
||||
let it_window_root = it_page.window();
|
||||
let it_window = it_window_root.r();
|
||||
|
@ -31,7 +31,7 @@ use ipc_channel::ipc::{self, IpcSender};
|
||||
use js::jsapi::{JSContext, JSObject, RootedValue};
|
||||
use js::jsval::{BooleanValue, DoubleValue, Int32Value, JSVal, NullValue, UndefinedValue};
|
||||
use net_traits::image::base::PixelFormat;
|
||||
use net_traits::image_cache_task::ImageResponse;
|
||||
use net_traits::image_cache_thread::ImageResponse;
|
||||
use offscreen_gl_context::GLContextAttributes;
|
||||
use script_traits::ScriptMsg as ConstellationMsg;
|
||||
use std::cell::Cell;
|
||||
@ -91,7 +91,7 @@ impl WebGLRenderingContext {
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
let constellation_chan = global.constellation_chan();
|
||||
constellation_chan.0
|
||||
.send(ConstellationMsg::CreateWebGLPaintTask(size, attrs, sender))
|
||||
.send(ConstellationMsg::CreateWebGLPaintThread(size, attrs, sender))
|
||||
.unwrap();
|
||||
let result = receiver.recv().unwrap();
|
||||
|
||||
@ -614,7 +614,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
||||
}
|
||||
|
||||
// TODO(ecoal95): Probably in the future we should keep track of the
|
||||
// generated objects, either here or in the webgl task
|
||||
// generated objects, either here or in the webgl thread
|
||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.5
|
||||
fn CreateBuffer(&self) -> Option<Root<WebGLBuffer>> {
|
||||
WebGLBuffer::maybe_new(self.global.root().r(), self.ipc_renderer.clone())
|
||||
|
@ -100,9 +100,9 @@ impl WebGLShader {
|
||||
&BuiltInResources::default()).unwrap();
|
||||
match validator.compile_and_translate(&[source.as_bytes()]) {
|
||||
Ok(translated_source) => {
|
||||
// NOTE: At this point we should be pretty sure that the compilation in the paint task
|
||||
// NOTE: At this point we should be pretty sure that the compilation in the paint thread
|
||||
// will succeed.
|
||||
// It could be interesting to retrieve the info log from the paint task though
|
||||
// It could be interesting to retrieve the info log from the paint thread though
|
||||
let msg = CanvasWebGLMsg::CompileShader(self.id, translated_source);
|
||||
self.renderer.send(CanvasMsg::WebGL(msg)).unwrap();
|
||||
self.compilation_status.set(ShaderCompilationStatus::Succeeded);
|
||||
|
@ -32,8 +32,8 @@ use net_traits::hosts::replace_hosts;
|
||||
use net_traits::unwrap_websocket_protocol;
|
||||
use net_traits::{WebSocketCommunicate, WebSocketConnectData, WebSocketDomAction, WebSocketNetworkEvent};
|
||||
use ref_slice::ref_slice;
|
||||
use script_task::ScriptTaskEventCategory::WebSocketEvent;
|
||||
use script_task::{CommonScriptMsg, Runnable};
|
||||
use script_thread::ScriptThreadEventCategory::WebSocketEvent;
|
||||
use script_thread::{CommonScriptMsg, Runnable};
|
||||
use std::borrow::ToOwned;
|
||||
use std::cell::Cell;
|
||||
use std::ptr;
|
||||
@ -139,7 +139,7 @@ pub struct WebSocket {
|
||||
global: GlobalField,
|
||||
ready_state: Cell<WebSocketRequestState>,
|
||||
buffered_amount: Cell<u64>,
|
||||
clearing_buffer: Cell<bool>, //Flag to tell if there is a running task to clear buffered_amount
|
||||
clearing_buffer: Cell<bool>, //Flag to tell if there is a running thread to clear buffered_amount
|
||||
#[ignore_heap_size_of = "Defined in std"]
|
||||
sender: DOMRefCell<Option<IpcSender<WebSocketDomAction>>>,
|
||||
failed: Cell<bool>, //Flag to tell if websocket was closed due to failure
|
||||
@ -183,7 +183,7 @@ impl WebSocket {
|
||||
-> Fallible<Root<WebSocket>> {
|
||||
// Step 1.
|
||||
let resource_url = try!(Url::parse(&url).map_err(|_| Error::Syntax));
|
||||
// Although we do this replace and parse operation again in the resource task,
|
||||
// Although we do this replace and parse operation again in the resource thread,
|
||||
// we try here to be able to immediately throw a syntax error on failure.
|
||||
let _ = try!(parse_url(&replace_hosts(&resource_url)).map_err(|_| Error::Syntax));
|
||||
// Step 2: Disallow https -> ws connections.
|
||||
@ -223,7 +223,7 @@ impl WebSocket {
|
||||
|
||||
// Step 7.
|
||||
let ws = WebSocket::new(global, resource_url.clone());
|
||||
let address = Trusted::new(ws.r(), global.networking_task_source());
|
||||
let address = Trusted::new(ws.r(), global.networking_thread_source());
|
||||
|
||||
let origin = global.get_url().serialize();
|
||||
let protocols: Vec<String> = protocols.iter().map(|x| String::from(x.clone())).collect();
|
||||
@ -234,7 +234,7 @@ impl WebSocket {
|
||||
protocols: protocols,
|
||||
};
|
||||
|
||||
// Create the interface for communication with the resource task
|
||||
// Create the interface for communication with the resource thread
|
||||
let (dom_action_sender, resource_action_receiver):
|
||||
(IpcSender<WebSocketDomAction>,
|
||||
IpcReceiver<WebSocketDomAction>) = ipc::channel().unwrap();
|
||||
@ -247,36 +247,36 @@ impl WebSocket {
|
||||
action_receiver: resource_action_receiver,
|
||||
};
|
||||
|
||||
let resource_task = global.resource_task();
|
||||
let _ = resource_task.send(WebsocketConnect(connect, connect_data));
|
||||
let resource_thread = global.resource_thread();
|
||||
let _ = resource_thread.send(WebsocketConnect(connect, connect_data));
|
||||
|
||||
*ws.sender.borrow_mut() = Some(dom_action_sender);
|
||||
|
||||
let moved_address = address.clone();
|
||||
let sender = global.networking_task_source();
|
||||
let sender = global.networking_thread_source();
|
||||
thread::spawn(move || {
|
||||
while let Ok(event) = dom_event_receiver.recv() {
|
||||
match event {
|
||||
WebSocketNetworkEvent::ConnectionEstablished(headers, protocols) => {
|
||||
let open_task = box ConnectionEstablishedTask {
|
||||
let open_thread = box ConnectionEstablishedTask {
|
||||
addr: moved_address.clone(),
|
||||
headers: headers,
|
||||
protocols: protocols,
|
||||
};
|
||||
sender.send(CommonScriptMsg::RunnableMsg(WebSocketEvent, open_task)).unwrap();
|
||||
sender.send(CommonScriptMsg::RunnableMsg(WebSocketEvent, open_thread)).unwrap();
|
||||
},
|
||||
WebSocketNetworkEvent::MessageReceived(message) => {
|
||||
let message_task = box MessageReceivedTask {
|
||||
let message_thread = box MessageReceivedTask {
|
||||
address: moved_address.clone(),
|
||||
message: message,
|
||||
};
|
||||
sender.send(CommonScriptMsg::RunnableMsg(WebSocketEvent, message_task)).unwrap();
|
||||
sender.send(CommonScriptMsg::RunnableMsg(WebSocketEvent, message_thread)).unwrap();
|
||||
},
|
||||
WebSocketNetworkEvent::Close => {
|
||||
let task = box CloseTask {
|
||||
let thread = box CloseTask {
|
||||
addr: moved_address.clone(),
|
||||
};
|
||||
sender.send(CommonScriptMsg::RunnableMsg(WebSocketEvent, task)).unwrap();
|
||||
sender.send(CommonScriptMsg::RunnableMsg(WebSocketEvent, thread)).unwrap();
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -296,7 +296,7 @@ impl WebSocket {
|
||||
};
|
||||
|
||||
let global = self.global.root();
|
||||
let chan = global.r().networking_task_source();
|
||||
let chan = global.r().networking_thread_source();
|
||||
let address = Trusted::new(self, chan.clone());
|
||||
|
||||
match data_byte_len.checked_add(self.buffered_amount.get()) {
|
||||
@ -469,11 +469,11 @@ impl Runnable for ConnectionEstablishedTask {
|
||||
if !self.protocols.is_empty() && self.headers.get::<WebSocketProtocol>().is_none() {
|
||||
ws.failed.set(true);
|
||||
ws.ready_state.set(WebSocketRequestState::Closing);
|
||||
let task = box CloseTask {
|
||||
let thread = box CloseTask {
|
||||
addr: self.addr,
|
||||
};
|
||||
let sender = global.r().networking_task_source();
|
||||
sender.send(CommonScriptMsg::RunnableMsg(WebSocketEvent, task)).unwrap();
|
||||
let sender = global.r().networking_thread_source();
|
||||
sender.send(CommonScriptMsg::RunnableMsg(WebSocketEvent, thread)).unwrap();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -47,17 +47,17 @@ use msg::ParseErrorReporter;
|
||||
use msg::constellation_msg::{ConstellationChan, DocumentState, LoadData};
|
||||
use msg::constellation_msg::{MozBrowserEvent, PipelineId, SubpageId, WindowSizeData};
|
||||
use msg::webdriver_msg::{WebDriverJSError, WebDriverJSResult};
|
||||
use net_traits::ResourceTask;
|
||||
use net_traits::image_cache_task::{ImageCacheChan, ImageCacheTask};
|
||||
use net_traits::storage_task::{StorageTask, StorageType};
|
||||
use net_traits::ResourceThread;
|
||||
use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheThread};
|
||||
use net_traits::storage_thread::{StorageThread, StorageType};
|
||||
use num::traits::ToPrimitive;
|
||||
use page::Page;
|
||||
use profile_traits::mem;
|
||||
use reporter::CSSErrorReporter;
|
||||
use rustc_serialize::base64::{FromBase64, STANDARD, ToBase64};
|
||||
use script_task::{DOMManipulationTaskSource, UserInteractionTaskSource, NetworkingTaskSource};
|
||||
use script_task::{HistoryTraversalTaskSource, FileReadingTaskSource, SendableMainThreadScriptChan};
|
||||
use script_task::{ScriptChan, ScriptPort, MainThreadScriptChan, MainThreadScriptMsg, RunnableWrapper};
|
||||
use script_thread::{DOMManipulationThreadSource, UserInteractionThreadSource, NetworkingThreadSource};
|
||||
use script_thread::{HistoryTraversalThreadSource, FileReadingThreadSource, SendableMainThreadScriptChan};
|
||||
use script_thread::{ScriptChan, ScriptPort, MainThreadScriptChan, MainThreadScriptMsg, RunnableWrapper};
|
||||
use script_traits::ScriptMsg as ConstellationMsg;
|
||||
use script_traits::{MsDuration, ScriptToCompositorMsg, TimerEvent, TimerEventId, TimerEventRequest, TimerSource};
|
||||
use selectors::parser::PseudoElement;
|
||||
@ -116,21 +116,21 @@ pub struct Window {
|
||||
eventtarget: EventTarget,
|
||||
#[ignore_heap_size_of = "trait objects are hard"]
|
||||
script_chan: MainThreadScriptChan,
|
||||
#[ignore_heap_size_of = "task sources are hard"]
|
||||
dom_manipulation_task_source: DOMManipulationTaskSource,
|
||||
#[ignore_heap_size_of = "task sources are hard"]
|
||||
user_interaction_task_source: UserInteractionTaskSource,
|
||||
#[ignore_heap_size_of = "task sources are hard"]
|
||||
networking_task_source: NetworkingTaskSource,
|
||||
#[ignore_heap_size_of = "task sources are hard"]
|
||||
history_traversal_task_source: HistoryTraversalTaskSource,
|
||||
#[ignore_heap_size_of = "task sources are hard"]
|
||||
file_reading_task_source: FileReadingTaskSource,
|
||||
#[ignore_heap_size_of = "thread sources are hard"]
|
||||
dom_manipulation_thread_source: DOMManipulationThreadSource,
|
||||
#[ignore_heap_size_of = "thread sources are hard"]
|
||||
user_interaction_thread_source: UserInteractionThreadSource,
|
||||
#[ignore_heap_size_of = "thread sources are hard"]
|
||||
networking_thread_source: NetworkingThreadSource,
|
||||
#[ignore_heap_size_of = "thread sources are hard"]
|
||||
history_traversal_thread_source: HistoryTraversalThreadSource,
|
||||
#[ignore_heap_size_of = "thread sources are hard"]
|
||||
file_reading_thread_source: FileReadingThreadSource,
|
||||
console: MutNullableHeap<JS<Console>>,
|
||||
crypto: MutNullableHeap<JS<Crypto>>,
|
||||
navigator: MutNullableHeap<JS<Navigator>>,
|
||||
#[ignore_heap_size_of = "channels are hard"]
|
||||
image_cache_task: ImageCacheTask,
|
||||
image_cache_thread: ImageCacheThread,
|
||||
#[ignore_heap_size_of = "channels are hard"]
|
||||
image_cache_chan: ImageCacheChan,
|
||||
#[ignore_heap_size_of = "TODO(#6911) newtypes containing unmeasurable types are hard"]
|
||||
@ -185,7 +185,7 @@ pub struct Window {
|
||||
#[ignore_heap_size_of = "Rc<T> is hard"]
|
||||
js_runtime: DOMRefCell<Option<Rc<Runtime>>>,
|
||||
|
||||
/// A handle for communicating messages to the layout task.
|
||||
/// A handle for communicating messages to the layout thread.
|
||||
#[ignore_heap_size_of = "channels are hard"]
|
||||
layout_chan: LayoutChan,
|
||||
|
||||
@ -196,15 +196,15 @@ pub struct Window {
|
||||
/// The current size of the window, in pixels.
|
||||
window_size: Cell<Option<WindowSizeData>>,
|
||||
|
||||
/// Associated resource task for use by DOM objects like XMLHttpRequest
|
||||
/// Associated resource thread for use by DOM objects like XMLHttpRequest
|
||||
#[ignore_heap_size_of = "channels are hard"]
|
||||
resource_task: Arc<ResourceTask>,
|
||||
resource_thread: Arc<ResourceThread>,
|
||||
|
||||
/// A handle for communicating messages to the storage task.
|
||||
/// A handle for communicating messages to the storage thread.
|
||||
#[ignore_heap_size_of = "channels are hard"]
|
||||
storage_task: StorageTask,
|
||||
storage_thread: StorageThread,
|
||||
|
||||
/// A handle for communicating messages to the constellation task.
|
||||
/// A handle for communicating messages to the constellation thread.
|
||||
#[ignore_heap_size_of = "channels are hard"]
|
||||
constellation_chan: ConstellationChan<ConstellationMsg>,
|
||||
|
||||
@ -249,24 +249,24 @@ impl Window {
|
||||
self.js_runtime.borrow().as_ref().unwrap().cx()
|
||||
}
|
||||
|
||||
pub fn dom_manipulation_task_source(&self) -> Box<ScriptChan + Send> {
|
||||
self.dom_manipulation_task_source.clone()
|
||||
pub fn dom_manipulation_thread_source(&self) -> Box<ScriptChan + Send> {
|
||||
self.dom_manipulation_thread_source.clone()
|
||||
}
|
||||
|
||||
pub fn user_interaction_task_source(&self) -> Box<ScriptChan + Send> {
|
||||
self.user_interaction_task_source.clone()
|
||||
pub fn user_interaction_thread_source(&self) -> Box<ScriptChan + Send> {
|
||||
self.user_interaction_thread_source.clone()
|
||||
}
|
||||
|
||||
pub fn networking_task_source(&self) -> Box<ScriptChan + Send> {
|
||||
self.networking_task_source.clone()
|
||||
pub fn networking_thread_source(&self) -> Box<ScriptChan + Send> {
|
||||
self.networking_thread_source.clone()
|
||||
}
|
||||
|
||||
pub fn history_traversal_task_source(&self) -> Box<ScriptChan + Send> {
|
||||
self.history_traversal_task_source.clone()
|
||||
pub fn history_traversal_thread_source(&self) -> Box<ScriptChan + Send> {
|
||||
self.history_traversal_thread_source.clone()
|
||||
}
|
||||
|
||||
pub fn file_reading_task_source(&self) -> Box<ScriptChan + Send> {
|
||||
self.file_reading_task_source.clone()
|
||||
pub fn file_reading_thread_source(&self) -> Box<ScriptChan + Send> {
|
||||
self.file_reading_thread_source.clone()
|
||||
}
|
||||
|
||||
pub fn main_thread_script_chan(&self) -> &Sender<MainThreadScriptMsg> {
|
||||
@ -302,8 +302,8 @@ impl Window {
|
||||
(box SendableMainThreadScriptChan(tx), box rx)
|
||||
}
|
||||
|
||||
pub fn image_cache_task(&self) -> &ImageCacheTask {
|
||||
&self.image_cache_task
|
||||
pub fn image_cache_thread(&self) -> &ImageCacheThread {
|
||||
&self.image_cache_thread
|
||||
}
|
||||
|
||||
pub fn compositor(&self) -> &IpcSender<ScriptToCompositorMsg> {
|
||||
@ -318,8 +318,8 @@ impl Window {
|
||||
&*self.page
|
||||
}
|
||||
|
||||
pub fn storage_task(&self) -> StorageTask {
|
||||
self.storage_task.clone()
|
||||
pub fn storage_thread(&self) -> StorageThread {
|
||||
self.storage_thread.clone()
|
||||
}
|
||||
|
||||
pub fn css_error_reporter(&self) -> Box<ParseErrorReporter + Send> {
|
||||
@ -837,10 +837,10 @@ impl Window {
|
||||
// (e.g. DOM objects removed from the tree that haven't
|
||||
// been collected yet). Forcing a GC here means that
|
||||
// those DOM objects will be able to call dispose()
|
||||
// to free their layout data before the layout task
|
||||
// to free their layout data before the layout thread
|
||||
// exits. Without this, those remaining objects try to
|
||||
// send a message to free their layout data to the
|
||||
// layout task when the script task is dropped,
|
||||
// layout thread when the script thread is dropped,
|
||||
// which causes a panic!
|
||||
self.Gc();
|
||||
|
||||
@ -981,7 +981,7 @@ impl Window {
|
||||
}
|
||||
Ok(_) => {}
|
||||
Err(Disconnected) => {
|
||||
panic!("Layout task failed while script was waiting for a result.");
|
||||
panic!("Layout thread failed while script was waiting for a result.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1018,7 +1018,7 @@ impl Window {
|
||||
// 2) The html element doesn't contain the 'reftest-wait' class
|
||||
// 3) The load event has fired.
|
||||
// When all these conditions are met, notify the constellation
|
||||
// that this pipeline is ready to write the image (from the script task
|
||||
// that this pipeline is ready to write the image (from the script thread
|
||||
// perspective at least).
|
||||
if opts::get().output_file.is_some() && for_display {
|
||||
let document = self.Document();
|
||||
@ -1126,8 +1126,8 @@ impl Window {
|
||||
(*self.Document().url()).clone()
|
||||
}
|
||||
|
||||
pub fn resource_task(&self) -> ResourceTask {
|
||||
(*self.resource_task).clone()
|
||||
pub fn resource_thread(&self) -> ResourceThread {
|
||||
(*self.resource_thread).clone()
|
||||
}
|
||||
|
||||
pub fn mem_profiler_chan(&self) -> mem::ProfilerChan {
|
||||
@ -1288,16 +1288,16 @@ impl Window {
|
||||
pub fn new(runtime: Rc<Runtime>,
|
||||
page: Rc<Page>,
|
||||
script_chan: MainThreadScriptChan,
|
||||
dom_task_source: DOMManipulationTaskSource,
|
||||
user_task_source: UserInteractionTaskSource,
|
||||
network_task_source: NetworkingTaskSource,
|
||||
history_task_source: HistoryTraversalTaskSource,
|
||||
file_task_source: FileReadingTaskSource,
|
||||
dom_thread_source: DOMManipulationThreadSource,
|
||||
user_thread_source: UserInteractionThreadSource,
|
||||
network_thread_source: NetworkingThreadSource,
|
||||
history_thread_source: HistoryTraversalThreadSource,
|
||||
file_thread_source: FileReadingThreadSource,
|
||||
image_cache_chan: ImageCacheChan,
|
||||
compositor: IpcSender<ScriptToCompositorMsg>,
|
||||
image_cache_task: ImageCacheTask,
|
||||
resource_task: Arc<ResourceTask>,
|
||||
storage_task: StorageTask,
|
||||
image_cache_thread: ImageCacheThread,
|
||||
resource_thread: Arc<ResourceThread>,
|
||||
storage_thread: StorageThread,
|
||||
mem_profiler_chan: mem::ProfilerChan,
|
||||
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
|
||||
constellation_chan: ConstellationChan<ConstellationMsg>,
|
||||
@ -1318,18 +1318,18 @@ impl Window {
|
||||
let win = box Window {
|
||||
eventtarget: EventTarget::new_inherited(),
|
||||
script_chan: script_chan,
|
||||
dom_manipulation_task_source: dom_task_source,
|
||||
user_interaction_task_source: user_task_source,
|
||||
networking_task_source: network_task_source,
|
||||
history_traversal_task_source: history_task_source,
|
||||
file_reading_task_source: file_task_source,
|
||||
dom_manipulation_thread_source: dom_thread_source,
|
||||
user_interaction_thread_source: user_thread_source,
|
||||
networking_thread_source: network_thread_source,
|
||||
history_traversal_thread_source: history_thread_source,
|
||||
file_reading_thread_source: file_thread_source,
|
||||
image_cache_chan: image_cache_chan,
|
||||
console: Default::default(),
|
||||
crypto: Default::default(),
|
||||
compositor: compositor,
|
||||
page: page,
|
||||
navigator: Default::default(),
|
||||
image_cache_task: image_cache_task,
|
||||
image_cache_thread: image_cache_thread,
|
||||
mem_profiler_chan: mem_profiler_chan,
|
||||
devtools_chan: devtools_chan,
|
||||
browsing_context: Default::default(),
|
||||
@ -1346,8 +1346,8 @@ impl Window {
|
||||
parent_info: parent_info,
|
||||
dom_static: GlobalStaticData::new(),
|
||||
js_runtime: DOMRefCell::new(Some(runtime.clone())),
|
||||
resource_task: resource_task,
|
||||
storage_task: storage_task,
|
||||
resource_thread: resource_thread,
|
||||
storage_thread: storage_thread,
|
||||
constellation_chan: constellation_chan,
|
||||
page_clip_rect: Cell::new(MAX_RECT),
|
||||
fragment_name: DOMRefCell::new(None),
|
||||
|
@ -24,7 +24,7 @@ use ipc_channel::ipc;
|
||||
use js::jsapi::{HandleValue, JSContext, RootedValue};
|
||||
use js::jsapi::{JSAutoCompartment, JSAutoRequest};
|
||||
use js::jsval::UndefinedValue;
|
||||
use script_task::{Runnable, ScriptChan};
|
||||
use script_thread::{Runnable, ScriptChan};
|
||||
use std::sync::mpsc::{Sender, channel};
|
||||
use util::str::DOMString;
|
||||
|
||||
@ -68,13 +68,13 @@ impl Worker {
|
||||
Err(_) => return Err(Error::Syntax),
|
||||
};
|
||||
|
||||
let resource_task = global.resource_task();
|
||||
let resource_thread = global.resource_thread();
|
||||
let constellation_chan = global.constellation_chan();
|
||||
let scheduler_chan = global.scheduler_chan();
|
||||
|
||||
let (sender, receiver) = channel();
|
||||
let worker = Worker::new(global, sender.clone());
|
||||
let worker_ref = Trusted::new(worker.r(), global.dom_manipulation_task_source());
|
||||
let worker_ref = Trusted::new(worker.r(), global.dom_manipulation_thread_source());
|
||||
let worker_id = global.get_next_worker_id();
|
||||
|
||||
let (devtools_sender, devtools_receiver) = ipc::channel().unwrap();
|
||||
@ -95,7 +95,7 @@ impl Worker {
|
||||
};
|
||||
|
||||
let init = WorkerGlobalScopeInit {
|
||||
resource_task: resource_task,
|
||||
resource_thread: resource_thread,
|
||||
mem_profiler_chan: global.mem_profiler_chan(),
|
||||
to_devtools_sender: global.devtools_chan(),
|
||||
from_devtools_sender: optional_sender,
|
||||
@ -105,7 +105,7 @@ impl Worker {
|
||||
};
|
||||
DedicatedWorkerGlobalScope::run_worker_scope(
|
||||
init, worker_url, global.pipeline(), devtools_receiver, worker_ref,
|
||||
global.dom_manipulation_task_source(), sender, receiver);
|
||||
global.dom_manipulation_thread_source(), sender, receiver);
|
||||
|
||||
Ok(worker)
|
||||
}
|
||||
@ -145,7 +145,7 @@ impl WorkerMethods for Worker {
|
||||
// https://html.spec.whatwg.org/multipage/#dom-dedicatedworkerglobalscope-postmessage
|
||||
fn PostMessage(&self, cx: *mut JSContext, message: HandleValue) -> ErrorResult {
|
||||
let data = try!(StructuredCloneData::write(cx, message));
|
||||
let address = Trusted::new(self, self.global.root().r().dom_manipulation_task_source());
|
||||
let address = Trusted::new(self, self.global.root().r().dom_manipulation_thread_source());
|
||||
self.sender.send((address, WorkerScriptMsg::DOMMessage(data))).unwrap();
|
||||
Ok(())
|
||||
}
|
||||
|
@ -21,9 +21,9 @@ use ipc_channel::ipc::IpcSender;
|
||||
use js::jsapi::{HandleValue, JSAutoRequest, JSContext};
|
||||
use js::rust::Runtime;
|
||||
use msg::constellation_msg::{ConstellationChan, PipelineId};
|
||||
use net_traits::{LoadContext, ResourceTask, load_whole_resource};
|
||||
use net_traits::{LoadContext, ResourceThread, load_whole_resource};
|
||||
use profile_traits::mem;
|
||||
use script_task::{CommonScriptMsg, ScriptChan, ScriptPort};
|
||||
use script_thread::{CommonScriptMsg, ScriptChan, ScriptPort};
|
||||
use script_traits::ScriptMsg as ConstellationMsg;
|
||||
use script_traits::{MsDuration, TimerEvent, TimerEventId, TimerEventRequest, TimerSource};
|
||||
use std::cell::Cell;
|
||||
@ -40,7 +40,7 @@ pub enum WorkerGlobalScopeTypeId {
|
||||
}
|
||||
|
||||
pub struct WorkerGlobalScopeInit {
|
||||
pub resource_task: ResourceTask,
|
||||
pub resource_thread: ResourceThread,
|
||||
pub mem_profiler_chan: mem::ProfilerChan,
|
||||
pub to_devtools_sender: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
|
||||
pub from_devtools_sender: Option<IpcSender<DevtoolScriptControlMsg>>,
|
||||
@ -59,7 +59,7 @@ pub struct WorkerGlobalScope {
|
||||
runtime: Rc<Runtime>,
|
||||
next_worker_id: Cell<WorkerId>,
|
||||
#[ignore_heap_size_of = "Defined in std"]
|
||||
resource_task: ResourceTask,
|
||||
resource_thread: ResourceThread,
|
||||
location: MutNullableHeap<JS<WorkerLocation>>,
|
||||
navigator: MutNullableHeap<JS<WorkerNavigator>>,
|
||||
console: MutNullableHeap<JS<Console>>,
|
||||
@ -104,7 +104,7 @@ impl WorkerGlobalScope {
|
||||
worker_id: init.worker_id,
|
||||
worker_url: worker_url,
|
||||
runtime: runtime,
|
||||
resource_task: init.resource_task,
|
||||
resource_thread: init.resource_thread,
|
||||
location: Default::default(),
|
||||
navigator: Default::default(),
|
||||
console: Default::default(),
|
||||
@ -158,8 +158,8 @@ impl WorkerGlobalScope {
|
||||
self.runtime.cx()
|
||||
}
|
||||
|
||||
pub fn resource_task(&self) -> &ResourceTask {
|
||||
&self.resource_task
|
||||
pub fn resource_thread(&self) -> &ResourceThread {
|
||||
&self.resource_thread
|
||||
}
|
||||
|
||||
pub fn get_url(&self) -> &Url {
|
||||
@ -203,7 +203,7 @@ impl WorkerGlobalScopeMethods for WorkerGlobalScope {
|
||||
}
|
||||
|
||||
for url in urls {
|
||||
let (url, source) = match load_whole_resource(LoadContext::Script, &self.resource_task, url, None) {
|
||||
let (url, source) = match load_whole_resource(LoadContext::Script, &self.resource_thread, url, None) {
|
||||
Err(_) => return Err(Error::Network),
|
||||
Ok((metadata, bytes)) => {
|
||||
(metadata.final_url, String::from_utf8(bytes).unwrap())
|
||||
|
@ -46,11 +46,11 @@ use js::jsapi::{JSContext, JS_ParseJSON, RootedValue};
|
||||
use js::jsval::{JSVal, NullValue, UndefinedValue};
|
||||
use net_traits::ControlMsg::Load;
|
||||
use net_traits::{AsyncResponseListener, AsyncResponseTarget, Metadata};
|
||||
use net_traits::{LoadConsumer, LoadContext, LoadData, ResourceCORSData, ResourceTask};
|
||||
use net_traits::{LoadConsumer, LoadContext, LoadData, ResourceCORSData, ResourceThread};
|
||||
use network_listener::{NetworkListener, PreInvoke};
|
||||
use parse::html::{ParseContext, parse_html};
|
||||
use parse::xml::{self, parse_xml};
|
||||
use script_task::{ScriptChan, ScriptPort};
|
||||
use script_thread::{ScriptChan, ScriptPort};
|
||||
use std::ascii::AsciiExt;
|
||||
use std::borrow::ToOwned;
|
||||
use std::cell::{Cell, RefCell};
|
||||
@ -197,13 +197,13 @@ impl XMLHttpRequest {
|
||||
load_data: LoadData,
|
||||
req: CORSRequest,
|
||||
script_chan: Box<ScriptChan + Send>,
|
||||
resource_task: ResourceTask) {
|
||||
resource_thread: ResourceThread) {
|
||||
struct CORSContext {
|
||||
xhr: Arc<Mutex<XHRContext>>,
|
||||
load_data: RefCell<Option<LoadData>>,
|
||||
req: CORSRequest,
|
||||
script_chan: Box<ScriptChan + Send>,
|
||||
resource_task: ResourceTask,
|
||||
resource_thread: ResourceThread,
|
||||
}
|
||||
|
||||
impl AsyncCORSResponseListener for CORSContext {
|
||||
@ -223,7 +223,7 @@ impl XMLHttpRequest {
|
||||
});
|
||||
|
||||
XMLHttpRequest::initiate_async_xhr(self.xhr.clone(), self.script_chan.clone(),
|
||||
self.resource_task.clone(), load_data);
|
||||
self.resource_thread.clone(), load_data);
|
||||
}
|
||||
}
|
||||
|
||||
@ -232,7 +232,7 @@ impl XMLHttpRequest {
|
||||
load_data: RefCell::new(Some(load_data)),
|
||||
req: req.clone(),
|
||||
script_chan: script_chan.clone(),
|
||||
resource_task: resource_task,
|
||||
resource_thread: resource_thread,
|
||||
};
|
||||
|
||||
req.http_fetch_async(box cors_context, script_chan);
|
||||
@ -240,7 +240,7 @@ impl XMLHttpRequest {
|
||||
|
||||
fn initiate_async_xhr(context: Arc<Mutex<XHRContext>>,
|
||||
script_chan: Box<ScriptChan + Send>,
|
||||
resource_task: ResourceTask,
|
||||
resource_thread: ResourceThread,
|
||||
load_data: LoadData) {
|
||||
impl AsyncResponseListener for XHRContext {
|
||||
fn headers_available(&mut self, metadata: Metadata) {
|
||||
@ -281,7 +281,7 @@ impl XMLHttpRequest {
|
||||
ROUTER.add_route(action_receiver.to_opaque(), box move |message| {
|
||||
listener.notify(message.to().unwrap());
|
||||
});
|
||||
resource_task.send(Load(load_data, LoadConsumer::Listener(response_target), None)).unwrap();
|
||||
resource_thread.send(Load(load_data, LoadConsumer::Listener(response_target), None)).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1026,7 +1026,7 @@ impl XMLHttpRequest {
|
||||
// This will cancel all previous timeouts
|
||||
let global = self.global.root();
|
||||
let callback = ScheduledXHRTimeout {
|
||||
xhr: Trusted::new(self, global.r().networking_task_source()),
|
||||
xhr: Trusted::new(self, global.r().networking_thread_source()),
|
||||
generation_id: self.generation_id.get(),
|
||||
};
|
||||
let duration = Length::new(duration_ms as u64);
|
||||
@ -1178,7 +1178,7 @@ impl XMLHttpRequest {
|
||||
Ok(req) => req,
|
||||
};
|
||||
|
||||
let xhr = Trusted::new(self, global.networking_task_source());
|
||||
let xhr = Trusted::new(self, global.networking_thread_source());
|
||||
|
||||
let context = Arc::new(Mutex::new(XHRContext {
|
||||
xhr: xhr,
|
||||
@ -1192,16 +1192,16 @@ impl XMLHttpRequest {
|
||||
let (tx, rx) = global.new_script_pair();
|
||||
(tx, Some(rx))
|
||||
} else {
|
||||
(global.networking_task_source(), None)
|
||||
(global.networking_thread_source(), None)
|
||||
};
|
||||
|
||||
let resource_task = global.resource_task();
|
||||
let resource_thread = global.resource_thread();
|
||||
if let Some(req) = cors_request {
|
||||
XMLHttpRequest::check_cors(context.clone(), load_data, req.clone(),
|
||||
script_chan.clone(), resource_task);
|
||||
script_chan.clone(), resource_thread);
|
||||
} else {
|
||||
XMLHttpRequest::initiate_async_xhr(context.clone(), script_chan,
|
||||
resource_task, load_data);
|
||||
resource_thread, load_data);
|
||||
}
|
||||
|
||||
if let Some(script_port) = script_port {
|
||||
|
@ -15,7 +15,7 @@ use ipc_channel::ipc::{IpcReceiver, IpcSender};
|
||||
use msg::compositor_msg::Epoch;
|
||||
use msg::constellation_msg::{ConstellationChan, Failure, PipelineId};
|
||||
use msg::constellation_msg::{WindowSizeData};
|
||||
use net_traits::image_cache_task::ImageCacheTask;
|
||||
use net_traits::image_cache_thread::ImageCacheThread;
|
||||
use profile_traits::mem::ReportsChan;
|
||||
use script_traits::{ConstellationControlMsg, LayoutControlMsg, LayoutMsg as ConstellationMsg};
|
||||
use script_traits::{OpaqueScriptLayoutChannel, UntrustedNodeAddress};
|
||||
@ -46,10 +46,10 @@ pub enum Msg {
|
||||
/// Get an RPC interface.
|
||||
GetRPC(Sender<Box<LayoutRPC + Send>>),
|
||||
|
||||
/// Requests that the layout task render the next frame of all animations.
|
||||
/// Requests that the layout thread render the next frame of all animations.
|
||||
TickAnimations,
|
||||
|
||||
/// Requests that the layout task reflow with a newly-loaded Web font.
|
||||
/// Requests that the layout thread reflow with a newly-loaded Web font.
|
||||
ReflowWithNewlyLoadedWebFont,
|
||||
|
||||
/// Updates the layout visible rects, affecting the area that display lists will be constructed
|
||||
@ -61,30 +61,30 @@ pub enum Msg {
|
||||
/// TODO(pcwalton): Maybe think about batching to avoid message traffic.
|
||||
ReapStyleAndLayoutData(OpaqueStyleAndLayoutData),
|
||||
|
||||
/// Requests that the layout task measure its memory usage. The resulting reports are sent back
|
||||
/// Requests that the layout thread measure its memory usage. The resulting reports are sent back
|
||||
/// via the supplied channel.
|
||||
CollectReports(ReportsChan),
|
||||
|
||||
/// Requests that the layout task enter a quiescent state in which no more messages are
|
||||
/// Requests that the layout thread enter a quiescent state in which no more messages are
|
||||
/// accepted except `ExitMsg`. A response message will be sent on the supplied channel when
|
||||
/// this happens.
|
||||
PrepareToExit(Sender<()>),
|
||||
|
||||
/// Requests that the layout task immediately shut down. There must be no more nodes left after
|
||||
/// Requests that the layout thread immediately shut down. There must be no more nodes left after
|
||||
/// this, or layout will crash.
|
||||
ExitNow,
|
||||
|
||||
/// Get the last epoch counter for this layout task.
|
||||
/// Get the last epoch counter for this layout thread.
|
||||
GetCurrentEpoch(IpcSender<Epoch>),
|
||||
|
||||
/// Asks the layout task whether any Web fonts have yet to load (if true, loads are pending;
|
||||
/// Asks the layout thread whether any Web fonts have yet to load (if true, loads are pending;
|
||||
/// false otherwise).
|
||||
GetWebFontLoadState(IpcSender<bool>),
|
||||
|
||||
/// Creates a new layout task.
|
||||
/// Creates a new layout thread.
|
||||
///
|
||||
/// This basically exists to keep the script-layout dependency one-way.
|
||||
CreateLayoutTask(NewLayoutTaskInfo),
|
||||
CreateLayoutThread(NewLayoutThreadInfo),
|
||||
|
||||
/// Set the final Url.
|
||||
SetFinalUrl(Url),
|
||||
@ -95,7 +95,7 @@ pub enum Msg {
|
||||
/// In general, you should use messages to talk to Layout. Use the RPC interface
|
||||
/// if and only if the work is
|
||||
///
|
||||
/// 1) read-only with respect to LayoutTaskData,
|
||||
/// 1) read-only with respect to LayoutThreadData,
|
||||
/// 2) small,
|
||||
/// 3) and really needs to be fast.
|
||||
pub trait LayoutRPC {
|
||||
@ -181,7 +181,7 @@ impl Drop for ScriptReflow {
|
||||
}
|
||||
}
|
||||
|
||||
/// Encapsulates a channel to the layout task.
|
||||
/// Encapsulates a channel to the layout thread.
|
||||
#[derive(Clone)]
|
||||
pub struct LayoutChan(pub Sender<Msg>);
|
||||
|
||||
@ -217,7 +217,7 @@ impl ScriptLayoutChan for OpaqueScriptLayoutChannel {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct NewLayoutTaskInfo {
|
||||
pub struct NewLayoutThreadInfo {
|
||||
pub id: PipelineId,
|
||||
pub url: Url,
|
||||
pub is_parent: bool,
|
||||
@ -226,7 +226,7 @@ pub struct NewLayoutTaskInfo {
|
||||
pub constellation_chan: ConstellationChan<ConstellationMsg>,
|
||||
pub failure: Failure,
|
||||
pub script_chan: IpcSender<ConstellationControlMsg>,
|
||||
pub image_cache_task: ImageCacheTask,
|
||||
pub image_cache_thread: ImageCacheThread,
|
||||
pub paint_chan: OptionalOpaqueIpcSender,
|
||||
pub layout_shutdown_chan: IpcSender<()>,
|
||||
pub content_process_shutdown_chan: IpcSender<()>,
|
||||
|
@ -92,7 +92,7 @@ pub mod page;
|
||||
pub mod parse;
|
||||
pub mod reporter;
|
||||
#[allow(unsafe_code)]
|
||||
pub mod script_task;
|
||||
pub mod script_thread;
|
||||
pub mod textinput;
|
||||
mod timers;
|
||||
mod unpremultiplytable;
|
||||
@ -147,7 +147,7 @@ fn perform_platform_specific_initialization() {}
|
||||
pub fn init() {
|
||||
unsafe {
|
||||
assert_eq!(js::jsapi::JS_Init(), true);
|
||||
SetDOMProxyInformation(ptr::null(), 0, Some(script_task::shadow_check_callback));
|
||||
SetDOMProxyInformation(ptr::null(), 0, Some(script_thread::shadow_check_callback));
|
||||
}
|
||||
|
||||
// Create the global vtables used by the (generated) DOM
|
||||
|
@ -3,8 +3,8 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use net_traits::{AsyncResponseListener, ResponseAction};
|
||||
use script_task::ScriptTaskEventCategory::NetworkEvent;
|
||||
use script_task::{CommonScriptMsg, Runnable, ScriptChan};
|
||||
use script_thread::ScriptThreadEventCategory::NetworkEvent;
|
||||
use script_thread::{CommonScriptMsg, Runnable, ScriptChan};
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
/// An off-thread sink for async network event runnables. All such events are forwarded to
|
||||
|
@ -2,19 +2,19 @@
|
||||
* 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/. */
|
||||
|
||||
//! The script task is the task that owns the DOM in memory, runs JavaScript, and spawns parsing
|
||||
//! and layout tasks. It's in charge of processing events for all same-origin pages in a frame
|
||||
//! The script thread is the thread that owns the DOM in memory, runs JavaScript, and spawns parsing
|
||||
//! and layout threads. It's in charge of processing events for all same-origin pages in a frame
|
||||
//! tree, and manages the entire lifetime of pages in the frame tree from initial request to
|
||||
//! teardown.
|
||||
//!
|
||||
//! Page loads follow a two-step process. When a request for a new page load is received, the
|
||||
//! network request is initiated and the relevant data pertaining to the new page is stashed.
|
||||
//! While the non-blocking request is ongoing, the script task is free to process further events,
|
||||
//! While the non-blocking request is ongoing, the script thread is free to process further events,
|
||||
//! noting when they pertain to ongoing loads (such as resizes/viewport adjustments). When the
|
||||
//! initial response is received for an ongoing load, the second phase starts - the frame tree
|
||||
//! entry is created, along with the Window and Document objects, and the appropriate parser
|
||||
//! takes over the response body. Once parsing is complete, the document lifecycle for loading
|
||||
//! a page runs its course and the script task returns to processing events in the main event
|
||||
//! a page runs its course and the script thread returns to processing events in the main event
|
||||
//! loop.
|
||||
|
||||
use devtools;
|
||||
@ -59,7 +59,7 @@ use js::jsapi::{JSObject, SetPreserveWrapperCallback};
|
||||
use js::jsval::UndefinedValue;
|
||||
use js::rust::Runtime;
|
||||
use layout_interface::{ReflowQueryType};
|
||||
use layout_interface::{self, LayoutChan, NewLayoutTaskInfo, ReflowGoal, ScriptLayoutChan};
|
||||
use layout_interface::{self, LayoutChan, NewLayoutThreadInfo, ReflowGoal, ScriptLayoutChan};
|
||||
use libc;
|
||||
use mem::heap_size_of_self_and_children;
|
||||
use msg::constellation_msg::{ConstellationChan, LoadData};
|
||||
@ -68,9 +68,9 @@ use msg::constellation_msg::{PipelineNamespace};
|
||||
use msg::constellation_msg::{SubpageId, WindowSizeData};
|
||||
use msg::webdriver_msg::WebDriverScriptCommand;
|
||||
use net_traits::LoadData as NetLoadData;
|
||||
use net_traits::image_cache_task::{ImageCacheChan, ImageCacheResult, ImageCacheTask};
|
||||
use net_traits::storage_task::StorageTask;
|
||||
use net_traits::{AsyncResponseTarget, ControlMsg, LoadConsumer, LoadContext, Metadata, ResourceTask};
|
||||
use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheResult, ImageCacheThread};
|
||||
use net_traits::storage_thread::StorageThread;
|
||||
use net_traits::{AsyncResponseTarget, ControlMsg, LoadConsumer, LoadContext, Metadata, ResourceThread};
|
||||
use network_listener::NetworkListener;
|
||||
use page::{Frame, IterablePage, Page};
|
||||
use parse::html::{ParseContext, parse_html};
|
||||
@ -81,7 +81,7 @@ use script_traits::CompositorEvent::{KeyEvent, MouseButtonEvent, MouseMoveEvent,
|
||||
use script_traits::CompositorEvent::{TouchEvent};
|
||||
use script_traits::{CompositorEvent, ConstellationControlMsg, EventResult, InitialScriptState, NewLayoutInfo};
|
||||
use script_traits::{LayoutMsg, OpaqueScriptLayoutChannel, ScriptMsg as ConstellationMsg};
|
||||
use script_traits::{ScriptTaskFactory, ScriptToCompositorMsg, TimerEvent, TimerEventRequest, TimerSource};
|
||||
use script_traits::{ScriptThreadFactory, ScriptToCompositorMsg, TimerEvent, TimerEventRequest, TimerSource};
|
||||
use script_traits::{TouchEventType, TouchId};
|
||||
use std::any::Any;
|
||||
use std::borrow::ToOwned;
|
||||
@ -101,17 +101,17 @@ use time::{Tm, now};
|
||||
use url::Url;
|
||||
use util::opts;
|
||||
use util::str::DOMString;
|
||||
use util::task;
|
||||
use util::task_state;
|
||||
use util::thread;
|
||||
use util::thread_state;
|
||||
use webdriver_handlers;
|
||||
|
||||
thread_local!(pub static STACK_ROOTS: Cell<Option<RootCollectionPtr>> = Cell::new(None));
|
||||
thread_local!(static SCRIPT_TASK_ROOT: RefCell<Option<*const ScriptTask>> = RefCell::new(None));
|
||||
thread_local!(static SCRIPT_TASK_ROOT: RefCell<Option<*const ScriptThread>> = RefCell::new(None));
|
||||
|
||||
unsafe extern fn trace_rust_roots(tr: *mut JSTracer, _data: *mut libc::c_void) {
|
||||
SCRIPT_TASK_ROOT.with(|root| {
|
||||
if let Some(script_task) = *root.borrow() {
|
||||
(*script_task).trace(tr);
|
||||
if let Some(script_thread) = *root.borrow() {
|
||||
(*script_thread).trace(tr);
|
||||
}
|
||||
});
|
||||
|
||||
@ -131,7 +131,7 @@ struct InProgressLoad {
|
||||
parent_info: Option<(PipelineId, SubpageId)>,
|
||||
/// The current window size associated with this pipeline.
|
||||
window_size: Option<WindowSizeData>,
|
||||
/// Channel to the layout task associated with this pipeline.
|
||||
/// Channel to the layout thread associated with this pipeline.
|
||||
layout_chan: LayoutChan,
|
||||
/// The current viewport clipping rectangle applying to this pipeline, if any.
|
||||
clip_rect: Option<Rect<f32>>,
|
||||
@ -196,7 +196,7 @@ pub trait Runnable {
|
||||
}
|
||||
|
||||
pub trait MainThreadRunnable {
|
||||
fn handler(self: Box<Self>, script_task: &ScriptTask);
|
||||
fn handler(self: Box<Self>, script_thread: &ScriptThread);
|
||||
}
|
||||
|
||||
enum MixedMessage {
|
||||
@ -209,17 +209,17 @@ enum MixedMessage {
|
||||
|
||||
/// Common messages used to control the event loops in both the script and the worker
|
||||
pub enum CommonScriptMsg {
|
||||
/// Requests that the script task measure its memory usage. The results are sent back via the
|
||||
/// Requests that the script thread measure its memory usage. The results are sent back via the
|
||||
/// supplied channel.
|
||||
CollectReports(ReportsChan),
|
||||
/// A DOM object's last pinned reference was removed (dispatched to all tasks).
|
||||
/// A DOM object's last pinned reference was removed (dispatched to all threads).
|
||||
RefcountCleanup(TrustedReference),
|
||||
/// Generic message that encapsulates event handling.
|
||||
RunnableMsg(ScriptTaskEventCategory, Box<Runnable + Send>),
|
||||
RunnableMsg(ScriptThreadEventCategory, Box<Runnable + Send>),
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, Hash, JSTraceable, PartialEq)]
|
||||
pub enum ScriptTaskEventCategory {
|
||||
pub enum ScriptThreadEventCategory {
|
||||
AttachLayout,
|
||||
ConstellationMsg,
|
||||
DevtoolsMsg,
|
||||
@ -246,12 +246,12 @@ pub enum MainThreadScriptMsg {
|
||||
/// Notify a document that all pending loads are complete.
|
||||
DocumentLoadsComplete(PipelineId),
|
||||
/// Notifies the script that a window associated with a particular pipeline
|
||||
/// should be closed (only dispatched to ScriptTask).
|
||||
/// should be closed (only dispatched to ScriptThread).
|
||||
ExitWindow(PipelineId),
|
||||
/// Generic message for running tasks in the ScriptTask
|
||||
/// Generic message for running threads in the ScriptThread
|
||||
MainThreadRunnableMsg(Box<MainThreadRunnable + Send>),
|
||||
/// Begins a content-initiated load on the specified pipeline (only
|
||||
/// dispatched to ScriptTask).
|
||||
/// dispatched to ScriptThread).
|
||||
Navigate(PipelineId, LoadData),
|
||||
}
|
||||
|
||||
@ -306,7 +306,7 @@ impl ScriptPort for Receiver<(TrustedWorkerAddress, MainThreadScriptMsg)> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Encapsulates internal communication of shared messages within the script task.
|
||||
/// Encapsulates internal communication of shared messages within the script thread.
|
||||
#[derive(JSTraceable)]
|
||||
pub struct SendableMainThreadScriptChan(pub Sender<CommonScriptMsg>);
|
||||
|
||||
@ -330,7 +330,7 @@ impl SendableMainThreadScriptChan {
|
||||
}
|
||||
}
|
||||
|
||||
/// Encapsulates internal communication of main thread messages within the script task.
|
||||
/// Encapsulates internal communication of main thread messages within the script thread.
|
||||
#[derive(JSTraceable)]
|
||||
pub struct MainThreadScriptChan(pub Sender<MainThreadScriptMsg>);
|
||||
|
||||
@ -354,99 +354,99 @@ impl MainThreadScriptChan {
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: Use a task source specific message instead of MainThreadScriptMsg
|
||||
// FIXME: Use a thread source specific message instead of MainThreadScriptMsg
|
||||
#[derive(JSTraceable)]
|
||||
pub struct DOMManipulationTaskSource(pub Sender<MainThreadScriptMsg>);
|
||||
pub struct DOMManipulationThreadSource(pub Sender<MainThreadScriptMsg>);
|
||||
|
||||
impl ScriptChan for DOMManipulationTaskSource {
|
||||
impl ScriptChan for DOMManipulationThreadSource {
|
||||
fn send(&self, msg: CommonScriptMsg) -> Result<(), ()> {
|
||||
let DOMManipulationTaskSource(ref chan) = *self;
|
||||
let DOMManipulationThreadSource(ref chan) = *self;
|
||||
chan.send(MainThreadScriptMsg::Common(msg)).map_err(|_| ())
|
||||
}
|
||||
|
||||
fn clone(&self) -> Box<ScriptChan + Send> {
|
||||
let DOMManipulationTaskSource(ref chan) = *self;
|
||||
box DOMManipulationTaskSource((*chan).clone())
|
||||
let DOMManipulationThreadSource(ref chan) = *self;
|
||||
box DOMManipulationThreadSource((*chan).clone())
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: Use a task source specific message instead of MainThreadScriptMsg
|
||||
// FIXME: Use a thread source specific message instead of MainThreadScriptMsg
|
||||
#[derive(JSTraceable)]
|
||||
pub struct UserInteractionTaskSource(pub Sender<MainThreadScriptMsg>);
|
||||
pub struct UserInteractionThreadSource(pub Sender<MainThreadScriptMsg>);
|
||||
|
||||
impl ScriptChan for UserInteractionTaskSource {
|
||||
impl ScriptChan for UserInteractionThreadSource {
|
||||
fn send(&self, msg: CommonScriptMsg) -> Result<(), ()> {
|
||||
let UserInteractionTaskSource(ref chan) = *self;
|
||||
let UserInteractionThreadSource(ref chan) = *self;
|
||||
chan.send(MainThreadScriptMsg::Common(msg)).map_err(|_| ())
|
||||
}
|
||||
|
||||
fn clone(&self) -> Box<ScriptChan + Send> {
|
||||
let UserInteractionTaskSource(ref chan) = *self;
|
||||
box UserInteractionTaskSource((*chan).clone())
|
||||
let UserInteractionThreadSource(ref chan) = *self;
|
||||
box UserInteractionThreadSource((*chan).clone())
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: Use a task source specific message instead of MainThreadScriptMsg
|
||||
// FIXME: Use a thread source specific message instead of MainThreadScriptMsg
|
||||
#[derive(JSTraceable)]
|
||||
pub struct NetworkingTaskSource(pub Sender<MainThreadScriptMsg>);
|
||||
pub struct NetworkingThreadSource(pub Sender<MainThreadScriptMsg>);
|
||||
|
||||
impl ScriptChan for NetworkingTaskSource {
|
||||
impl ScriptChan for NetworkingThreadSource {
|
||||
fn send(&self, msg: CommonScriptMsg) -> Result<(), ()> {
|
||||
let NetworkingTaskSource(ref chan) = *self;
|
||||
let NetworkingThreadSource(ref chan) = *self;
|
||||
chan.send(MainThreadScriptMsg::Common(msg)).map_err(|_| ())
|
||||
}
|
||||
|
||||
fn clone(&self) -> Box<ScriptChan + Send> {
|
||||
let NetworkingTaskSource(ref chan) = *self;
|
||||
box NetworkingTaskSource((*chan).clone())
|
||||
let NetworkingThreadSource(ref chan) = *self;
|
||||
box NetworkingThreadSource((*chan).clone())
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: Use a task source specific message instead of MainThreadScriptMsg
|
||||
// FIXME: Use a thread source specific message instead of MainThreadScriptMsg
|
||||
#[derive(JSTraceable)]
|
||||
pub struct HistoryTraversalTaskSource(pub Sender<MainThreadScriptMsg>);
|
||||
pub struct HistoryTraversalThreadSource(pub Sender<MainThreadScriptMsg>);
|
||||
|
||||
impl ScriptChan for HistoryTraversalTaskSource {
|
||||
impl ScriptChan for HistoryTraversalThreadSource {
|
||||
fn send(&self, msg: CommonScriptMsg) -> Result<(), ()> {
|
||||
let HistoryTraversalTaskSource(ref chan) = *self;
|
||||
let HistoryTraversalThreadSource(ref chan) = *self;
|
||||
chan.send(MainThreadScriptMsg::Common(msg)).map_err(|_| ())
|
||||
}
|
||||
|
||||
fn clone(&self) -> Box<ScriptChan + Send> {
|
||||
let HistoryTraversalTaskSource(ref chan) = *self;
|
||||
box HistoryTraversalTaskSource((*chan).clone())
|
||||
let HistoryTraversalThreadSource(ref chan) = *self;
|
||||
box HistoryTraversalThreadSource((*chan).clone())
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: Use a task source specific message instead of MainThreadScriptMsg
|
||||
// FIXME: Use a thread source specific message instead of MainThreadScriptMsg
|
||||
#[derive(JSTraceable)]
|
||||
pub struct FileReadingTaskSource(pub Sender<MainThreadScriptMsg>);
|
||||
pub struct FileReadingThreadSource(pub Sender<MainThreadScriptMsg>);
|
||||
|
||||
impl ScriptChan for FileReadingTaskSource {
|
||||
impl ScriptChan for FileReadingThreadSource {
|
||||
fn send(&self, msg: CommonScriptMsg) -> Result<(), ()> {
|
||||
let FileReadingTaskSource(ref chan) = *self;
|
||||
let FileReadingThreadSource(ref chan) = *self;
|
||||
chan.send(MainThreadScriptMsg::Common(msg)).map_err(|_| ())
|
||||
}
|
||||
|
||||
fn clone(&self) -> Box<ScriptChan + Send> {
|
||||
let FileReadingTaskSource(ref chan) = *self;
|
||||
box FileReadingTaskSource((*chan).clone())
|
||||
let FileReadingThreadSource(ref chan) = *self;
|
||||
box FileReadingThreadSource((*chan).clone())
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: Use a task source specific message instead of MainThreadScriptMsg
|
||||
// FIXME: Use a thread source specific message instead of MainThreadScriptMsg
|
||||
#[derive(JSTraceable)]
|
||||
pub struct ProfilerTaskSource(pub Sender<MainThreadScriptMsg>);
|
||||
pub struct ProfilerThreadSource(pub Sender<MainThreadScriptMsg>);
|
||||
|
||||
impl ScriptChan for ProfilerTaskSource {
|
||||
impl ScriptChan for ProfilerThreadSource {
|
||||
fn send(&self, msg: CommonScriptMsg) -> Result<(), ()> {
|
||||
let ProfilerTaskSource(ref chan) = *self;
|
||||
let ProfilerThreadSource(ref chan) = *self;
|
||||
chan.send(MainThreadScriptMsg::Common(msg)).map_err(|_| ())
|
||||
}
|
||||
|
||||
fn clone(&self) -> Box<ScriptChan + Send> {
|
||||
let ProfilerTaskSource(ref chan) = *self;
|
||||
box ProfilerTaskSource((*chan).clone())
|
||||
let ProfilerThreadSource(ref chan) = *self;
|
||||
box ProfilerThreadSource((*chan).clone())
|
||||
}
|
||||
}
|
||||
|
||||
@ -471,41 +471,41 @@ impl<'a> Drop for StackRootTLS<'a> {
|
||||
/// Information for an entire page. Pages are top-level browsing contexts and can contain multiple
|
||||
/// frames.
|
||||
#[derive(JSTraceable)]
|
||||
// ScriptTask instances are rooted on creation, so this is okay
|
||||
// ScriptThread instances are rooted on creation, so this is okay
|
||||
#[allow(unrooted_must_root)]
|
||||
pub struct ScriptTask {
|
||||
pub struct ScriptThread {
|
||||
/// A handle to the information pertaining to page layout
|
||||
page: DOMRefCell<Option<Rc<Page>>>,
|
||||
/// A list of data pertaining to loads that have not yet received a network response
|
||||
incomplete_loads: DOMRefCell<Vec<InProgressLoad>>,
|
||||
/// A handle to the image cache task.
|
||||
image_cache_task: ImageCacheTask,
|
||||
/// A handle to the resource task. This is an `Arc` to avoid running out of file descriptors if
|
||||
/// A handle to the image cache thread.
|
||||
image_cache_thread: ImageCacheThread,
|
||||
/// A handle to the resource thread. This is an `Arc` to avoid running out of file descriptors if
|
||||
/// there are many iframes.
|
||||
resource_task: Arc<ResourceTask>,
|
||||
/// A handle to the storage task.
|
||||
storage_task: StorageTask,
|
||||
resource_thread: Arc<ResourceThread>,
|
||||
/// A handle to the storage thread.
|
||||
storage_thread: StorageThread,
|
||||
|
||||
/// The port on which the script task receives messages (load URL, exit, etc.)
|
||||
/// The port on which the script thread receives messages (load URL, exit, etc.)
|
||||
port: Receiver<MainThreadScriptMsg>,
|
||||
/// A channel to hand out to script task-based entities that need to be able to enqueue
|
||||
/// A channel to hand out to script thread-based entities that need to be able to enqueue
|
||||
/// events in the event queue.
|
||||
chan: MainThreadScriptChan,
|
||||
dom_manipulation_task_source: DOMManipulationTaskSource,
|
||||
dom_manipulation_thread_source: DOMManipulationThreadSource,
|
||||
|
||||
user_interaction_task_source: UserInteractionTaskSource,
|
||||
user_interaction_thread_source: UserInteractionThreadSource,
|
||||
|
||||
networking_task_source: NetworkingTaskSource,
|
||||
networking_thread_source: NetworkingThreadSource,
|
||||
|
||||
history_traversal_task_source: HistoryTraversalTaskSource,
|
||||
history_traversal_thread_source: HistoryTraversalThreadSource,
|
||||
|
||||
file_reading_task_source: FileReadingTaskSource,
|
||||
file_reading_thread_source: FileReadingThreadSource,
|
||||
|
||||
/// A channel to hand out to tasks that need to respond to a message from the script task.
|
||||
/// A channel to hand out to threads that need to respond to a message from the script thread.
|
||||
control_chan: IpcSender<ConstellationControlMsg>,
|
||||
|
||||
/// The port on which the constellation and layout tasks can communicate with the
|
||||
/// script task.
|
||||
/// The port on which the constellation and layout threads can communicate with the
|
||||
/// script thread.
|
||||
control_port: Receiver<ConstellationControlMsg>,
|
||||
|
||||
/// For communicating load url messages to the constellation
|
||||
@ -541,7 +541,7 @@ pub struct ScriptTask {
|
||||
|
||||
mouse_over_targets: DOMRefCell<Vec<JS<Element>>>,
|
||||
|
||||
/// List of pipelines that have been owned and closed by this script task.
|
||||
/// List of pipelines that have been owned and closed by this script thread.
|
||||
closed_pipelines: DOMRefCell<HashSet<PipelineId>>,
|
||||
|
||||
scheduler_chan: IpcSender<TimerEventRequest>,
|
||||
@ -551,12 +551,12 @@ pub struct ScriptTask {
|
||||
content_process_shutdown_chan: IpcSender<()>,
|
||||
}
|
||||
|
||||
/// In the event of task failure, all data on the stack runs its destructor. However, there
|
||||
/// In the event of thread failure, all data on the stack runs its destructor. However, there
|
||||
/// are no reachable, owning pointers to the DOM memory, so it never gets freed by default
|
||||
/// when the script task fails. The ScriptMemoryFailsafe uses the destructor bomb pattern
|
||||
/// to forcibly tear down the JS compartments for pages associated with the failing ScriptTask.
|
||||
/// when the script thread fails. The ScriptMemoryFailsafe uses the destructor bomb pattern
|
||||
/// to forcibly tear down the JS compartments for pages associated with the failing ScriptThread.
|
||||
struct ScriptMemoryFailsafe<'a> {
|
||||
owner: Option<&'a ScriptTask>,
|
||||
owner: Option<&'a ScriptThread>,
|
||||
}
|
||||
|
||||
impl<'a> ScriptMemoryFailsafe<'a> {
|
||||
@ -564,7 +564,7 @@ impl<'a> ScriptMemoryFailsafe<'a> {
|
||||
self.owner = None;
|
||||
}
|
||||
|
||||
fn new(owner: &'a ScriptTask) -> ScriptMemoryFailsafe<'a> {
|
||||
fn new(owner: &'a ScriptThread) -> ScriptMemoryFailsafe<'a> {
|
||||
ScriptMemoryFailsafe {
|
||||
owner: Some(owner),
|
||||
}
|
||||
@ -589,18 +589,18 @@ impl<'a> Drop for ScriptMemoryFailsafe<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
impl ScriptTaskFactory for ScriptTask {
|
||||
fn create_layout_channel(_phantom: Option<&mut ScriptTask>) -> OpaqueScriptLayoutChannel {
|
||||
impl ScriptThreadFactory for ScriptThread {
|
||||
fn create_layout_channel(_phantom: Option<&mut ScriptThread>) -> OpaqueScriptLayoutChannel {
|
||||
let (chan, port) = channel();
|
||||
ScriptLayoutChan::new(chan, port)
|
||||
}
|
||||
|
||||
fn clone_layout_channel(_phantom: Option<&mut ScriptTask>, pair: &OpaqueScriptLayoutChannel)
|
||||
fn clone_layout_channel(_phantom: Option<&mut ScriptThread>, pair: &OpaqueScriptLayoutChannel)
|
||||
-> Box<Any + Send> {
|
||||
box pair.sender() as Box<Any + Send>
|
||||
}
|
||||
|
||||
fn create(_phantom: Option<&mut ScriptTask>,
|
||||
fn create(_phantom: Option<&mut ScriptThread>,
|
||||
state: InitialScriptState,
|
||||
layout_chan: &OpaqueScriptLayoutChannel,
|
||||
load_data: LoadData) {
|
||||
@ -608,8 +608,8 @@ impl ScriptTaskFactory for ScriptTask {
|
||||
let (script_chan, script_port) = channel();
|
||||
let layout_chan = LayoutChan(layout_chan.sender());
|
||||
let failure_info = state.failure_info;
|
||||
task::spawn_named_with_send_on_failure(format!("ScriptTask {:?}", state.id),
|
||||
task_state::SCRIPT,
|
||||
thread::spawn_named_with_send_on_failure(format!("ScriptThread {:?}", state.id),
|
||||
thread_state::SCRIPT,
|
||||
move || {
|
||||
PipelineNamespace::install(state.pipeline_namespace_id);
|
||||
let roots = RootCollection::new();
|
||||
@ -620,27 +620,27 @@ impl ScriptTaskFactory for ScriptTask {
|
||||
let parent_info = state.parent_info;
|
||||
let mem_profiler_chan = state.mem_profiler_chan.clone();
|
||||
let window_size = state.window_size;
|
||||
let script_task = ScriptTask::new(state,
|
||||
let script_thread = ScriptThread::new(state,
|
||||
script_port,
|
||||
script_chan);
|
||||
|
||||
SCRIPT_TASK_ROOT.with(|root| {
|
||||
*root.borrow_mut() = Some(&script_task as *const _);
|
||||
*root.borrow_mut() = Some(&script_thread as *const _);
|
||||
});
|
||||
|
||||
let mut failsafe = ScriptMemoryFailsafe::new(&script_task);
|
||||
let mut failsafe = ScriptMemoryFailsafe::new(&script_thread);
|
||||
|
||||
let new_load = InProgressLoad::new(id, parent_info, layout_chan, window_size,
|
||||
load_data.url.clone());
|
||||
script_task.start_page_load(new_load, load_data);
|
||||
script_thread.start_page_load(new_load, load_data);
|
||||
|
||||
let reporter_name = format!("script-reporter-{}", id);
|
||||
mem_profiler_chan.run_with_memory_reporting(|| {
|
||||
script_task.start();
|
||||
let _ = script_task.content_process_shutdown_chan.send(());
|
||||
script_thread.start();
|
||||
let _ = script_thread.content_process_shutdown_chan.send(());
|
||||
}, reporter_name, channel_for_reporter, CommonScriptMsg::CollectReports);
|
||||
|
||||
// This must always be the very last operation performed before the task completes
|
||||
// This must always be the very last operation performed before the thread completes
|
||||
failsafe.neuter();
|
||||
}, ConstellationMsg::Failure(failure_info), const_chan);
|
||||
}
|
||||
@ -691,8 +691,8 @@ unsafe extern "C" fn gc_slice_callback(_rt: *mut JSRuntime, progress: GCProgress
|
||||
|
||||
unsafe extern "C" fn debug_gc_callback(_rt: *mut JSRuntime, status: JSGCStatus, _data: *mut libc::c_void) {
|
||||
match status {
|
||||
JSGCStatus::JSGC_BEGIN => task_state::enter(task_state::IN_GC),
|
||||
JSGCStatus::JSGC_END => task_state::exit(task_state::IN_GC),
|
||||
JSGCStatus::JSGC_BEGIN => thread_state::enter(thread_state::IN_GC),
|
||||
JSGCStatus::JSGC_END => thread_state::exit(thread_state::IN_GC),
|
||||
}
|
||||
}
|
||||
|
||||
@ -710,37 +710,37 @@ pub struct CSSError {
|
||||
msg: String
|
||||
}
|
||||
|
||||
impl ScriptTask {
|
||||
impl ScriptThread {
|
||||
pub fn page_fetch_complete(id: PipelineId, subpage: Option<SubpageId>, metadata: Metadata)
|
||||
-> Option<ParserRoot> {
|
||||
SCRIPT_TASK_ROOT.with(|root| {
|
||||
let script_task = unsafe { &*root.borrow().unwrap() };
|
||||
script_task.handle_page_fetch_complete(id, subpage, metadata)
|
||||
let script_thread = unsafe { &*root.borrow().unwrap() };
|
||||
script_thread.handle_page_fetch_complete(id, subpage, metadata)
|
||||
})
|
||||
}
|
||||
|
||||
pub fn parsing_complete(id: PipelineId) {
|
||||
SCRIPT_TASK_ROOT.with(|root| {
|
||||
let script_task = unsafe { &*root.borrow().unwrap() };
|
||||
script_task.handle_parsing_complete(id);
|
||||
let script_thread = unsafe { &*root.borrow().unwrap() };
|
||||
script_thread.handle_parsing_complete(id);
|
||||
});
|
||||
}
|
||||
|
||||
pub fn process_event(msg: CommonScriptMsg) {
|
||||
SCRIPT_TASK_ROOT.with(|root| {
|
||||
if let Some(script_task) = *root.borrow() {
|
||||
let script_task = unsafe { &*script_task };
|
||||
script_task.handle_msg_from_script(MainThreadScriptMsg::Common(msg));
|
||||
if let Some(script_thread) = *root.borrow() {
|
||||
let script_thread = unsafe { &*script_thread };
|
||||
script_thread.handle_msg_from_script(MainThreadScriptMsg::Common(msg));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// Creates a new script task.
|
||||
/// Creates a new script thread.
|
||||
pub fn new(state: InitialScriptState,
|
||||
port: Receiver<MainThreadScriptMsg>,
|
||||
chan: Sender<MainThreadScriptMsg>)
|
||||
-> ScriptTask {
|
||||
let runtime = ScriptTask::new_rt_and_cx();
|
||||
-> ScriptThread {
|
||||
let runtime = ScriptThread::new_rt_and_cx();
|
||||
|
||||
unsafe {
|
||||
JS_SetWrapObjectCallbacks(runtime.rt(),
|
||||
@ -751,7 +751,7 @@ impl ScriptTask {
|
||||
let (ipc_devtools_sender, ipc_devtools_receiver) = ipc::channel().unwrap();
|
||||
let devtools_port = ROUTER.route_ipc_receiver_to_new_mpsc_receiver(ipc_devtools_receiver);
|
||||
|
||||
// Ask the router to proxy IPC messages from the image cache task to us.
|
||||
// Ask the router to proxy IPC messages from the image cache thread to us.
|
||||
let (ipc_image_cache_channel, ipc_image_cache_port) = ipc::channel().unwrap();
|
||||
let image_cache_port =
|
||||
ROUTER.route_ipc_receiver_to_new_mpsc_receiver(ipc_image_cache_port);
|
||||
@ -761,24 +761,24 @@ impl ScriptTask {
|
||||
// Ask the router to proxy IPC messages from the control port to us.
|
||||
let control_port = ROUTER.route_ipc_receiver_to_new_mpsc_receiver(state.control_port);
|
||||
|
||||
ScriptTask {
|
||||
ScriptThread {
|
||||
page: DOMRefCell::new(None),
|
||||
incomplete_loads: DOMRefCell::new(vec!()),
|
||||
|
||||
image_cache_task: state.image_cache_task,
|
||||
image_cache_thread: state.image_cache_thread,
|
||||
image_cache_channel: ImageCacheChan(ipc_image_cache_channel),
|
||||
image_cache_port: image_cache_port,
|
||||
|
||||
resource_task: Arc::new(state.resource_task),
|
||||
storage_task: state.storage_task,
|
||||
resource_thread: Arc::new(state.resource_thread),
|
||||
storage_thread: state.storage_thread,
|
||||
|
||||
port: port,
|
||||
chan: MainThreadScriptChan(chan.clone()),
|
||||
dom_manipulation_task_source: DOMManipulationTaskSource(chan.clone()),
|
||||
user_interaction_task_source: UserInteractionTaskSource(chan.clone()),
|
||||
networking_task_source: NetworkingTaskSource(chan.clone()),
|
||||
history_traversal_task_source: HistoryTraversalTaskSource(chan.clone()),
|
||||
file_reading_task_source: FileReadingTaskSource(chan),
|
||||
dom_manipulation_thread_source: DOMManipulationThreadSource(chan.clone()),
|
||||
user_interaction_thread_source: UserInteractionThreadSource(chan.clone()),
|
||||
networking_thread_source: NetworkingThreadSource(chan.clone()),
|
||||
history_traversal_thread_source: HistoryTraversalThreadSource(chan.clone()),
|
||||
file_reading_thread_source: FileReadingThreadSource(chan),
|
||||
|
||||
control_chan: state.control_chan,
|
||||
control_port: control_port,
|
||||
@ -851,7 +851,7 @@ impl ScriptTask {
|
||||
self.js_runtime.cx()
|
||||
}
|
||||
|
||||
/// Starts the script task. After calling this method, the script task will loop receiving
|
||||
/// Starts the script thread. After calling this method, the script thread will loop receiving
|
||||
/// messages on its port.
|
||||
pub fn start(&self) {
|
||||
while self.handle_msgs() {
|
||||
@ -932,17 +932,17 @@ impl ScriptTask {
|
||||
// child list yet, causing the find() to fail.
|
||||
FromConstellation(ConstellationControlMsg::AttachLayout(
|
||||
new_layout_info)) => {
|
||||
self.profile_event(ScriptTaskEventCategory::AttachLayout, || {
|
||||
self.profile_event(ScriptThreadEventCategory::AttachLayout, || {
|
||||
self.handle_new_layout(new_layout_info);
|
||||
})
|
||||
}
|
||||
FromConstellation(ConstellationControlMsg::Resize(id, size)) => {
|
||||
self.profile_event(ScriptTaskEventCategory::Resize, || {
|
||||
self.profile_event(ScriptThreadEventCategory::Resize, || {
|
||||
self.handle_resize(id, size);
|
||||
})
|
||||
}
|
||||
FromConstellation(ConstellationControlMsg::Viewport(id, rect)) => {
|
||||
self.profile_event(ScriptTaskEventCategory::SetViewport, || {
|
||||
self.profile_event(ScriptThreadEventCategory::SetViewport, || {
|
||||
self.handle_viewport(id, rect);
|
||||
})
|
||||
}
|
||||
@ -1037,52 +1037,52 @@ impl ScriptTask {
|
||||
true
|
||||
}
|
||||
|
||||
fn categorize_msg(&self, msg: &MixedMessage) -> ScriptTaskEventCategory {
|
||||
fn categorize_msg(&self, msg: &MixedMessage) -> ScriptThreadEventCategory {
|
||||
match *msg {
|
||||
MixedMessage::FromConstellation(ref inner_msg) => {
|
||||
match *inner_msg {
|
||||
ConstellationControlMsg::SendEvent(_, _) =>
|
||||
ScriptTaskEventCategory::DomEvent,
|
||||
_ => ScriptTaskEventCategory::ConstellationMsg
|
||||
ScriptThreadEventCategory::DomEvent,
|
||||
_ => ScriptThreadEventCategory::ConstellationMsg
|
||||
}
|
||||
},
|
||||
MixedMessage::FromDevtools(_) => ScriptTaskEventCategory::DevtoolsMsg,
|
||||
MixedMessage::FromImageCache(_) => ScriptTaskEventCategory::ImageCacheMsg,
|
||||
MixedMessage::FromDevtools(_) => ScriptThreadEventCategory::DevtoolsMsg,
|
||||
MixedMessage::FromImageCache(_) => ScriptThreadEventCategory::ImageCacheMsg,
|
||||
MixedMessage::FromScript(ref inner_msg) => {
|
||||
match *inner_msg {
|
||||
MainThreadScriptMsg::Common(CommonScriptMsg::RunnableMsg(ref category, _)) =>
|
||||
*category,
|
||||
_ => ScriptTaskEventCategory::ScriptEvent
|
||||
_ => ScriptThreadEventCategory::ScriptEvent
|
||||
}
|
||||
},
|
||||
MixedMessage::FromScheduler(_) => ScriptTaskEventCategory::TimerEvent,
|
||||
MixedMessage::FromScheduler(_) => ScriptThreadEventCategory::TimerEvent,
|
||||
}
|
||||
}
|
||||
|
||||
fn profile_event<F, R>(&self, category: ScriptTaskEventCategory, f: F) -> R
|
||||
fn profile_event<F, R>(&self, category: ScriptThreadEventCategory, f: F) -> R
|
||||
where F: FnOnce() -> R {
|
||||
|
||||
if opts::get().profile_script_events {
|
||||
let profiler_cat = match category {
|
||||
ScriptTaskEventCategory::AttachLayout => ProfilerCategory::ScriptAttachLayout,
|
||||
ScriptTaskEventCategory::ConstellationMsg => ProfilerCategory::ScriptConstellationMsg,
|
||||
ScriptTaskEventCategory::DevtoolsMsg => ProfilerCategory::ScriptDevtoolsMsg,
|
||||
ScriptTaskEventCategory::DocumentEvent => ProfilerCategory::ScriptDocumentEvent,
|
||||
ScriptTaskEventCategory::DomEvent => ProfilerCategory::ScriptDomEvent,
|
||||
ScriptTaskEventCategory::FileRead => ProfilerCategory::ScriptFileRead,
|
||||
ScriptTaskEventCategory::ImageCacheMsg => ProfilerCategory::ScriptImageCacheMsg,
|
||||
ScriptTaskEventCategory::InputEvent => ProfilerCategory::ScriptInputEvent,
|
||||
ScriptTaskEventCategory::NetworkEvent => ProfilerCategory::ScriptNetworkEvent,
|
||||
ScriptTaskEventCategory::Resize => ProfilerCategory::ScriptResize,
|
||||
ScriptTaskEventCategory::ScriptEvent => ProfilerCategory::ScriptEvent,
|
||||
ScriptTaskEventCategory::UpdateReplacedElement => {
|
||||
ScriptThreadEventCategory::AttachLayout => ProfilerCategory::ScriptAttachLayout,
|
||||
ScriptThreadEventCategory::ConstellationMsg => ProfilerCategory::ScriptConstellationMsg,
|
||||
ScriptThreadEventCategory::DevtoolsMsg => ProfilerCategory::ScriptDevtoolsMsg,
|
||||
ScriptThreadEventCategory::DocumentEvent => ProfilerCategory::ScriptDocumentEvent,
|
||||
ScriptThreadEventCategory::DomEvent => ProfilerCategory::ScriptDomEvent,
|
||||
ScriptThreadEventCategory::FileRead => ProfilerCategory::ScriptFileRead,
|
||||
ScriptThreadEventCategory::ImageCacheMsg => ProfilerCategory::ScriptImageCacheMsg,
|
||||
ScriptThreadEventCategory::InputEvent => ProfilerCategory::ScriptInputEvent,
|
||||
ScriptThreadEventCategory::NetworkEvent => ProfilerCategory::ScriptNetworkEvent,
|
||||
ScriptThreadEventCategory::Resize => ProfilerCategory::ScriptResize,
|
||||
ScriptThreadEventCategory::ScriptEvent => ProfilerCategory::ScriptEvent,
|
||||
ScriptThreadEventCategory::UpdateReplacedElement => {
|
||||
ProfilerCategory::ScriptUpdateReplacedElement
|
||||
}
|
||||
ScriptTaskEventCategory::StylesheetLoad => ProfilerCategory::ScriptStylesheetLoad,
|
||||
ScriptTaskEventCategory::SetViewport => ProfilerCategory::ScriptSetViewport,
|
||||
ScriptTaskEventCategory::TimerEvent => ProfilerCategory::ScriptTimerEvent,
|
||||
ScriptTaskEventCategory::WebSocketEvent => ProfilerCategory::ScriptWebSocketEvent,
|
||||
ScriptTaskEventCategory::WorkerEvent => ProfilerCategory::ScriptWorkerEvent,
|
||||
ScriptThreadEventCategory::StylesheetLoad => ProfilerCategory::ScriptStylesheetLoad,
|
||||
ScriptThreadEventCategory::SetViewport => ProfilerCategory::ScriptSetViewport,
|
||||
ScriptThreadEventCategory::TimerEvent => ProfilerCategory::ScriptTimerEvent,
|
||||
ScriptThreadEventCategory::WebSocketEvent => ProfilerCategory::ScriptWebSocketEvent,
|
||||
ScriptThreadEventCategory::WorkerEvent => ProfilerCategory::ScriptWorkerEvent,
|
||||
};
|
||||
profile(profiler_cat, None, self.time_profiler_chan.clone(), f)
|
||||
} else {
|
||||
@ -1167,12 +1167,12 @@ impl ScriptTask {
|
||||
|
||||
let pipeline_id = match source {
|
||||
TimerSource::FromWindow(pipeline_id) => pipeline_id,
|
||||
TimerSource::FromWorker => panic!("Worker timeouts must not be sent to script task"),
|
||||
TimerSource::FromWorker => panic!("Worker timeouts must not be sent to script thread"),
|
||||
};
|
||||
|
||||
let page = self.root_page();
|
||||
let page = page.find(pipeline_id).expect("ScriptTask: received fire timer msg for a
|
||||
pipeline ID not associated with this script task. This is a bug.");
|
||||
let page = page.find(pipeline_id).expect("ScriptThread: received fire timer msg for a
|
||||
pipeline ID not associated with this script thread. This is a bug.");
|
||||
let window = page.window();
|
||||
|
||||
window.handle_fire_timer(id);
|
||||
@ -1301,12 +1301,12 @@ impl ScriptTask {
|
||||
content_process_shutdown_chan,
|
||||
} = new_layout_info;
|
||||
|
||||
let layout_pair = ScriptTask::create_layout_channel(None::<&mut ScriptTask>);
|
||||
let layout_chan = LayoutChan(*ScriptTask::clone_layout_channel(
|
||||
None::<&mut ScriptTask>,
|
||||
let layout_pair = ScriptThread::create_layout_channel(None::<&mut ScriptThread>);
|
||||
let layout_chan = LayoutChan(*ScriptThread::clone_layout_channel(
|
||||
None::<&mut ScriptThread>,
|
||||
&layout_pair).downcast::<Sender<layout_interface::Msg>>().unwrap());
|
||||
|
||||
let layout_creation_info = NewLayoutTaskInfo {
|
||||
let layout_creation_info = NewLayoutThreadInfo {
|
||||
id: new_pipeline_id,
|
||||
url: load_data.url.clone(),
|
||||
is_parent: false,
|
||||
@ -1316,21 +1316,21 @@ impl ScriptTask {
|
||||
failure: failure,
|
||||
paint_chan: paint_chan,
|
||||
script_chan: self.control_chan.clone(),
|
||||
image_cache_task: self.image_cache_task.clone(),
|
||||
image_cache_thread: self.image_cache_thread.clone(),
|
||||
layout_shutdown_chan: layout_shutdown_chan,
|
||||
content_process_shutdown_chan: content_process_shutdown_chan,
|
||||
};
|
||||
|
||||
let page = self.root_page();
|
||||
let parent_page = page.find(containing_pipeline_id).expect("ScriptTask: received a layout
|
||||
let parent_page = page.find(containing_pipeline_id).expect("ScriptThread: received a layout
|
||||
whose parent has a PipelineId which does not correspond to a pipeline in the script
|
||||
task's page tree. This is a bug.");
|
||||
thread's page tree. This is a bug.");
|
||||
let parent_window = parent_page.window();
|
||||
|
||||
// Tell layout to actually spawn the task.
|
||||
// Tell layout to actually spawn the thread.
|
||||
parent_window.layout_chan()
|
||||
.0
|
||||
.send(layout_interface::Msg::CreateLayoutTask(layout_creation_info))
|
||||
.send(layout_interface::Msg::CreateLayoutThread(layout_creation_info))
|
||||
.unwrap();
|
||||
|
||||
// Kick off the fetch for the new resource.
|
||||
@ -1353,7 +1353,7 @@ impl ScriptTask {
|
||||
// https://html.spec.whatwg.org/multipage/#the-end step 7
|
||||
let addr: Trusted<Document> = Trusted::new(doc, self.chan.clone());
|
||||
let handler = box DocumentProgressHandler::new(addr.clone());
|
||||
self.chan.send(CommonScriptMsg::RunnableMsg(ScriptTaskEventCategory::DocumentEvent, handler)).unwrap();
|
||||
self.chan.send(CommonScriptMsg::RunnableMsg(ScriptThreadEventCategory::DocumentEvent, handler)).unwrap();
|
||||
|
||||
let ConstellationChan(ref chan) = self.constellation_chan;
|
||||
chan.send(ConstellationMsg::LoadComplete(pipeline)).unwrap();
|
||||
@ -1433,7 +1433,7 @@ impl ScriptTask {
|
||||
}
|
||||
}
|
||||
let path_seg = format!("url({})", urls.join(", "));
|
||||
reports.extend(ScriptTask::get_reports(self.get_cx(), path_seg));
|
||||
reports.extend(ScriptThread::get_reports(self.get_cx(), path_seg));
|
||||
reports_chan.send(reports);
|
||||
}
|
||||
|
||||
@ -1532,12 +1532,12 @@ impl ScriptTask {
|
||||
}
|
||||
|
||||
/// We have gotten a window.close from script, which we pass on to the compositor.
|
||||
/// We do not shut down the script task now, because the compositor will ask the
|
||||
/// We do not shut down the script thread now, because the compositor will ask the
|
||||
/// constellation to shut down the pipeline, which will clean everything up
|
||||
/// normally. If we do exit, we will tear down the DOM nodes, possibly at a point
|
||||
/// where layout is still accessing them.
|
||||
fn handle_exit_window_msg(&self, _: PipelineId) {
|
||||
debug!("script task handling exit window msg");
|
||||
debug!("script thread handling exit window msg");
|
||||
|
||||
// TODO(tkuehn): currently there is only one window,
|
||||
// so this can afford to be naive and just shut down the
|
||||
@ -1573,8 +1573,8 @@ impl ScriptTask {
|
||||
document.send_title_to_compositor();
|
||||
}
|
||||
|
||||
/// Handles a request to exit the script task and shut down layout.
|
||||
/// Returns true if the script task should shut down and false otherwise.
|
||||
/// Handles a request to exit the script thread and shut down layout.
|
||||
/// Returns true if the script thread should shut down and false otherwise.
|
||||
fn handle_exit_pipeline_msg(&self, id: PipelineId) -> bool {
|
||||
self.closed_pipelines.borrow_mut().insert(id);
|
||||
|
||||
@ -1586,7 +1586,7 @@ impl ScriptTask {
|
||||
if let Some(idx) = idx {
|
||||
let load = self.incomplete_loads.borrow_mut().remove(idx);
|
||||
|
||||
// Tell the layout task to begin shutting down, and wait until it
|
||||
// Tell the layout thread to begin shutting down, and wait until it
|
||||
// processed this message.
|
||||
let (response_chan, response_port) = channel();
|
||||
let LayoutChan(chan) = load.layout_chan;
|
||||
@ -1619,7 +1619,7 @@ impl ScriptTask {
|
||||
false
|
||||
}
|
||||
|
||||
/// Handles when layout task finishes all animation in one tick
|
||||
/// Handles when layout thread finishes all animation in one tick
|
||||
fn handle_tick_all_animations(&self, id: PipelineId) {
|
||||
let page = get_page(&self.root_page(), id);
|
||||
let document = page.document();
|
||||
@ -1647,7 +1647,7 @@ impl ScriptTask {
|
||||
fn load(&self, metadata: Metadata, incomplete: InProgressLoad) -> ParserRoot {
|
||||
let final_url = metadata.final_url.clone();
|
||||
{
|
||||
// send the final url to the layout task.
|
||||
// send the final url to the layout thread.
|
||||
let LayoutChan(ref chan) = incomplete.layout_chan;
|
||||
chan.send(layout_interface::Msg::SetFinalUrl(final_url.clone())).unwrap();
|
||||
|
||||
@ -1655,7 +1655,7 @@ impl ScriptTask {
|
||||
let ConstellationChan(ref chan) = self.constellation_chan;
|
||||
chan.send(ConstellationMsg::SetFinalUrl(incomplete.pipeline_id, final_url.clone())).unwrap();
|
||||
}
|
||||
debug!("ScriptTask: loading {} on page {:?}", incomplete.url.serialize(), incomplete.pipeline_id);
|
||||
debug!("ScriptThread: loading {} on page {:?}", incomplete.url.serialize(), incomplete.pipeline_id);
|
||||
|
||||
// We should either be initializing a root page or loading a child page of an
|
||||
// existing one.
|
||||
@ -1663,12 +1663,12 @@ impl ScriptTask {
|
||||
|
||||
let frame_element = incomplete.parent_info.and_then(|(parent_id, subpage_id)| {
|
||||
// The root page may not exist yet, if the parent of this frame
|
||||
// exists in a different script task.
|
||||
// exists in a different script thread.
|
||||
let borrowed_page = self.page.borrow();
|
||||
|
||||
// In the case a parent id exists but the matching page
|
||||
// cannot be found, this means the page exists in a different
|
||||
// script task (due to origin) so it shouldn't be returned.
|
||||
// script thread (due to origin) so it shouldn't be returned.
|
||||
// TODO: window.parent will continue to return self in that
|
||||
// case, which is wrong. We should be returning an object that
|
||||
// denies access to most properties (per
|
||||
@ -1689,7 +1689,7 @@ impl ScriptTask {
|
||||
} else if let Some((parent, _)) = incomplete.parent_info {
|
||||
// We have a new child frame.
|
||||
let parent_page = self.root_page();
|
||||
// TODO(gw): This find will fail when we are sharing script tasks
|
||||
// TODO(gw): This find will fail when we are sharing script threads
|
||||
// between cross origin iframes in the same TLD.
|
||||
let parent_page = parent_page.find(parent)
|
||||
.expect("received load for subpage with missing parent");
|
||||
@ -1702,14 +1702,14 @@ impl ScriptTask {
|
||||
}
|
||||
struct AutoPageRemover<'a> {
|
||||
page: PageToRemove,
|
||||
script_task: &'a ScriptTask,
|
||||
script_thread: &'a ScriptThread,
|
||||
neutered: bool,
|
||||
}
|
||||
impl<'a> AutoPageRemover<'a> {
|
||||
fn new(script_task: &'a ScriptTask, page: PageToRemove) -> AutoPageRemover<'a> {
|
||||
fn new(script_thread: &'a ScriptThread, page: PageToRemove) -> AutoPageRemover<'a> {
|
||||
AutoPageRemover {
|
||||
page: page,
|
||||
script_task: script_task,
|
||||
script_thread: script_thread,
|
||||
neutered: false,
|
||||
}
|
||||
}
|
||||
@ -1722,9 +1722,9 @@ impl ScriptTask {
|
||||
fn drop(&mut self) {
|
||||
if !self.neutered {
|
||||
match self.page {
|
||||
PageToRemove::Root => *self.script_task.page.borrow_mut() = None,
|
||||
PageToRemove::Root => *self.script_thread.page.borrow_mut() = None,
|
||||
PageToRemove::Child(id) => {
|
||||
self.script_task.root_page().remove(id).unwrap();
|
||||
self.script_thread.root_page().remove(id).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1738,11 +1738,11 @@ impl ScriptTask {
|
||||
};
|
||||
let mut page_remover = AutoPageRemover::new(self, page_to_remove);
|
||||
let MainThreadScriptChan(ref sender) = self.chan;
|
||||
let DOMManipulationTaskSource(ref dom_sender) = self.dom_manipulation_task_source;
|
||||
let UserInteractionTaskSource(ref user_sender) = self.user_interaction_task_source;
|
||||
let NetworkingTaskSource(ref network_sender) = self.networking_task_source;
|
||||
let HistoryTraversalTaskSource(ref history_sender) = self.history_traversal_task_source;
|
||||
let FileReadingTaskSource(ref file_sender) = self.file_reading_task_source;
|
||||
let DOMManipulationThreadSource(ref dom_sender) = self.dom_manipulation_thread_source;
|
||||
let UserInteractionThreadSource(ref user_sender) = self.user_interaction_thread_source;
|
||||
let NetworkingThreadSource(ref network_sender) = self.networking_thread_source;
|
||||
let HistoryTraversalThreadSource(ref history_sender) = self.history_traversal_thread_source;
|
||||
let FileReadingThreadSource(ref file_sender) = self.file_reading_thread_source;
|
||||
|
||||
let (ipc_timer_event_chan, ipc_timer_event_port) = ipc::channel().unwrap();
|
||||
ROUTER.route_ipc_receiver_to_mpsc_sender(ipc_timer_event_port,
|
||||
@ -1752,16 +1752,16 @@ impl ScriptTask {
|
||||
let window = Window::new(self.js_runtime.clone(),
|
||||
page.clone(),
|
||||
MainThreadScriptChan(sender.clone()),
|
||||
DOMManipulationTaskSource(dom_sender.clone()),
|
||||
UserInteractionTaskSource(user_sender.clone()),
|
||||
NetworkingTaskSource(network_sender.clone()),
|
||||
HistoryTraversalTaskSource(history_sender.clone()),
|
||||
FileReadingTaskSource(file_sender.clone()),
|
||||
DOMManipulationThreadSource(dom_sender.clone()),
|
||||
UserInteractionThreadSource(user_sender.clone()),
|
||||
NetworkingThreadSource(network_sender.clone()),
|
||||
HistoryTraversalThreadSource(history_sender.clone()),
|
||||
FileReadingThreadSource(file_sender.clone()),
|
||||
self.image_cache_channel.clone(),
|
||||
self.compositor.borrow_mut().clone(),
|
||||
self.image_cache_task.clone(),
|
||||
self.resource_task.clone(),
|
||||
self.storage_task.clone(),
|
||||
self.image_cache_thread.clone(),
|
||||
self.resource_thread.clone(),
|
||||
self.storage_thread.clone(),
|
||||
self.mem_profiler_chan.clone(),
|
||||
self.devtools_chan.clone(),
|
||||
self.constellation_chan.clone(),
|
||||
@ -1788,7 +1788,7 @@ impl ScriptTask {
|
||||
_ => None
|
||||
};
|
||||
|
||||
let loader = DocumentLoader::new_with_task(self.resource_task.clone(),
|
||||
let loader = DocumentLoader::new_with_thread(self.resource_thread.clone(),
|
||||
Some(page.pipeline()),
|
||||
Some(incomplete.url.clone()));
|
||||
|
||||
@ -1903,7 +1903,7 @@ impl ScriptTask {
|
||||
let rect = element.upcast::<Node>().get_bounding_content_box();
|
||||
|
||||
// In order to align with element edges, we snap to unscaled pixel boundaries, since the
|
||||
// paint task currently does the same for drawing elements. This is important for pages
|
||||
// paint thread currently does the same for drawing elements. This is important for pages
|
||||
// that require pixel perfect scroll positioning for proper display (like Acid2). Since we
|
||||
// don't have the device pixel ratio here, this might not be accurate, but should work as
|
||||
// long as the ratio is a whole number. Once #8275 is fixed this should actually take into
|
||||
@ -2107,7 +2107,7 @@ impl ScriptTask {
|
||||
let subpage = incomplete.parent_info.clone().map(|p| p.1);
|
||||
|
||||
let script_chan = self.chan.clone();
|
||||
let resource_task = self.resource_task.clone();
|
||||
let resource_thread = self.resource_thread.clone();
|
||||
|
||||
let context = Arc::new(Mutex::new(ParserContext::new(id, subpage, script_chan.clone(),
|
||||
load_data.url.clone())));
|
||||
@ -2127,7 +2127,7 @@ impl ScriptTask {
|
||||
load_data.url = url!("about:blank");
|
||||
}
|
||||
|
||||
resource_task.send(ControlMsg::Load(NetLoadData {
|
||||
resource_thread.send(ControlMsg::Load(NetLoadData {
|
||||
context: LoadContext::Browsing,
|
||||
url: load_data.url,
|
||||
method: load_data.method,
|
||||
@ -2198,7 +2198,7 @@ impl ScriptTask {
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for ScriptTask {
|
||||
impl Drop for ScriptThread {
|
||||
fn drop(&mut self) {
|
||||
SCRIPT_TASK_ROOT.with(|root| {
|
||||
*root.borrow_mut() = None;
|
||||
@ -2211,7 +2211,7 @@ fn shut_down_layout(page_tree: &Rc<Page>) {
|
||||
let mut channels = vec!();
|
||||
|
||||
for page in page_tree.iter() {
|
||||
// Tell the layout task to begin shutting down, and wait until it
|
||||
// Tell the layout thread to begin shutting down, and wait until it
|
||||
// processed this message.
|
||||
let (response_chan, response_port) = channel();
|
||||
let window = page.window();
|
||||
@ -2230,15 +2230,15 @@ fn shut_down_layout(page_tree: &Rc<Page>) {
|
||||
page.set_frame(None);
|
||||
}
|
||||
|
||||
// Destroy the layout task. If there were node leaks, layout will now crash safely.
|
||||
// Destroy the layout thread. If there were node leaks, layout will now crash safely.
|
||||
for chan in channels {
|
||||
chan.send(layout_interface::Msg::ExitNow).ok();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_page(page: &Rc<Page>, pipeline_id: PipelineId) -> Rc<Page> {
|
||||
page.find(pipeline_id).expect("ScriptTask: received an event \
|
||||
message for a layout channel that is not associated with this script task.\
|
||||
page.find(pipeline_id).expect("ScriptThread: received an event \
|
||||
message for a layout channel that is not associated with this script thread.\
|
||||
This is a bug.")
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ pub struct ActiveTimers {
|
||||
/// - a timer was added with an earlier callback time. In this case the
|
||||
/// original timer is rescheduled when it is the next one to get called.
|
||||
expected_event_id: Cell<TimerEventId>,
|
||||
/// The nesting level of the currently executing timer task or 0.
|
||||
/// The nesting level of the currently executing timer thread or 0.
|
||||
nesting_level: Cell<u32>,
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ use js::jsval::UndefinedValue;
|
||||
use msg::constellation_msg::{PipelineId, WindowSizeData};
|
||||
use msg::webdriver_msg::{WebDriverFrameId, WebDriverJSError, WebDriverJSResult, WebDriverJSValue};
|
||||
use page::Page;
|
||||
use script_task::get_page;
|
||||
use script_thread::get_page;
|
||||
use std::rc::Rc;
|
||||
use url::Url;
|
||||
use util::str::DOMString;
|
||||
|
@ -44,9 +44,9 @@ use msg::constellation_msg::{Key, KeyModifiers, KeyState, LoadData, SubpageId};
|
||||
use msg::constellation_msg::{MouseButton, MouseEventType};
|
||||
use msg::constellation_msg::{MozBrowserEvent, PipelineNamespaceId};
|
||||
use msg::webdriver_msg::WebDriverScriptCommand;
|
||||
use net_traits::ResourceTask;
|
||||
use net_traits::image_cache_task::ImageCacheTask;
|
||||
use net_traits::storage_task::StorageTask;
|
||||
use net_traits::ResourceThread;
|
||||
use net_traits::image_cache_thread::ImageCacheThread;
|
||||
use net_traits::storage_thread::StorageThread;
|
||||
use profile_traits::mem;
|
||||
use std::any::Any;
|
||||
use util::ipc::OptionalOpaqueIpcSender;
|
||||
@ -60,10 +60,10 @@ pub use script_msg::{LayoutMsg, ScriptMsg};
|
||||
pub struct UntrustedNodeAddress(pub *const c_void);
|
||||
unsafe impl Send for UntrustedNodeAddress {}
|
||||
|
||||
/// Messages sent to the layout task from the constellation and/or compositor.
|
||||
/// Messages sent to the layout thread from the constellation and/or compositor.
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub enum LayoutControlMsg {
|
||||
/// Requests that this layout task exit.
|
||||
/// Requests that this layout thread exit.
|
||||
ExitNow,
|
||||
/// Requests the current epoch (layout counter) from this layout.
|
||||
GetCurrentEpoch(IpcSender<Epoch>),
|
||||
@ -85,12 +85,12 @@ pub struct NewLayoutInfo {
|
||||
pub new_pipeline_id: PipelineId,
|
||||
/// Id of the new frame associated with this pipeline.
|
||||
pub subpage_id: SubpageId,
|
||||
/// Network request data which will be initiated by the script task.
|
||||
/// Network request data which will be initiated by the script thread.
|
||||
pub load_data: LoadData,
|
||||
/// The paint channel, cast to `OptionalOpaqueIpcSender`. This is really an
|
||||
/// `Sender<LayoutToPaintMsg>`.
|
||||
pub paint_chan: OptionalOpaqueIpcSender,
|
||||
/// Information on what to do on task failure.
|
||||
/// Information on what to do on thread failure.
|
||||
pub failure: Failure,
|
||||
/// A port on which layout can receive messages from the pipeline.
|
||||
pub pipeline_port: IpcReceiver<LayoutControlMsg>,
|
||||
@ -100,10 +100,10 @@ pub struct NewLayoutInfo {
|
||||
pub content_process_shutdown_chan: IpcSender<()>,
|
||||
}
|
||||
|
||||
/// Messages sent from the constellation or layout to the script task.
|
||||
/// Messages sent from the constellation or layout to the script thread.
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub enum ConstellationControlMsg {
|
||||
/// Gives a channel and ID to a layout task, as well as the ID of that layout's parent
|
||||
/// Gives a channel and ID to a layout thread, as well as the ID of that layout's parent
|
||||
AttachLayout(NewLayoutInfo),
|
||||
/// Window resized. Sends a DOM event eventually, but first we combine events.
|
||||
Resize(PipelineId, WindowSizeData),
|
||||
@ -115,25 +115,25 @@ pub enum ConstellationControlMsg {
|
||||
SendEvent(PipelineId, CompositorEvent),
|
||||
/// Notifies script of the viewport.
|
||||
Viewport(PipelineId, Rect<f32>),
|
||||
/// Requests that the script task immediately send the constellation the title of a pipeline.
|
||||
/// Requests that the script thread immediately send the constellation the title of a pipeline.
|
||||
GetTitle(PipelineId),
|
||||
/// Notifies script task to suspend all its timers
|
||||
/// Notifies script thread to suspend all its timers
|
||||
Freeze(PipelineId),
|
||||
/// Notifies script task to resume all its timers
|
||||
/// Notifies script thread to resume all its timers
|
||||
Thaw(PipelineId),
|
||||
/// Notifies script task that a url should be loaded in this iframe.
|
||||
/// Notifies script thread that a url should be loaded in this iframe.
|
||||
Navigate(PipelineId, SubpageId, LoadData),
|
||||
/// Requests the script task forward a mozbrowser event to an iframe it owns
|
||||
/// Requests the script thread forward a mozbrowser event to an iframe it owns
|
||||
MozBrowserEvent(PipelineId, SubpageId, MozBrowserEvent),
|
||||
/// Updates the current subpage id of a given iframe
|
||||
UpdateSubpageId(PipelineId, SubpageId, SubpageId),
|
||||
/// Set an iframe to be focused. Used when an element in an iframe gains focus.
|
||||
FocusIFrame(PipelineId, SubpageId),
|
||||
/// Passes a webdriver command to the script task for execution
|
||||
/// Passes a webdriver command to the script thread for execution
|
||||
WebDriverScriptCommand(PipelineId, WebDriverScriptCommand),
|
||||
/// Notifies script task that all animations are done
|
||||
/// Notifies script thread that all animations are done
|
||||
TickAllAnimations(PipelineId),
|
||||
/// Notifies the script task that a new Web font has been loaded, and thus the page should be
|
||||
/// Notifies the script thread that a new Web font has been loaded, and thus the page should be
|
||||
/// reflowed.
|
||||
WebFontLoaded(PipelineId),
|
||||
/// Cause a `load` event to be dispatched at the appropriate frame element.
|
||||
@ -166,7 +166,7 @@ pub enum TouchEventType {
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Deserialize, Serialize)]
|
||||
pub struct TouchId(pub i32);
|
||||
|
||||
/// Events from the compositor that the script task needs to know about
|
||||
/// Events from the compositor that the script thread needs to know about
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub enum CompositorEvent {
|
||||
/// The window was resized.
|
||||
@ -192,16 +192,16 @@ pub struct TimerEventRequest(pub IpcSender<TimerEvent>,
|
||||
pub TimerEventId,
|
||||
pub MsDuration);
|
||||
|
||||
/// Notifies the script task to fire due timers.
|
||||
/// TimerSource must be FromWindow when dispatched to ScriptTask and
|
||||
/// Notifies the script thread to fire due timers.
|
||||
/// TimerSource must be FromWindow when dispatched to ScriptThread and
|
||||
/// must be FromWorker when dispatched to a DedicatedGlobalWorkerScope
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub struct TimerEvent(pub TimerSource, pub TimerEventId);
|
||||
|
||||
/// Describes the task that requested the TimerEvent.
|
||||
/// Describes the thread that requested the TimerEvent.
|
||||
#[derive(Copy, Clone, HeapSizeOf, Deserialize, Serialize)]
|
||||
pub enum TimerSource {
|
||||
/// The event was requested from a window (ScriptTask).
|
||||
/// The event was requested from a window (ScriptThread).
|
||||
FromWindow(PipelineId),
|
||||
/// The event was requested from a worker (DedicatedGlobalWorkerScope).
|
||||
FromWorker
|
||||
@ -244,24 +244,24 @@ pub struct InitialScriptState {
|
||||
pub parent_info: Option<(PipelineId, SubpageId)>,
|
||||
/// The compositor.
|
||||
pub compositor: IpcSender<ScriptToCompositorMsg>,
|
||||
/// A channel with which messages can be sent to us (the script task).
|
||||
/// A channel with which messages can be sent to us (the script thread).
|
||||
pub control_chan: IpcSender<ConstellationControlMsg>,
|
||||
/// A port on which messages sent by the constellation to script can be received.
|
||||
pub control_port: IpcReceiver<ConstellationControlMsg>,
|
||||
/// A channel on which messages can be sent to the constellation from script.
|
||||
pub constellation_chan: ConstellationChan<ScriptMsg>,
|
||||
/// A channel for the layout task to send messages to the constellation.
|
||||
/// A channel for the layout thread to send messages to the constellation.
|
||||
pub layout_to_constellation_chan: ConstellationChan<LayoutMsg>,
|
||||
/// A channel to schedule timer events.
|
||||
pub scheduler_chan: IpcSender<TimerEventRequest>,
|
||||
/// Information that script sends out when it panics.
|
||||
pub failure_info: Failure,
|
||||
/// A channel to the resource manager task.
|
||||
pub resource_task: ResourceTask,
|
||||
/// A channel to the storage task.
|
||||
pub storage_task: StorageTask,
|
||||
/// A channel to the image cache task.
|
||||
pub image_cache_task: ImageCacheTask,
|
||||
/// A channel to the resource manager thread.
|
||||
pub resource_thread: ResourceThread,
|
||||
/// A channel to the storage thread.
|
||||
pub storage_thread: StorageThread,
|
||||
/// A channel to the image cache thread.
|
||||
pub image_cache_thread: ImageCacheThread,
|
||||
/// A channel to the time profiler thread.
|
||||
pub time_profiler_chan: profile_traits::time::ProfilerChan,
|
||||
/// A channel to the memory profiler thread.
|
||||
@ -276,14 +276,14 @@ pub struct InitialScriptState {
|
||||
pub content_process_shutdown_chan: IpcSender<()>,
|
||||
}
|
||||
|
||||
/// Encapsulates external communication with the script task.
|
||||
/// Encapsulates external communication with the script thread.
|
||||
#[derive(Clone, Deserialize, Serialize)]
|
||||
pub struct ScriptControlChan(pub IpcSender<ConstellationControlMsg>);
|
||||
|
||||
/// This trait allows creating a `ScriptTask` without depending on the `script`
|
||||
/// This trait allows creating a `ScriptThread` without depending on the `script`
|
||||
/// crate.
|
||||
pub trait ScriptTaskFactory {
|
||||
/// Create a `ScriptTask`.
|
||||
pub trait ScriptThreadFactory {
|
||||
/// Create a `ScriptThread`.
|
||||
fn create(_phantom: Option<&mut Self>,
|
||||
state: InitialScriptState,
|
||||
layout_chan: &OpaqueScriptLayoutChannel,
|
||||
|
@ -20,7 +20,7 @@ use util::cursor::Cursor;
|
||||
pub enum LayoutMsg {
|
||||
/// Indicates whether this pipeline is currently running animations.
|
||||
ChangeRunningAnimationsState(PipelineId, AnimationState),
|
||||
/// Layout task failure.
|
||||
/// Layout thread failure.
|
||||
Failure(Failure),
|
||||
/// Requests that the constellation inform the compositor of the a cursor change.
|
||||
SetCursor(Cursor),
|
||||
@ -35,17 +35,17 @@ pub enum ScriptMsg {
|
||||
ChangeRunningAnimationsState(PipelineId, AnimationState),
|
||||
/// Requests that a new 2D canvas thread be created. (This is done in the constellation because
|
||||
/// 2D canvases may use the GPU and we don't want to give untrusted content access to the GPU.)
|
||||
CreateCanvasPaintTask(Size2D<i32>, IpcSender<(IpcSender<CanvasMsg>, usize)>),
|
||||
CreateCanvasPaintThread(Size2D<i32>, IpcSender<(IpcSender<CanvasMsg>, usize)>),
|
||||
/// Requests that a new WebGL thread be created. (This is done in the constellation because
|
||||
/// WebGL uses the GPU and we don't want to give untrusted content access to the GPU.)
|
||||
CreateWebGLPaintTask(Size2D<i32>,
|
||||
CreateWebGLPaintThread(Size2D<i32>,
|
||||
GLContextAttributes,
|
||||
IpcSender<Result<(IpcSender<CanvasMsg>, usize), String>>),
|
||||
/// Dispatched after the DOM load event has fired on a document
|
||||
/// Causes a `load` event to be dispatched to any enclosing frame context element
|
||||
/// for the given pipeline.
|
||||
DOMLoad(PipelineId),
|
||||
/// Script task failure.
|
||||
/// Script thread failure.
|
||||
Failure(Failure),
|
||||
/// Notifies the constellation that this frame has received focus.
|
||||
Focus(PipelineId),
|
||||
|
@ -11,8 +11,8 @@
|
||||
//!
|
||||
//! The `Browser` type is responsible for configuring a
|
||||
//! `Constellation`, which does the heavy lifting of coordinating all
|
||||
//! of Servo's internal subsystems, including the `ScriptTask` and the
|
||||
//! `LayoutTask`, as well maintains the navigation context.
|
||||
//! of Servo's internal subsystems, including the `ScriptThread` and the
|
||||
//! `LayoutThread`, as well maintains the navigation context.
|
||||
//!
|
||||
//! The `Browser` is fed events from a generic type that implements the
|
||||
//! `WindowMethods` trait.
|
||||
@ -58,20 +58,20 @@ fn webdriver(_port: u16, _constellation: Sender<ConstellationMsg>) { }
|
||||
|
||||
use compositing::CompositorEventListener;
|
||||
use compositing::CompositorMsg as ConstellationMsg;
|
||||
use compositing::compositor_task::InitialCompositorState;
|
||||
use compositing::compositor_thread::InitialCompositorState;
|
||||
use compositing::constellation::InitialConstellationState;
|
||||
use compositing::pipeline::UnprivilegedPipelineContent;
|
||||
use compositing::sandboxing;
|
||||
use compositing::windowing::WindowEvent;
|
||||
use compositing::windowing::WindowMethods;
|
||||
use compositing::{CompositorProxy, CompositorTask, Constellation};
|
||||
use compositing::{CompositorProxy, CompositorThread, Constellation};
|
||||
use gaol::sandbox::{ChildSandbox, ChildSandboxMethods};
|
||||
use gfx::font_cache_task::FontCacheTask;
|
||||
use gfx::font_cache_thread::FontCacheThread;
|
||||
use ipc_channel::ipc::{self, IpcSender};
|
||||
use net::image_cache_task::new_image_cache_task;
|
||||
use net::resource_task::new_resource_task;
|
||||
use net::storage_task::StorageTaskFactory;
|
||||
use net_traits::storage_task::StorageTask;
|
||||
use net::image_cache_thread::new_image_cache_thread;
|
||||
use net::resource_thread::new_resource_thread;
|
||||
use net::storage_thread::StorageThreadFactory;
|
||||
use net_traits::storage_thread::StorageThread;
|
||||
use profile::mem as profile_mem;
|
||||
use profile::time as profile_time;
|
||||
use profile_traits::mem;
|
||||
@ -163,7 +163,7 @@ impl Browser {
|
||||
|
||||
// The compositor coordinates with the client window to create the final
|
||||
// rendered page and display it somewhere.
|
||||
let compositor = CompositorTask::create(window, InitialCompositorState {
|
||||
let compositor = CompositorThread::create(window, InitialCompositorState {
|
||||
sender: compositor_proxy,
|
||||
receiver: compositor_receiver,
|
||||
constellation_chan: constellation_chan,
|
||||
@ -199,26 +199,26 @@ fn create_constellation(opts: opts::Opts,
|
||||
mem_profiler_chan: mem::ProfilerChan,
|
||||
devtools_chan: Option<Sender<devtools_traits::DevtoolsControlMsg>>,
|
||||
supports_clipboard: bool) -> Sender<ConstellationMsg> {
|
||||
let resource_task = new_resource_task(opts.user_agent.clone(), devtools_chan.clone());
|
||||
let resource_thread = new_resource_thread(opts.user_agent.clone(), devtools_chan.clone());
|
||||
|
||||
let image_cache_task = new_image_cache_task(resource_task.clone());
|
||||
let font_cache_task = FontCacheTask::new(resource_task.clone());
|
||||
let storage_task: StorageTask = StorageTaskFactory::new();
|
||||
let image_cache_thread = new_image_cache_thread(resource_thread.clone());
|
||||
let font_cache_thread = FontCacheThread::new(resource_thread.clone());
|
||||
let storage_thread: StorageThread = StorageThreadFactory::new();
|
||||
|
||||
let initial_state = InitialConstellationState {
|
||||
compositor_proxy: compositor_proxy,
|
||||
devtools_chan: devtools_chan,
|
||||
image_cache_task: image_cache_task,
|
||||
font_cache_task: font_cache_task,
|
||||
resource_task: resource_task,
|
||||
storage_task: storage_task,
|
||||
image_cache_thread: image_cache_thread,
|
||||
font_cache_thread: font_cache_thread,
|
||||
resource_thread: resource_thread,
|
||||
storage_thread: storage_thread,
|
||||
time_profiler_chan: time_profiler_chan,
|
||||
mem_profiler_chan: mem_profiler_chan,
|
||||
supports_clipboard: supports_clipboard,
|
||||
};
|
||||
let constellation_chan =
|
||||
Constellation::<layout::layout_task::LayoutTask,
|
||||
script::script_task::ScriptTask>::start(initial_state);
|
||||
Constellation::<layout::layout_thread::LayoutThread,
|
||||
script::script_thread::ScriptThread>::start(initial_state);
|
||||
|
||||
// Send the URL command to the constellation.
|
||||
match opts.url {
|
||||
@ -249,7 +249,7 @@ pub fn run_content_process(token: String) {
|
||||
|
||||
script::init();
|
||||
|
||||
unprivileged_content.start_all::<layout::layout_task::LayoutTask,
|
||||
script::script_task::ScriptTask>(true);
|
||||
unprivileged_content.start_all::<layout::layout_thread::LayoutThread,
|
||||
script::script_thread::ScriptThread>(true);
|
||||
}
|
||||
|
||||
|
@ -246,7 +246,7 @@ mod android {
|
||||
use self::libc::fdopen;
|
||||
use self::libc::fgets;
|
||||
use self::libc::{pipe, dup2};
|
||||
use servo::util::task::spawn_named;
|
||||
use servo::util::thread::spawn_named;
|
||||
use std::ffi::CStr;
|
||||
use std::ffi::CString;
|
||||
use std::str::from_utf8;
|
||||
|
@ -21,7 +21,7 @@ pub type Generation = u32;
|
||||
/// matches. Thanks to the bloom filter, we can avoid walking up the tree
|
||||
/// looking for ancestors that aren't there in the majority of cases.
|
||||
///
|
||||
/// As we walk down the DOM tree a task-local bloom filter is built of all the
|
||||
/// As we walk down the DOM tree a thread-local bloom filter is built of all the
|
||||
/// CSS `SimpleSelector`s which are part of a `Descendant` compound selector
|
||||
/// (i.e. paired with a `Descendant` combinator, in the `next` field of a
|
||||
/// `CompoundSelector`.
|
||||
@ -35,15 +35,15 @@ pub type Generation = u32;
|
||||
///
|
||||
/// Since a work-stealing queue is used for styling, sometimes, the bloom filter
|
||||
/// will no longer be the for the parent of the node we're currently on. When
|
||||
/// this happens, the task local bloom filter will be thrown away and rebuilt.
|
||||
/// this happens, the thread local bloom filter will be thrown away and rebuilt.
|
||||
thread_local!(
|
||||
pub static STYLE_BLOOM: RefCell<Option<(Box<BloomFilter>, UnsafeNode, Generation)>> = RefCell::new(None));
|
||||
|
||||
/// Returns the task local bloom filter.
|
||||
/// Returns the thread local bloom filter.
|
||||
///
|
||||
/// If one does not exist, a new one will be made for you. If it is out of date,
|
||||
/// it will be cleared and reused.
|
||||
fn take_task_local_bloom_filter<'ln, N>(parent_node: Option<N>,
|
||||
fn take_thread_local_bloom_filter<'ln, N>(parent_node: Option<N>,
|
||||
root: OpaqueNode,
|
||||
context: &SharedStyleContext)
|
||||
-> Box<BloomFilter>
|
||||
@ -79,12 +79,12 @@ fn take_task_local_bloom_filter<'ln, N>(parent_node: Option<N>,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn put_task_local_bloom_filter(bf: Box<BloomFilter>,
|
||||
pub fn put_thread_local_bloom_filter(bf: Box<BloomFilter>,
|
||||
unsafe_node: &UnsafeNode,
|
||||
context: &SharedStyleContext) {
|
||||
STYLE_BLOOM.with(move |style_bloom| {
|
||||
assert!(style_bloom.borrow().is_none(),
|
||||
"Putting into a never-taken task-local bloom filter");
|
||||
"Putting into a never-taken thread-local bloom filter");
|
||||
*style_bloom.borrow_mut() = Some((bf, *unsafe_node, context.generation));
|
||||
})
|
||||
}
|
||||
@ -176,7 +176,7 @@ pub fn recalc_style_at<'a, 'ln, N: TNode<'ln>, C: StyleContext<'a>> (context: &'
|
||||
let parent_opt = node.layout_parent_node(root);
|
||||
|
||||
// Get the style bloom filter.
|
||||
let mut bf = take_task_local_bloom_filter(parent_opt, root, context.shared_context());
|
||||
let mut bf = take_thread_local_bloom_filter(parent_opt, root, context.shared_context());
|
||||
|
||||
let nonincremental_layout = opts::get().nonincremental_layout;
|
||||
if nonincremental_layout || node.is_dirty() {
|
||||
@ -254,6 +254,6 @@ pub fn recalc_style_at<'a, 'ln, N: TNode<'ln>, C: StyleContext<'a>> (context: &'
|
||||
node.insert_into_bloom_filter(&mut *bf);
|
||||
|
||||
// NB: flow construction updates the bloom filter on the way up.
|
||||
put_task_local_bloom_filter(bf, &unsafe_layout_node, context.shared_context());
|
||||
put_thread_local_bloom_filter(bf, &unsafe_layout_node, context.shared_context());
|
||||
}
|
||||
|
||||
|
@ -69,9 +69,9 @@ pub mod print_tree;
|
||||
pub mod range;
|
||||
pub mod resource_files;
|
||||
pub mod str;
|
||||
pub mod task;
|
||||
pub mod task_state;
|
||||
pub mod taskpool;
|
||||
pub mod thread;
|
||||
pub mod thread_state;
|
||||
pub mod threadpool;
|
||||
pub mod tid;
|
||||
pub mod time;
|
||||
pub mod vec;
|
||||
|
@ -119,7 +119,7 @@ pub struct Opts {
|
||||
/// and paint.
|
||||
pub trace_layout: bool,
|
||||
|
||||
/// Periodically print out on which events script tasks spend their processing time.
|
||||
/// Periodically print out on which events script threads spend their processing time.
|
||||
pub profile_script_events: bool,
|
||||
|
||||
/// Enable all heartbeats for profiling.
|
||||
@ -224,7 +224,7 @@ pub struct DebugOptions {
|
||||
/// Print notifications when there is a relayout.
|
||||
pub relayout_event: bool,
|
||||
|
||||
/// Profile which events script tasks spend their time on.
|
||||
/// Profile which events script threads spend their time on.
|
||||
pub profile_script_events: bool,
|
||||
|
||||
/// Enable all heartbeats for profiling.
|
||||
@ -334,7 +334,7 @@ pub fn print_debug_usage(app: &str) -> ! {
|
||||
print_option("dump-layer-tree", "Print the layer tree whenever it changes.");
|
||||
print_option("relayout-event", "Print notifications when there is a relayout.");
|
||||
print_option("profile-script-events", "Enable profiling of script-related events.");
|
||||
print_option("profile-heartbeats", "Enable heartbeats for all task categories.");
|
||||
print_option("profile-heartbeats", "Enable heartbeats for all thread categories.");
|
||||
print_option("show-compositor-borders", "Paint borders along layer and tile boundaries.");
|
||||
print_option("show-fragment-borders", "Paint borders along fragment boundaries.");
|
||||
print_option("show-parallel-paint", "Overlay tiles with colors showing which thread painted them.");
|
||||
@ -507,7 +507,7 @@ pub fn from_cmdline_args(args: &[String]) -> ArgumentParsingResult {
|
||||
opts.optmulti("", "user-stylesheet",
|
||||
"A user stylesheet to be added to every document", "file.css");
|
||||
opts.optflag("z", "headless", "Headless mode");
|
||||
opts.optflag("f", "hard-fail", "Exit on task failure instead of displaying about:failure");
|
||||
opts.optflag("f", "hard-fail", "Exit on thread failure instead of displaying about:failure");
|
||||
opts.optflagopt("", "devtools", "Start remote devtools server on port", "6000");
|
||||
opts.optflagopt("", "webdriver", "Start remote WebDriver server on port", "7000");
|
||||
opts.optopt("", "resolution", "Set window resolution.", "800x600");
|
||||
|
@ -8,7 +8,7 @@ use std::borrow::ToOwned;
|
||||
use std::sync::mpsc::Sender;
|
||||
use std::thread;
|
||||
use std::thread::Builder;
|
||||
use task_state;
|
||||
use thread_state;
|
||||
|
||||
pub fn spawn_named<F>(name: String, f: F)
|
||||
where F: FnOnce() + Send + 'static
|
||||
@ -38,9 +38,9 @@ impl<T> SendOnFailure for IpcSender<T> where T: Send + Serialize + 'static {
|
||||
}
|
||||
}
|
||||
|
||||
/// Arrange to send a particular message to a channel if the task fails.
|
||||
/// Arrange to send a particular message to a channel if the thread fails.
|
||||
pub fn spawn_named_with_send_on_failure<F, T, S>(name: String,
|
||||
state: task_state::TaskState,
|
||||
state: thread_state::ThreadState,
|
||||
f: F,
|
||||
msg: T,
|
||||
mut dest: S)
|
||||
@ -48,7 +48,7 @@ pub fn spawn_named_with_send_on_failure<F, T, S>(name: String,
|
||||
T: Send + 'static,
|
||||
S: Send + SendOnFailure<Value=T> + 'static {
|
||||
let future_handle = thread::Builder::new().name(name.to_owned()).spawn(move || {
|
||||
task_state::initialize(state);
|
||||
thread_state::initialize(state);
|
||||
f()
|
||||
}).unwrap();
|
||||
|
@ -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/. */
|
||||
|
||||
//! Supports dynamic assertions in debug builds about what sort of task is
|
||||
//! Supports dynamic assertions in debug builds about what sort of thread is
|
||||
//! running and what state it's in.
|
||||
//!
|
||||
//! In release builds, `get` returns 0. All of the other functions inline
|
||||
@ -11,7 +11,7 @@
|
||||
pub use self::imp::{enter, exit, get, initialize};
|
||||
|
||||
bitflags! {
|
||||
flags TaskState: u32 {
|
||||
flags ThreadState: u32 {
|
||||
const SCRIPT = 0x01,
|
||||
const LAYOUT = 0x02,
|
||||
const PAINT = 0x04,
|
||||
@ -22,8 +22,8 @@ bitflags! {
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! task_types ( ( $( $fun:ident = $flag:ident ; )* ) => (
|
||||
impl TaskState {
|
||||
macro_rules! thread_types ( ( $( $fun:ident = $flag:ident ; )* ) => (
|
||||
impl ThreadState {
|
||||
$(
|
||||
#[cfg(debug_assertions)]
|
||||
pub fn $fun(self) -> bool {
|
||||
@ -37,11 +37,11 @@ macro_rules! task_types ( ( $( $fun:ident = $flag:ident ; )* ) => (
|
||||
}
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
static TYPES: &'static [TaskState]
|
||||
static TYPES: &'static [ThreadState]
|
||||
= &[ $( $flag ),* ];
|
||||
));
|
||||
|
||||
task_types! {
|
||||
thread_types! {
|
||||
is_script = SCRIPT;
|
||||
is_layout = LAYOUT;
|
||||
is_paint = PAINT;
|
||||
@ -50,14 +50,14 @@ task_types! {
|
||||
#[cfg(debug_assertions)]
|
||||
mod imp {
|
||||
use std::cell::RefCell;
|
||||
use super::{TYPES, TaskState};
|
||||
use super::{TYPES, ThreadState};
|
||||
|
||||
thread_local!(static STATE: RefCell<Option<TaskState>> = RefCell::new(None));
|
||||
thread_local!(static STATE: RefCell<Option<ThreadState>> = RefCell::new(None));
|
||||
|
||||
pub fn initialize(x: TaskState) {
|
||||
pub fn initialize(x: ThreadState) {
|
||||
STATE.with(|ref k| {
|
||||
match *k.borrow() {
|
||||
Some(s) => panic!("Task state already initialized as {:?}", s),
|
||||
Some(s) => panic!("Thread state already initialized as {:?}", s),
|
||||
None => ()
|
||||
};
|
||||
*k.borrow_mut() = Some(x);
|
||||
@ -65,20 +65,20 @@ mod imp {
|
||||
get(); // check the assertion below
|
||||
}
|
||||
|
||||
pub fn get() -> TaskState {
|
||||
pub fn get() -> ThreadState {
|
||||
let state = STATE.with(|ref k| {
|
||||
match *k.borrow() {
|
||||
None => panic!("Task state not initialized"),
|
||||
None => panic!("Thread state not initialized"),
|
||||
Some(s) => s,
|
||||
}
|
||||
});
|
||||
|
||||
// Exactly one of the task type flags should be set.
|
||||
// Exactly one of the thread type flags should be set.
|
||||
assert_eq!(1, TYPES.iter().filter(|&&ty| state.contains(ty)).count());
|
||||
state
|
||||
}
|
||||
|
||||
pub fn enter(x: TaskState) {
|
||||
pub fn enter(x: ThreadState) {
|
||||
let state = get();
|
||||
assert!(!state.intersects(x));
|
||||
STATE.with(|ref k| {
|
||||
@ -86,7 +86,7 @@ mod imp {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn exit(x: TaskState) {
|
||||
pub fn exit(x: ThreadState) {
|
||||
let state = get();
|
||||
assert!(state.contains(x));
|
||||
STATE.with(|ref k| {
|
||||
@ -97,9 +97,9 @@ mod imp {
|
||||
|
||||
#[cfg(not(debug_assertions))]
|
||||
mod imp {
|
||||
use super::TaskState;
|
||||
#[inline(always)] pub fn initialize(_: TaskState) { }
|
||||
#[inline(always)] pub fn get() -> TaskState { TaskState::empty() }
|
||||
#[inline(always)] pub fn enter(_: TaskState) { }
|
||||
#[inline(always)] pub fn exit(_: TaskState) { }
|
||||
use super::ThreadState;
|
||||
#[inline(always)] pub fn initialize(_: ThreadState) { }
|
||||
#[inline(always)] pub fn get() -> ThreadState { ThreadState::empty() }
|
||||
#[inline(always)] pub fn enter(_: ThreadState) { }
|
||||
#[inline(always)] pub fn exit(_: ThreadState) { }
|
||||
}
|
@ -2,14 +2,14 @@
|
||||
* 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/. */
|
||||
|
||||
//! A load-balancing task pool.
|
||||
//! A load-balancing thread pool.
|
||||
//!
|
||||
//! This differs in implementation from std::sync::TaskPool in that each job is
|
||||
//! up for grabs by any of the child tasks in the pool.
|
||||
//! This differs in implementation from std::sync::ThreadPool in that each job is
|
||||
//! up for grabs by any of the child threads in the pool.
|
||||
//!
|
||||
|
||||
//
|
||||
// This is based on the cargo task pool.
|
||||
// This is based on the cargo thread pool.
|
||||
// https://github.com/rust-lang/cargo/blob/master/src/cargo/util/pool.rs
|
||||
//
|
||||
// The only difference is that a normal channel is used instead of a sync_channel.
|
||||
@ -18,27 +18,27 @@
|
||||
use std::boxed::FnBox;
|
||||
use std::sync::mpsc::{Receiver, Sender, channel};
|
||||
use std::sync::{Arc, Mutex};
|
||||
use task::spawn_named;
|
||||
use thread::spawn_named;
|
||||
|
||||
pub struct TaskPool {
|
||||
pub struct ThreadPool {
|
||||
tx: Sender<Box<FnBox() + Send + 'static>>,
|
||||
}
|
||||
|
||||
impl TaskPool {
|
||||
pub fn new(tasks: u32) -> TaskPool {
|
||||
assert!(tasks > 0);
|
||||
impl ThreadPool {
|
||||
pub fn new(threads: u32) -> ThreadPool {
|
||||
assert!(threads > 0);
|
||||
let (tx, rx) = channel();
|
||||
|
||||
let state = Arc::new(Mutex::new(rx));
|
||||
|
||||
for i in 0..tasks {
|
||||
for i in 0..threads {
|
||||
let state = state.clone();
|
||||
spawn_named(
|
||||
format!("TaskPoolWorker {}/{}", i + 1, tasks),
|
||||
format!("ThreadPoolWorker {}/{}", i + 1, threads),
|
||||
move || worker(&*state));
|
||||
}
|
||||
|
||||
return TaskPool { tx: tx };
|
||||
return ThreadPool { tx: tx };
|
||||
|
||||
fn worker(rx: &Mutex<Receiver<Box<FnBox() + Send + 'static>>>) {
|
||||
while let Ok(job) = rx.lock().unwrap().recv() {
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user