Skip to content

Commit

Permalink
Make workers' interrupt_callback use GlobalScope
Browse files Browse the repository at this point in the history
  • Loading branch information
nox committed Oct 6, 2016
1 parent 907781e commit 00e66a7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
10 changes: 4 additions & 6 deletions components/script/dom/dedicatedworkerglobalscope.rs
Expand Up @@ -11,7 +11,7 @@ use dom::bindings::codegen::Bindings::DedicatedWorkerGlobalScopeBinding;
use dom::bindings::codegen::Bindings::DedicatedWorkerGlobalScopeBinding::DedicatedWorkerGlobalScopeMethods;
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
use dom::bindings::error::{ErrorInfo, ErrorResult};
use dom::bindings::global::{GlobalRef, global_root_from_context};
use dom::bindings::global::global_scope_from_context;
use dom::bindings::inheritance::Castable;
use dom::bindings::js::{Root, RootCollection};
use dom::bindings::reflector::Reflectable;
Expand Down Expand Up @@ -342,11 +342,9 @@ impl DedicatedWorkerGlobalScope {

#[allow(unsafe_code)]
unsafe extern "C" fn interrupt_callback(cx: *mut JSContext) -> bool {
let global = global_root_from_context(cx);
let worker = match global.r() {
GlobalRef::Worker(w) => w,
_ => panic!("global for worker is not a worker scope")
};
let worker =
Root::downcast::<WorkerGlobalScope>(global_scope_from_context(cx))
.expect("global is not a worker scope");
assert!(worker.is::<DedicatedWorkerGlobalScope>());

// A false response causes the script to terminate
Expand Down
10 changes: 4 additions & 6 deletions components/script/dom/serviceworkerglobalscope.rs
Expand Up @@ -8,7 +8,7 @@ use dom::abstractworker::WorkerScriptMsg;
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
use dom::bindings::codegen::Bindings::ServiceWorkerGlobalScopeBinding;
use dom::bindings::codegen::Bindings::ServiceWorkerGlobalScopeBinding::ServiceWorkerGlobalScopeMethods;
use dom::bindings::global::{GlobalRef, global_root_from_context};
use dom::bindings::global::global_scope_from_context;
use dom::bindings::inheritance::Castable;
use dom::bindings::js::{Root, RootCollection};
use dom::bindings::reflector::Reflectable;
Expand Down Expand Up @@ -310,11 +310,9 @@ impl ServiceWorkerGlobalScope {

#[allow(unsafe_code)]
unsafe extern "C" fn interrupt_callback(cx: *mut JSContext) -> bool {
let global = global_root_from_context(cx);
let worker = match global.r() {
GlobalRef::Worker(w) => w,
_ => panic!("global for worker is not a worker scope")
};
let worker =
Root::downcast::<WorkerGlobalScope>(global_scope_from_context(cx))
.expect("global is not a worker scope");
assert!(worker.is::<ServiceWorkerGlobalScope>());

// A false response causes the script to terminate
Expand Down

0 comments on commit 00e66a7

Please sign in to comment.