aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/globalscope.rs
diff options
context:
space:
mode:
authorAnthony Ramine <n.oxyde@gmail.com>2016-09-27 13:26:21 +0200
committerAnthony Ramine <n.oxyde@gmail.com>2016-10-06 20:59:09 +0200
commit38273fe7a83313649384a6f265ee9ab816287b18 (patch)
tree7e66f7d4e4a1aa177e6d1df9d36d502ecbb7f9b5 /components/script/dom/globalscope.rs
parentfcb59d305742a18daa083352a9b6e9a45896c9f6 (diff)
downloadservo-38273fe7a83313649384a6f265ee9ab816287b18.tar.gz
servo-38273fe7a83313649384a6f265ee9ab816287b18.zip
Introduce GlobalScope::crypto
Diffstat (limited to 'components/script/dom/globalscope.rs')
-rw-r--r--components/script/dom/globalscope.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/components/script/dom/globalscope.rs b/components/script/dom/globalscope.rs
index de9ee3773d2..0eaf631f0e1 100644
--- a/components/script/dom/globalscope.rs
+++ b/components/script/dom/globalscope.rs
@@ -2,19 +2,23 @@
* 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 dom::bindings::js::{JS, MutNullableHeap, Root};
use dom::bindings::reflector::Reflectable;
+use dom::crypto::Crypto;
use dom::eventtarget::EventTarget;
use js::jsapi::{JS_GetContext, JS_GetObjectRuntime, JSContext};
#[dom_struct]
pub struct GlobalScope {
eventtarget: EventTarget,
+ crypto: MutNullableHeap<JS<Crypto>>,
}
impl GlobalScope {
pub fn new_inherited() -> GlobalScope {
GlobalScope {
eventtarget: EventTarget::new_inherited(),
+ crypto: Default::default(),
}
}
@@ -29,4 +33,8 @@ impl GlobalScope {
context
}
}
+
+ pub fn crypto(&self) -> Root<Crypto> {
+ self.crypto.or_init(|| Crypto::new(self))
+ }
}