Auto merge of #14508 - servo:determine_request_referrer, r=jdm,frewsxcv

Rewrite determine_request_referrer() to explicitly limit it to the checks it can do.

Checks for the Client value should reside in the script thread.

I also noted some other issues in this code.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14508)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-12-09 13:13:27 -08:00 committed by GitHub
commit 882d5512bb
3 changed files with 40 additions and 42 deletions

View file

@ -9,7 +9,6 @@ use msg::constellation_msg::PipelineId;
use servo_url::ServoUrl;
use std::cell::{Cell, RefCell};
use std::default::Default;
use std::mem::swap;
use url::{Origin as UrlOrigin};
/// An [initiator](https://fetch.spec.whatwg.org/#concept-request-initiator)
@ -308,19 +307,4 @@ impl Referrer {
Referrer::ReferrerUrl(ref url) => Some(url)
}
}
pub fn from_url(url: Option<ServoUrl>) -> Self {
if let Some(url) = url {
Referrer::ReferrerUrl(url)
} else {
Referrer::NoReferrer
}
}
pub fn take(&mut self) -> Option<ServoUrl> {
let mut new = Referrer::Client;
swap(self, &mut new);
match new {
Referrer::NoReferrer | Referrer::Client => None,
Referrer::ReferrerUrl(url) => Some(url)
}
}
}