Split out shared networking code into net_traits crate

Fixes #4476
This commit is contained in:
Gilles Leblanc 2015-03-23 21:19:55 -04:00
parent 74f8c0eeb7
commit ba36a108c1
56 changed files with 674 additions and 518 deletions

View file

@ -11,6 +11,7 @@ dependencies = [
"layout 0.0.1",
"msg 0.0.1",
"net 0.0.1",
"net_traits 0.0.1",
"png 0.1.0 (git+https://github.com/servo/rust-png)",
"profile 0.0.1",
"script 0.0.1",
@ -98,6 +99,7 @@ dependencies = [
"libc 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"msg 0.0.1",
"net 0.0.1",
"net_traits 0.0.1",
"png 0.1.0 (git+https://github.com/servo/rust-png)",
"profile 0.0.1",
"script_traits 0.0.1",
@ -321,7 +323,7 @@ dependencies = [
"layers 0.1.0 (git+https://github.com/servo/rust-layers)",
"libc 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"msg 0.0.1",
"net 0.0.1",
"net_traits 0.0.1",
"plugins 0.0.1",
"png 0.1.0 (git+https://github.com/servo/rust-png)",
"profile 0.0.1",
@ -527,7 +529,7 @@ dependencies = [
"layout_traits 0.0.1",
"libc 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"msg 0.0.1",
"net 0.0.1",
"net_traits 0.0.1",
"plugins 0.0.1",
"png 0.1.0 (git+https://github.com/servo/rust-png)",
"profile 0.0.1",
@ -548,7 +550,7 @@ version = "0.0.1"
dependencies = [
"gfx 0.0.1",
"msg 0.0.1",
"net 0.0.1",
"net_traits 0.0.1",
"profile 0.0.1",
"script_traits 0.0.1",
"url 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)",
@ -639,18 +641,31 @@ dependencies = [
"flate2 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"geom 0.1.0 (git+https://github.com/servo/rust-geom)",
"hyper 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"net_traits 0.0.1",
"openssl 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"png 0.1.0 (git+https://github.com/servo/rust-png)",
"profile 0.0.1",
"regex 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)",
"regex_macros 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
"stb_image 0.1.0 (git+https://github.com/servo/rust-stb-image)",
"time 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)",
"url 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1",
]
[[package]]
name = "net_traits"
version = "0.0.1"
dependencies = [
"geom 0.1.0 (git+https://github.com/servo/rust-geom)",
"hyper 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"png 0.1.0 (git+https://github.com/servo/rust-png)",
"profile 0.0.1",
"stb_image 0.1.0 (git+https://github.com/servo/rust-stb-image)",
"url 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1",
]
[[package]]
name = "openssl"
version = "0.5.1"
@ -785,7 +800,7 @@ dependencies = [
"js 0.1.0 (git+https://github.com/servo/rust-mozjs)",
"libc 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"msg 0.0.1",
"net 0.0.1",
"net_traits 0.0.1",
"plugins 0.0.1",
"profile 0.0.1",
"rustc-serialize 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
@ -808,7 +823,7 @@ dependencies = [
"geom 0.1.0 (git+https://github.com/servo/rust-geom)",
"libc 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"msg 0.0.1",
"net 0.0.1",
"net_traits 0.0.1",
"url 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1",
]

View file

@ -48,6 +48,9 @@ path = "../compositing"
[dependencies.net]
path = "../net"
[dependencies.net_traits]
path = "../net_traits"
[dependencies.msg]
path = "../msg"

View file

@ -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/. */
#![feature(libc, path, rustc_private, thread_local)]
#![feature(libc, rustc_private, thread_local)]
#[macro_use]
extern crate log;
@ -10,6 +10,7 @@ extern crate log;
extern crate compositing;
extern crate devtools;
extern crate net;
extern crate net_traits;
extern crate msg;
extern crate profile;
#[macro_use]
@ -33,11 +34,15 @@ use msg::constellation_msg::ConstellationChan;
use script::dom::bindings::codegen::RegisterBindings;
#[cfg(not(test))]
use net::image_cache_task::{ImageCacheTask, LoadPlaceholder};
use net::image_cache_task::{ImageCacheTaskFactory, LoadPlaceholder};
#[cfg(not(test))]
use net::storage_task::StorageTaskFactory;
#[cfg(not(test))]
use net::resource_task::new_resource_task;
#[cfg(not(test))]
use net::storage_task::{StorageTaskFactory, StorageTask};
use net_traits::image_cache_task::ImageCacheTask;
#[cfg(not(test))]
use net_traits::storage_task::StorageTask;
#[cfg(not(test))]
use gfx::font_cache_task::FontCacheTask;
#[cfg(not(test))]
@ -82,12 +87,12 @@ impl Browser {
// If we are emitting an output file, then we need to block on
// image load or we risk emitting an output file missing the
// image.
let image_cache_task = if opts.output_file.is_some() {
ImageCacheTask::new_sync(resource_task.clone(), shared_task_pool,
time_profiler_chan.clone(), LoadPlaceholder::Preload)
let image_cache_task: ImageCacheTask = if opts.output_file.is_some() {
ImageCacheTaskFactory::new_sync(resource_task.clone(), shared_task_pool,
time_profiler_chan.clone(), LoadPlaceholder::Preload)
} else {
ImageCacheTask::new(resource_task.clone(), shared_task_pool,
time_profiler_chan.clone(), LoadPlaceholder::Preload)
ImageCacheTaskFactory::new(resource_task.clone(), shared_task_pool,
time_profiler_chan.clone(), LoadPlaceholder::Preload)
};
let font_cache_task = FontCacheTask::new(resource_task.clone());