diff options
author | Connor Brewster <connor.brewster@eagles.oc.edu> | 2017-01-20 13:21:23 -0600 |
---|---|---|
committer | Alan Jeffrey <ajeffrey@mozilla.com> | 2017-02-22 11:11:59 -0600 |
commit | bfd7b950ad1d2e9264563fc40d5684a96bbab23f (patch) | |
tree | 775afc20fbfb832b7242ea5c6145c97f6a63bcc6 /components/script/origin.rs | |
parent | 4f7e422054237c8ba0a8e521a615a6012b90eab4 (diff) | |
download | servo-bfd7b950ad1d2e9264563fc40d5684a96bbab23f.tar.gz servo-bfd7b950ad1d2e9264563fc40d5684a96bbab23f.zip |
Add ImmutableOrigin to allow for serializing origins
Diffstat (limited to 'components/script/origin.rs')
-rw-r--r-- | components/script/origin.rs | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/components/script/origin.rs b/components/script/origin.rs deleted file mode 100644 index 067eb77dcda..00000000000 --- a/components/script/origin.rs +++ /dev/null @@ -1,61 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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 servo_url::ServoUrl; -use std::sync::Arc; -use url::Host; -use url::Origin as UrlOrigin; - -/// A representation of an [origin](https://html.spec.whatwg.org/multipage/#origin-2). -#[derive(HeapSizeOf, JSTraceable)] -pub struct Origin { - #[ignore_heap_size_of = "Arc<T> has unclear ownership semantics"] - inner: Arc<UrlOrigin>, -} - -impl Origin { - /// Create a new origin comprising a unique, opaque identifier. - pub fn opaque_identifier() -> Origin { - Origin { - inner: Arc::new(UrlOrigin::new_opaque()), - } - } - - /// Create a new origin for the given URL. - pub fn new(url: &ServoUrl) -> Origin { - Origin { - inner: Arc::new(url.origin()), - } - } - - /// Does this origin represent a host/scheme/port tuple? - pub fn is_scheme_host_port_tuple(&self) -> bool { - self.inner.is_tuple() - } - - /// Return the host associated with this origin. - pub fn host(&self) -> Option<&Host<String>> { - match *self.inner { - UrlOrigin::Tuple(_, ref host, _) => Some(host), - UrlOrigin::Opaque(..) => None, - } - } - - /// https://html.spec.whatwg.org/multipage/#same-origin - pub fn same_origin(&self, other: &Origin) -> bool { - self.inner == other.inner - } - - pub fn copy(&self) -> Origin { - Origin { - inner: Arc::new((*self.inner).clone()), - } - } - - pub fn alias(&self) -> Origin { - Origin { - inner: self.inner.clone(), - } - } -} |