An in-memory RNG that shares its file descriptor.

This commit is contained in:
Alan Jeffrey 2017-01-05 13:51:53 +00:00
parent 143dfc879e
commit 7ace30f9bd
15 changed files with 203 additions and 23 deletions

View file

@ -12,23 +12,23 @@ use dom::bindings::reflector::{Reflector, reflect_dom_object};
use dom::globalscope::GlobalScope;
use js::jsapi::{JSContext, JSObject};
use js::jsapi::{JS_GetArrayBufferViewType, Type};
use rand::{OsRng, Rng};
use servo_rand::{ServoRng, Rng};
unsafe_no_jsmanaged_fields!(OsRng);
unsafe_no_jsmanaged_fields!(ServoRng);
// https://developer.mozilla.org/en-US/docs/Web/API/Crypto
#[dom_struct]
pub struct Crypto {
reflector_: Reflector,
#[ignore_heap_size_of = "Defined in rand"]
rng: DOMRefCell<OsRng>,
rng: DOMRefCell<ServoRng>,
}
impl Crypto {
fn new_inherited() -> Crypto {
Crypto {
reflector_: Reflector::new(),
rng: DOMRefCell::new(OsRng::new().unwrap()),
rng: DOMRefCell::new(ServoRng::new()),
}
}

View file

@ -29,10 +29,10 @@ use js::rust::Runtime;
use msg::constellation_msg::FrameId;
use net_traits::{IpcSend, load_whole_resource};
use net_traits::request::{CredentialsMode, Destination, RequestInit, Type as RequestType};
use rand::random;
use script_runtime::{CommonScriptMsg, ScriptChan, ScriptPort, StackRootTLS, get_reports, new_rt_and_cx};
use script_runtime::ScriptThreadEventCategory::WorkerEvent;
use script_traits::{TimerEvent, TimerSource, WorkerGlobalScopeInit, WorkerScriptLoadOrigin};
use servo_rand::random;
use servo_url::ServoUrl;
use std::mem::replace;
use std::sync::{Arc, Mutex};

View file

@ -44,9 +44,9 @@ use html5ever_atoms::LocalName;
use hyper::header::{Charset, ContentDisposition, ContentType, DispositionParam, DispositionType};
use hyper::method::Method;
use msg::constellation_msg::PipelineId;
use rand::random;
use script_thread::{MainThreadScriptMsg, Runnable};
use script_traits::LoadData;
use servo_rand::random;
use std::borrow::ToOwned;
use std::cell::Cell;
use std::sync::mpsc::Sender;

View file

@ -25,10 +25,10 @@ use js::jsval::UndefinedValue;
use js::rust::Runtime;
use net_traits::{load_whole_resource, IpcSend, CustomResponseMediator};
use net_traits::request::{CredentialsMode, Destination, RequestInit, Type as RequestType};
use rand::random;
use script_runtime::{CommonScriptMsg, StackRootTLS, get_reports, new_rt_and_cx, ScriptChan};
use script_traits::{TimerEvent, WorkerGlobalScopeInit, ScopeThings, ServiceWorkerMsg, WorkerScriptLoadOrigin};
use servo_config::prefs::PREFS;
use servo_rand::random;
use servo_url::ServoUrl;
use std::sync::mpsc::{Receiver, RecvError, Select, Sender, channel};
use std::thread;