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

@ -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());