Start switching net/ to use abstractions over channels to allow introducing non-channel communication in the future.

This commit is contained in:
Josh Matthews 2015-01-25 10:44:28 -05:00
parent 7fddf4aa13
commit 1644436557
13 changed files with 108 additions and 79 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/. */
use net_traits::{LoadData, Metadata};
use net_traits::{LoadData, Metadata, ResponseSenders};
use net_traits::ProgressMsg::{Payload, Done};
use mime_classifier::MIMEClassifier;
use resource_task::start_sending;
@ -13,16 +13,15 @@ use hyper::mime::Mime;
use std::sync::Arc;
use url::{percent_decode, SchemeData};
pub fn factory(load_data: LoadData, _classifier: Arc<MIMEClassifier>) {
pub fn factory(load_data: LoadData, senders: ResponseSenders, _classifier: Arc<MIMEClassifier>) {
// NB: we don't spawn a new task.
// 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.
load(load_data)
load(load_data, senders)
}
pub fn load(load_data: LoadData) {
let start_chan = load_data.consumer;
pub fn load(load_data: LoadData, start_chan: ResponseSenders) {
let url = load_data.url;
assert!(&*url.scheme == "data");