mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-14 04:03:47 +00:00
Bug 1748718 - Part 3: Remove now-unnecessary xpidl constant casts, r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D135166
This commit is contained in:
parent
aa59bfed6b
commit
e8f83d2043
@ -51,16 +51,16 @@ impl<T: XpCom + 'static> Iterator for IterSimpleEnumerator<T> {
|
||||
|
||||
fn process_type() -> u32 {
|
||||
if let Some(appinfo) = xpcom::services::get_XULRuntime() {
|
||||
let mut process_type = nsIXULRuntime::PROCESS_TYPE_DEFAULT as u32;
|
||||
let mut process_type = nsIXULRuntime::PROCESS_TYPE_DEFAULT;
|
||||
if unsafe { appinfo.GetProcessType(&mut process_type).succeeded() } {
|
||||
return process_type;
|
||||
}
|
||||
}
|
||||
nsIXULRuntime::PROCESS_TYPE_DEFAULT as u32
|
||||
nsIXULRuntime::PROCESS_TYPE_DEFAULT
|
||||
}
|
||||
|
||||
pub fn is_parent_process() -> bool {
|
||||
process_type() == nsIXULRuntime::PROCESS_TYPE_DEFAULT as u32
|
||||
process_type() == nsIXULRuntime::PROCESS_TYPE_DEFAULT
|
||||
}
|
||||
|
||||
pub fn get_packaged_locales() -> Option<ThinVec<nsCString>> {
|
||||
|
@ -296,10 +296,10 @@ impl SecurityState {
|
||||
}
|
||||
|
||||
pub fn get_has_prior_data(&self, data_type: u8) -> Result<bool, SecurityStateError> {
|
||||
if data_type == nsICertStorage::DATA_TYPE_CRLITE_FILTER_FULL as u8 {
|
||||
if data_type == nsICertStorage::DATA_TYPE_CRLITE_FILTER_FULL {
|
||||
return Ok(self.crlite_filter.is_some());
|
||||
}
|
||||
if data_type == nsICertStorage::DATA_TYPE_CRLITE_FILTER_INCREMENTAL as u8 {
|
||||
if data_type == nsICertStorage::DATA_TYPE_CRLITE_FILTER_INCREMENTAL {
|
||||
return Ok(self.crlite_stash.is_some());
|
||||
}
|
||||
|
||||
@ -373,7 +373,7 @@ impl SecurityState {
|
||||
|
||||
let st: i16 = match self.read_entry(&issuer_serial) {
|
||||
Ok(Some(value)) => value,
|
||||
Ok(None) => nsICertStorage::STATE_UNSET as i16,
|
||||
Ok(None) => nsICertStorage::STATE_UNSET,
|
||||
Err(_) => {
|
||||
return Err(SecurityStateError::from(
|
||||
"problem reading revocation state (from issuer / serial)",
|
||||
@ -381,13 +381,13 @@ impl SecurityState {
|
||||
}
|
||||
};
|
||||
|
||||
if st != nsICertStorage::STATE_UNSET as i16 {
|
||||
if st != nsICertStorage::STATE_UNSET {
|
||||
return Ok(st);
|
||||
}
|
||||
|
||||
match self.read_entry(&subject_pubkey) {
|
||||
Ok(Some(value)) => Ok(value),
|
||||
Ok(None) => Ok(nsICertStorage::STATE_UNSET as i16),
|
||||
Ok(None) => Ok(nsICertStorage::STATE_UNSET),
|
||||
Err(_) => {
|
||||
return Err(SecurityStateError::from(
|
||||
"problem reading revocation state (from subject / pubkey)",
|
||||
@ -408,7 +408,7 @@ impl SecurityState {
|
||||
let subject_pubkey = make_key!(PREFIX_CRLITE, subject, &pub_key_hash);
|
||||
match self.read_entry(&subject_pubkey) {
|
||||
Ok(Some(value)) => Ok(value),
|
||||
Ok(None) => Ok(nsICertStorage::STATE_UNSET as i16),
|
||||
Ok(None) => Ok(nsICertStorage::STATE_UNSET),
|
||||
Err(_) => Err(SecurityStateError::from("problem reading crlite state")),
|
||||
}
|
||||
}
|
||||
@ -449,7 +449,7 @@ impl SecurityState {
|
||||
&mut writer,
|
||||
&make_key!(
|
||||
PREFIX_DATA_TYPE,
|
||||
&[nsICertStorage::DATA_TYPE_CRLITE_FILTER_FULL as u8]
|
||||
&[nsICertStorage::DATA_TYPE_CRLITE_FILTER_FULL]
|
||||
),
|
||||
&Value::U64(timestamp),
|
||||
)?;
|
||||
@ -529,13 +529,13 @@ impl SecurityState {
|
||||
&reader,
|
||||
&make_key!(
|
||||
PREFIX_DATA_TYPE,
|
||||
&[nsICertStorage::DATA_TYPE_CRLITE_FILTER_FULL as u8]
|
||||
&[nsICertStorage::DATA_TYPE_CRLITE_FILTER_FULL]
|
||||
),
|
||||
) {
|
||||
Ok(Some(Value::U64(timestamp))) => timestamp,
|
||||
// If we don't have a timestamp yet, we won't have a filter. Return the earliest
|
||||
// timestamp possible to indicate this to callers.
|
||||
Ok(None) => return Ok((0, nsICertStorage::STATE_UNSET as i16)),
|
||||
Ok(None) => return Ok((0, nsICertStorage::STATE_UNSET)),
|
||||
Ok(_) => {
|
||||
return Err(SecurityStateError::from(
|
||||
"unexpected type when trying to get Value::U64",
|
||||
@ -545,8 +545,8 @@ impl SecurityState {
|
||||
}
|
||||
};
|
||||
let enrollment_state = self.get_crlite_state(issuer, issuer_spki)?;
|
||||
if enrollment_state != nsICertStorage::STATE_ENFORCE as i16 {
|
||||
return Ok((timestamp, nsICertStorage::STATE_NOT_ENROLLED as i16));
|
||||
if enrollment_state != nsICertStorage::STATE_ENFORCE {
|
||||
return Ok((timestamp, nsICertStorage::STATE_NOT_ENROLLED));
|
||||
}
|
||||
let mut digest = Sha256::default();
|
||||
digest.input(issuer_spki);
|
||||
@ -558,11 +558,11 @@ impl SecurityState {
|
||||
// This can only happen if the backing file was deleted or if it or our database has
|
||||
// become corrupted. In any case, we have no information, so again return the earliest
|
||||
// timestamp to indicate this to the user.
|
||||
None => return Ok((0, nsICertStorage::STATE_UNSET as i16)),
|
||||
None => return Ok((0, nsICertStorage::STATE_UNSET)),
|
||||
};
|
||||
match result {
|
||||
true => Ok((timestamp, nsICertStorage::STATE_ENFORCE as i16)),
|
||||
false => Ok((timestamp, nsICertStorage::STATE_UNSET as i16)),
|
||||
true => Ok((timestamp, nsICertStorage::STATE_ENFORCE)),
|
||||
false => Ok((timestamp, nsICertStorage::STATE_UNSET)),
|
||||
}
|
||||
}
|
||||
|
||||
@ -622,10 +622,7 @@ impl SecurityState {
|
||||
// Make a note that we have prior cert data now.
|
||||
env_and_store.store.put(
|
||||
&mut writer,
|
||||
&make_key!(
|
||||
PREFIX_DATA_TYPE,
|
||||
&[nsICertStorage::DATA_TYPE_CERTIFICATE as u8]
|
||||
),
|
||||
&make_key!(PREFIX_DATA_TYPE, &[nsICertStorage::DATA_TYPE_CERTIFICATE]),
|
||||
&Value::Bool(true),
|
||||
)?;
|
||||
|
||||
@ -1537,7 +1534,7 @@ impl CertStorage {
|
||||
let task = Box::new(try_ns!(SecurityStateTask::new(
|
||||
&*callback,
|
||||
&self.security_state,
|
||||
move |ss| ss.set_batch_state(&entries, nsICertStorage::DATA_TYPE_REVOCATION as u8),
|
||||
move |ss| ss.set_batch_state(&entries, nsICertStorage::DATA_TYPE_REVOCATION),
|
||||
)));
|
||||
let runnable = try_ns!(TaskRunnable::new("SetRevocations", task));
|
||||
try_ns!(TaskRunnable::dispatch(runnable, self.queue.coerce()));
|
||||
@ -1557,7 +1554,7 @@ impl CertStorage {
|
||||
if issuer.is_null() || serial.is_null() || subject.is_null() || pub_key.is_null() {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
*state = nsICertStorage::STATE_UNSET as i16;
|
||||
*state = nsICertStorage::STATE_UNSET;
|
||||
let ss = get_security_state!(self);
|
||||
match ss.get_revocation_state(&*issuer, &*serial, &*subject, &*pub_key) {
|
||||
Ok(st) => {
|
||||
@ -1618,7 +1615,7 @@ impl CertStorage {
|
||||
let task = Box::new(try_ns!(SecurityStateTask::new(
|
||||
&*callback,
|
||||
&self.security_state,
|
||||
move |ss| ss.set_batch_state(&crlite_entries, nsICertStorage::DATA_TYPE_CRLITE as u8),
|
||||
move |ss| ss.set_batch_state(&crlite_entries, nsICertStorage::DATA_TYPE_CRLITE),
|
||||
)));
|
||||
let runnable = try_ns!(TaskRunnable::new("SetCRLiteState", task));
|
||||
try_ns!(TaskRunnable::dispatch(runnable, self.queue.coerce()));
|
||||
@ -1636,7 +1633,7 @@ impl CertStorage {
|
||||
if subject.is_null() || pub_key.is_null() {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
*state = nsICertStorage::STATE_UNSET as i16;
|
||||
*state = nsICertStorage::STATE_UNSET;
|
||||
let ss = get_security_state!(self);
|
||||
match ss.get_crlite_state(&*subject, &*pub_key) {
|
||||
Ok(st) => {
|
||||
@ -1728,7 +1725,7 @@ impl CertStorage {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
*valid_before = 0;
|
||||
*state = nsICertStorage::STATE_UNSET as i16;
|
||||
*state = nsICertStorage::STATE_UNSET;
|
||||
let ss = get_security_state!(self);
|
||||
match ss.get_crlite_revocation_state(&*issuer, &*issuerSPKI, &*serialNumber) {
|
||||
Ok((crlite_timestamp, st)) => {
|
||||
@ -1886,8 +1883,8 @@ impl MemoryReporter {
|
||||
callback.Callback(
|
||||
&nsCStr::new() as &nsACString,
|
||||
&nsCStr::from("explicit/cert-storage/storage") as &nsACString,
|
||||
nsIMemoryReporter::KIND_HEAP as i32,
|
||||
nsIMemoryReporter::UNITS_BYTES as i32,
|
||||
nsIMemoryReporter::KIND_HEAP,
|
||||
nsIMemoryReporter::UNITS_BYTES,
|
||||
size as i64,
|
||||
&nsCStr::from("Memory used by certificate storage") as &nsACString,
|
||||
data,
|
||||
|
@ -43,7 +43,7 @@ impl Action {
|
||||
}
|
||||
|
||||
pub fn as_error_code(&self) -> i32 {
|
||||
let val = match self {
|
||||
match self {
|
||||
Action::StartDownload => nsIBits::ERROR_ACTION_START_DOWNLOAD,
|
||||
Action::MonitorDownload => nsIBits::ERROR_ACTION_MONITOR_DOWNLOAD,
|
||||
Action::Complete => nsIBits::ERROR_ACTION_COMPLETE,
|
||||
@ -53,8 +53,7 @@ impl Action {
|
||||
Action::SetNoProgressTimeout => nsIBits::ERROR_ACTION_SET_NO_PROGRESS_TIMEOUT,
|
||||
Action::Resume => nsIBits::ERROR_ACTION_RESUME,
|
||||
Action::Suspend => nsIBits::ERROR_ACTION_SUSPEND,
|
||||
};
|
||||
val as i32
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ pub enum ErrorType {
|
||||
|
||||
impl ErrorType {
|
||||
pub fn bits_code(&self) -> i32 {
|
||||
let val = match self {
|
||||
match self {
|
||||
ErrorType::NullArgument => nsIBits::ERROR_TYPE_NULL_ARGUMENT,
|
||||
ErrorType::InvalidArgument => nsIBits::ERROR_TYPE_INVALID_ARGUMENT,
|
||||
ErrorType::NotInitialized => nsIBits::ERROR_TYPE_NOT_INITIALIZED,
|
||||
@ -119,8 +119,7 @@ impl ErrorType {
|
||||
ErrorType::BitsStateCancelled => nsIBits::ERROR_TYPE_BITS_STATE_CANCELLED,
|
||||
ErrorType::BitsStateUnexpected => nsIBits::ERROR_TYPE_BITS_STATE_UNEXPECTED,
|
||||
ErrorType::FailedToConnectToBcm => nsIBits::ERROR_TYPE_FAILED_TO_CONNECT_TO_BCM,
|
||||
};
|
||||
val as i32
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -127,7 +127,7 @@ impl MonitorRunnable {
|
||||
}
|
||||
|
||||
pub fn dispatch(&self, thread: RefPtr<nsIThread>) -> Result<(), nsresult> {
|
||||
unsafe { thread.DispatchFromScript(self.coerce(), nsIEventTarget::DISPATCH_NORMAL as u32) }
|
||||
unsafe { thread.DispatchFromScript(self.coerce(), nsIEventTarget::DISPATCH_NORMAL) }
|
||||
.to_result()
|
||||
}
|
||||
|
||||
|
@ -328,7 +328,7 @@ impl BitsRequest {
|
||||
#[allow(non_snake_case)]
|
||||
fn get_bits_transfer_error_nsIBitsRequest(&self) -> Result<i32, nsresult> {
|
||||
let error_type = match self.download_status_error_type.get() {
|
||||
None => nsIBits::ERROR_TYPE_SUCCESS as i32,
|
||||
None => nsIBits::ERROR_TYPE_SUCCESS,
|
||||
Some(error_type) => error_type.bits_code(),
|
||||
};
|
||||
Ok(error_type)
|
||||
|
@ -82,7 +82,7 @@ static PROCESS_TYPE: Lazy<AtomicU32> = Lazy::new(|| {
|
||||
// and introduced a negative process type constant. Default to parent.
|
||||
let process_type = process_type
|
||||
.try_into()
|
||||
.unwrap_or(nsIXULRuntime::PROCESS_TYPE_DEFAULT as u32);
|
||||
.unwrap_or(nsIXULRuntime::PROCESS_TYPE_DEFAULT);
|
||||
// We don't have process-specific init locations outside of the main
|
||||
// process, so we introduce this side-effect to a global static init.
|
||||
// This is the absolute first time we decide which process type we're
|
||||
@ -93,7 +93,7 @@ static PROCESS_TYPE: Lazy<AtomicU32> = Lazy::new(|| {
|
||||
|
||||
#[cfg(feature = "with_gecko")]
|
||||
pub fn need_ipc() -> bool {
|
||||
PROCESS_TYPE.load(Ordering::Relaxed) != nsIXULRuntime::PROCESS_TYPE_DEFAULT as u32
|
||||
PROCESS_TYPE.load(Ordering::Relaxed) != nsIXULRuntime::PROCESS_TYPE_DEFAULT
|
||||
}
|
||||
|
||||
/// The first time we're used in a process,
|
||||
|
@ -58,7 +58,7 @@ impl<F> RunnableBuilder<F> {
|
||||
RunnableBuilder {
|
||||
name,
|
||||
function,
|
||||
priority: nsIRunnablePriority::PRIORITY_NORMAL as u32,
|
||||
priority: nsIRunnablePriority::PRIORITY_NORMAL,
|
||||
options: DispatchOptions::default(),
|
||||
}
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ impl<F> TaskBuilder<F> {
|
||||
TaskBuilder {
|
||||
name,
|
||||
future,
|
||||
priority: nsIRunnablePriority::PRIORITY_NORMAL as u32,
|
||||
priority: nsIRunnablePriority::PRIORITY_NORMAL,
|
||||
options: DispatchOptions::default(),
|
||||
}
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ pub struct DispatchOptions(u32);
|
||||
impl Default for DispatchOptions {
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
DispatchOptions(nsIEventTarget::DISPATCH_NORMAL as u32)
|
||||
DispatchOptions(nsIEventTarget::DISPATCH_NORMAL)
|
||||
}
|
||||
}
|
||||
|
||||
@ -161,7 +161,7 @@ impl DispatchOptions {
|
||||
/// dedicated thread pool, leaving the main pool free for CPU-bound tasks.
|
||||
#[inline]
|
||||
pub fn may_block(self, may_block: bool) -> DispatchOptions {
|
||||
const FLAG: u32 = nsIEventTarget::DISPATCH_EVENT_MAY_BLOCK as u32;
|
||||
const FLAG: u32 = nsIEventTarget::DISPATCH_EVENT_MAY_BLOCK;
|
||||
if may_block {
|
||||
DispatchOptions(self.flags() | FLAG)
|
||||
} else {
|
||||
@ -179,7 +179,7 @@ impl DispatchOptions {
|
||||
/// event target when the event is about to finish.
|
||||
#[inline]
|
||||
pub unsafe fn at_end(self, may_block: bool) -> DispatchOptions {
|
||||
const FLAG: u32 = nsIEventTarget::DISPATCH_AT_END as u32;
|
||||
const FLAG: u32 = nsIEventTarget::DISPATCH_AT_END;
|
||||
if may_block {
|
||||
DispatchOptions(self.flags() | FLAG)
|
||||
} else {
|
||||
|
@ -21,18 +21,18 @@ interface nsIRunnable : nsISupports
|
||||
[scriptable, uuid(e75aa42a-80a9-11e6-afb5-e89d87348e2c)]
|
||||
interface nsIRunnablePriority : nsISupports
|
||||
{
|
||||
const unsigned short PRIORITY_IDLE = 0;
|
||||
const unsigned short PRIORITY_DEFERRED_TIMERS = 1;
|
||||
const unsigned long PRIORITY_IDLE = 0;
|
||||
const unsigned long PRIORITY_DEFERRED_TIMERS = 1;
|
||||
// INPUT_LOW isn't supposed to be used directly.
|
||||
// const unsigned short PRIORITY_INPUT_LOW = 2;
|
||||
const unsigned short PRIORITY_NORMAL = 3;
|
||||
const unsigned short PRIORITY_MEDIUMHIGH = 4;
|
||||
const unsigned short PRIORITY_INPUT_HIGH = 5;
|
||||
const unsigned short PRIORITY_VSYNC = 6;
|
||||
// const unsigned long PRIORITY_INPUT_LOW = 2;
|
||||
const unsigned long PRIORITY_NORMAL = 3;
|
||||
const unsigned long PRIORITY_MEDIUMHIGH = 4;
|
||||
const unsigned long PRIORITY_INPUT_HIGH = 5;
|
||||
const unsigned long PRIORITY_VSYNC = 6;
|
||||
// INPUT_HIGHEST is InputTaskManager's internal priority
|
||||
//const unsigned short PRIORITY_INPUT_HIGHEST = 7;
|
||||
const unsigned short PRIORITY_RENDER_BLOCKING = 8;
|
||||
const unsigned short PRIORITY_CONTROL = 9;
|
||||
//const unsigned long PRIORITY_INPUT_HIGHEST = 7;
|
||||
const unsigned long PRIORITY_RENDER_BLOCKING = 8;
|
||||
const unsigned long PRIORITY_CONTROL = 9;
|
||||
|
||||
readonly attribute unsigned long priority;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user