diff --git a/services/fxaccounts/rust-bridge/firefox-accounts-bridge/src/bridge.rs b/services/fxaccounts/rust-bridge/firefox-accounts-bridge/src/bridge.rs index 284923f10a89b..7aa768c781f42 100644 --- a/services/fxaccounts/rust-bridge/firefox-accounts-bridge/src/bridge.rs +++ b/services/fxaccounts/rust-bridge/firefox-accounts-bridge/src/bridge.rs @@ -24,17 +24,18 @@ use xpcom::{ macro_rules! punt { - ($fn_name:ident $(, $arg:ident)*) => { - paste::expr! { + ($fn_name:ident $(, $arg:ident : $ty:ty)*) => { + fn $fn_name(&self $(, $arg: $ty)*, callback: &mozIFirefoxAccountsBridgeCallback) -> Result<()> { if let Some(fxa) = self.fxa.get() { - let task = PuntTask::[](fxa $(, $arg)* ,callback)?; + let task_fn = paste::expr! { PuntTask::[] }; + let task = task_fn(fxa $(, $arg)*, callback)?; task.dispatch(&self.thread)?; Ok(()) } else { Err(Error::Unavailable) } } - }; + } } @@ -108,9 +109,8 @@ impl Bridge { callback: *const mozIFirefoxAccountsBridgeCallback ) ); - fn to_json(&self, callback: &mozIFirefoxAccountsBridgeCallback) -> Result<()> { - punt!(to_json) - } + + punt!(to_json); xpcom_method!( begin_oauth_flow => BeginOAuthFlow( @@ -118,13 +118,8 @@ impl Bridge { callback: *const mozIFirefoxAccountsBridgeCallback ) ); - fn begin_oauth_flow( - &self, - scopes: &ThinVec, - callback: &mozIFirefoxAccountsBridgeCallback, - ) -> Result<()> { - punt!(begin_oauth_flow, scopes) - } + + punt!(begin_oauth_flow, scopes: &ThinVec); xpcom_method!( complete_oauth_flow => CompleteOAuthFlow( @@ -133,23 +128,15 @@ impl Bridge { callback: *const mozIFirefoxAccountsBridgeCallback ) ); - fn complete_oauth_flow( - &self, - code: &nsACString, - state: &nsACString, - callback: &mozIFirefoxAccountsBridgeCallback, - ) -> Result<()> { - punt!(complete_oauth_flow, code, state) - } + + punt!(complete_oauth_flow, code: &nsACString, state: &nsACString); xpcom_method!( disconnect => Disconnect( callback: *const mozIFirefoxAccountsBridgeCallback ) ); - fn disconnect(&self, callback: &mozIFirefoxAccountsBridgeCallback) -> Result<()> { - punt!(disconnect) - } + punt!(disconnect); xpcom_method!( get_access_token => GetAccessToken( @@ -158,53 +145,36 @@ impl Bridge { callback: *const mozIFirefoxAccountsBridgeCallback ) ); - fn get_access_token( - &self, - scope: &nsACString, - ttl: u64, - callback: &mozIFirefoxAccountsBridgeCallback, - ) -> Result<()> { - punt!(get_access_token, scope, ttl) - } + punt!(get_access_token, scope: &nsACString, ttl: u64); xpcom_method!( get_session_token => GetSessionToken( callback: *const mozIFirefoxAccountsBridgeCallback ) ); - fn get_session_token(&self, callback: &mozIFirefoxAccountsBridgeCallback) -> Result<()> { - punt!(get_session_token) - } + + punt!(get_session_token); xpcom_method!( get_attached_clients => GetAttachedClients( callback: *const mozIFirefoxAccountsBridgeCallback ) ); - fn get_attached_clients(&self, callback: &mozIFirefoxAccountsBridgeCallback) -> Result<()> { - punt!(get_attached_clients) - } + punt!(get_attached_clients); xpcom_method!( check_authorization_status => CheckAuthorizationStatus( callback: *const mozIFirefoxAccountsBridgeCallback ) ); - fn check_authorization_status( - &self, - callback: &mozIFirefoxAccountsBridgeCallback, - ) -> Result<()> { - punt!(check_authorization_status) - } + punt!(check_authorization_status); xpcom_method!( clear_access_token_cache => ClearAccessTokenCache( callback: *const mozIFirefoxAccountsBridgeCallback ) ); - fn clear_access_token_cache(&self, callback: &mozIFirefoxAccountsBridgeCallback) -> Result<()> { - punt!(clear_access_token_cache) - } + punt!(clear_access_token_cache); xpcom_method!( handle_session_token_change => HandleSessionTokenChange( @@ -212,13 +182,8 @@ impl Bridge { callback: *const mozIFirefoxAccountsBridgeCallback ) ); - fn handle_session_token_change( - &self, - session_token: &nsACString, - callback: &mozIFirefoxAccountsBridgeCallback, - ) -> Result<()> { - punt!(handle_session_token_change, session_token) - } + + punt!(handle_session_token_change, session_token: &nsACString); xpcom_method!( migrate_from_session_token => MigrateFromSessionToken( @@ -229,43 +194,29 @@ impl Bridge { callback: *const mozIFirefoxAccountsBridgeCallback ) ); - fn migrate_from_session_token( - &self, + + punt!( + migrate_from_session_token, session_token: &nsACString, k_sync: &nsACString, k_xcs: &nsACString, - copy_session_token: bool, - callback: &mozIFirefoxAccountsBridgeCallback, - ) -> Result<()> { - punt!( - migrate_from_session_token, - session_token, - k_sync, - k_xcs, - copy_session_token - ) - } + copy_session_token: bool + ); xpcom_method!( retry_migrate_from_session_token => RetryMigrateFromSessionToken( callback: *const mozIFirefoxAccountsBridgeCallback ) ); - fn retry_migrate_from_session_token( - &self, - callback: &mozIFirefoxAccountsBridgeCallback, - ) -> Result<()> { - punt!(retry_migrate_from_session_token) - } + + punt!(retry_migrate_from_session_token); xpcom_method!( is_in_migration_state => IsInMigrationState( callback: *const mozIFirefoxAccountsBridgeCallback ) ); - fn is_in_migration_state(&self, callback: &mozIFirefoxAccountsBridgeCallback) -> Result<()> { - punt!(is_in_migration_state) - } + punt!(is_in_migration_state); xpcom_method!( get_profile => GetProfile( @@ -273,37 +224,23 @@ impl Bridge { callback: *const mozIFirefoxAccountsBridgeCallback ) ); - fn get_profile( - &self, - ignore_cache: bool, - callback: &mozIFirefoxAccountsBridgeCallback, - ) -> Result<()> { - punt!(get_profile, ignore_cache) - } + punt!(get_profile, ignore_cache: bool); xpcom_method!( get_token_server_endpoint_url => GetTokenServerEndpointURL( callback: *const mozIFirefoxAccountsBridgeCallback ) ); - fn get_token_server_endpoint_url( - &self, - callback: &mozIFirefoxAccountsBridgeCallback, - ) -> Result<()> { - punt!(get_token_server_endpoint_url) - } + + punt!(get_token_server_endpoint_url); xpcom_method!( get_connection_success_url => GetConnectionSuccessURL( callback: *const mozIFirefoxAccountsBridgeCallback ) ); - fn get_connection_success_url( - &self, - callback: &mozIFirefoxAccountsBridgeCallback, - ) -> Result<()> { - punt!(get_connection_success_url) - } + + punt!(get_connection_success_url); xpcom_method!( get_manage_account_url => GetManageAccountURL( @@ -311,13 +248,7 @@ impl Bridge { callback: *const mozIFirefoxAccountsBridgeCallback ) ); - fn get_manage_account_url( - &self, - entrypoint: &nsACString, - callback: &mozIFirefoxAccountsBridgeCallback, - ) -> Result<()> { - punt!(get_manage_account_url, entrypoint) - } + punt!(get_manage_account_url, entrypoint: &nsACString); xpcom_method!( get_manage_devices_url => GetManageDevicesURL( @@ -325,13 +256,7 @@ impl Bridge { callback: *const mozIFirefoxAccountsBridgeCallback ) ); - fn get_manage_devices_url( - &self, - entrypoint: &nsACString, - callback: &mozIFirefoxAccountsBridgeCallback, - ) -> Result<()> { - punt!(get_manage_devices_url, entrypoint) - } + punt!(get_manage_devices_url, entrypoint: &nsACString); xpcom_method!( fetch_devices => FetchDevices( @@ -339,13 +264,8 @@ impl Bridge { callback: *const mozIFirefoxAccountsBridgeCallback ) ); - fn fetch_devices( - &self, - ignore_cache: bool, - callback: &mozIFirefoxAccountsBridgeCallback, - ) -> Result<()> { - punt!(fetch_devices, ignore_cache) - } + + punt!(fetch_devices, ignore_cache: bool); xpcom_method!( set_device_display_name => SetDeviceDisplayName( @@ -353,13 +273,7 @@ impl Bridge { callback: *const mozIFirefoxAccountsBridgeCallback ) ); - fn set_device_display_name( - &self, - name: &nsACString, - callback: &mozIFirefoxAccountsBridgeCallback, - ) -> Result<()> { - punt!(set_device_display_name, name) - } + punt!(set_device_display_name, name: &nsACString); xpcom_method!( handle_push_message => HandlePushMessage( @@ -367,22 +281,16 @@ impl Bridge { callback: *const mozIFirefoxAccountsBridgeCallback ) ); - fn handle_push_message( - &self, - payload: &nsACString, - callback: &mozIFirefoxAccountsBridgeCallback, - ) -> Result<()> { - punt!(handle_push_message, payload) - } + + punt!(handle_push_message, payload: &nsACString); xpcom_method!( poll_device_commands => PollDeviceCommands( callback: *const mozIFirefoxAccountsBridgeCallback ) ); - fn poll_device_commands(&self, callback: &mozIFirefoxAccountsBridgeCallback) -> Result<()> { - punt!(poll_device_commands) - } + + punt!(poll_device_commands); xpcom_method!( send_single_tab => SendSingleTab( @@ -392,15 +300,7 @@ impl Bridge { callback: *const mozIFirefoxAccountsBridgeCallback ) ); - fn send_single_tab( - &self, - target_id: &nsACString, - title: &nsACString, - url: &nsACString, - callback: &mozIFirefoxAccountsBridgeCallback, - ) -> Result<()> { - punt!(send_single_tab, target_id, title, url) - } + punt!(send_single_tab, target_id: &nsACString, title: &nsACString, url: &nsACString); xpcom_method!( set_device_push_subscription => SetDevicePushSubscription( @@ -410,15 +310,8 @@ impl Bridge { callback: *const mozIFirefoxAccountsBridgeCallback ) ); - fn set_device_push_subscription( - &self, - endpoint: &nsACString, - public_key: &nsACString, - auth_key: &nsACString, - callback: &mozIFirefoxAccountsBridgeCallback, - ) -> Result<()> { - punt!(set_device_push_subscription, endpoint, public_key, auth_key) - } + + punt!(set_device_push_subscription, endpoint: &nsACString, public_key: &nsACString, auth_key: &nsACString); xpcom_method!( initialize_device => InitializeDevice( @@ -428,15 +321,8 @@ impl Bridge { callback: *const mozIFirefoxAccountsBridgeCallback ) ); - fn initialize_device( - &self, - name: &nsACString, - device_type: &nsACString, - supported_capabilities: &ThinVec, - callback: &mozIFirefoxAccountsBridgeCallback, - ) -> Result<()> { - punt!(initialize_device, name, device_type, supported_capabilities) - } + + punt!(initialize_device, name: &nsACString, device_type: &nsACString, supported_capabilities: &ThinVec); xpcom_method!( ensure_capabilities => EnsureCapabilities( @@ -444,11 +330,6 @@ impl Bridge { callback: *const mozIFirefoxAccountsBridgeCallback ) ); - fn ensure_capabilities( - &self, - supported_capabilities: &ThinVec, - callback: &mozIFirefoxAccountsBridgeCallback, - ) -> Result<()> { - punt!(ensure_capabilities, supported_capabilities) - } + + punt!(ensure_capabilities, supported_capabilities: &ThinVec); }