Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the fetch target non-optional. #14465

Merged
merged 9 commits into from Dec 15, 2016

Use the asynchronous fetching code for fetch_with_context().

  • Loading branch information
Ms2ger committed Dec 15, 2016
commit 306905a6319a9ff956512cc254932573ff654214
@@ -72,20 +72,20 @@ impl FetchTaskTarget for FetchResponseCollector {
}

fn fetch(request: Request, dc: Option<Sender<DevtoolsControlMsg>>) -> Response {
fetch_with_context(request, &new_fetch_context(dc))
}

fn fetch_with_context(request: Request, context: &FetchContext) -> Response {
let (sender, receiver) = channel();
let target = Box::new(FetchResponseCollector {
sender: sender,
});

methods::fetch(Rc::new(request), &mut Some(target), &new_fetch_context(dc));
methods::fetch(Rc::new(request), &mut Some(target), context);

receiver.recv().unwrap()
}

fn fetch_with_context(request: Request, context: &FetchContext) -> Response {
methods::fetch(Rc::new(request), &mut None, context)
}

fn make_server<H: Handler + 'static>(handler: H) -> (Listening, ServoUrl) {
// this is a Listening server because of handle_threads()
let server = Server::http("0.0.0.0:0").unwrap().handle_threads(handler, 1).unwrap();
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.