Граф коммитов

111 Коммитов

Автор SHA1 Сообщение Дата
lougeniac64 cc29c6925f Removed obsolete iOS sync logic 2023-07-17 22:39:21 +00:00
Ben Dean-Kawamura 14fae5c7f0 Upgrading to UniFFI 0.24 and Glean to 53.1.0 2023-07-05 20:48:54 +00:00
Sammy Khamis 42c35214dc move/port sync manager metrics from android into appservices and rename to fix iOS name collision 2023-06-07 00:52:32 +00:00
Mark Hammond 5802165598
Remove duplicate DeviceType enums. (#5316) 2023-04-28 05:35:26 +10:00
lougeniaC64 6d91c28a52
Added iOS sync telemetry reporting logic (#5479) 2023-04-14 15:27:52 -04:00
lougeniaC64 f562aff7a7
Exposed sync manager component to iOS (#5359) 2023-02-24 11:19:08 -05:00
Ben Dean-Kawamura 6ecde0b247 Don't use workspace dependencies for UniFFI.
This was really nice, but it breaks when we get vendored in to
moz-central.  So we have to go back to the dark ages.
2023-01-30 12:26:58 -05:00
Ben Dean-Kawamura b3a573164e Clippy and check-dependency fixes 2023-01-27 15:32:17 -05:00
Ben Dean-Kawamura a79f23574f Updating UniFFI to version 0.23
- Switched to using workspace dependencies, this will make future
  updates much simpler
- Updated code to work with the new UniFFI crate structure
- Updated the error-support integration tests to work with the workspace
  dependencies, following this advice: https://stackoverflow.com/a/71461114.
2023-01-27 12:38:55 -05:00
Mark Hammond 24098bcafd
Update rust version to 1.65.0, MSR to 1.61 (#5299) 2022-12-16 14:02:22 +11:00
Ben Dean-Kawamura f50d60cbb3 Replaced `log::error!` calls with `error_support::report_error!`
Went through all the main app-services components and replaced the
old-style `log::error!` calls with `error_support::report_error!`.

Removed the `reporting` feature of `error-support` and made it
always-enabled.

Renamed the `report_error` function so that it's name doesn't clash with
the `report_error` macro
2022-10-27 18:37:46 -04:00
Ben Dean-Kawamura 084ec6b8cf Rename `LoginsStorageError` to `LoginsApiError`
I think this name communicates it's purpose better and is more
consistent with other components.

Renamed `LoginsError` to `Error` for the same reasons as the change from
`PlacesError` to `Error`

Changed `logins.udl` to use the fielded error style.  Updated
`LoginsApiError` to use named fields to be compatibile with this.

Removed the `RequestFailed` variant, based on the note next to it.
2022-10-27 18:37:45 -04:00
Ben Dean-Kawamura 01aeb370c3 Further reworked the places errors
- Renamed `PlacesInternalError` to `Error` because it seems more
  idiomatic
- Renamed `PlacesError` to `PlacesApiError` to make it consistent with
  the logins errors.  I considered just calling this `ApiError` but I
  thought that would be confusing for consumers since they won't always
  have the `places::` prefix before the class name.
- Removed `JsonError`, which seems like it was unusped
- Merged `InternalError` into `UnexpectedPlacesException`
- Merged `UrlTooLong` into `UrlParseFailed` for `PlacesApiError`
- Merged `InvalidBookmarkUpdate`, `CannotUpdateRoot`, `InvalidParent`
  into `InvalidBookmarkOperation` for `PlacesApiError`

Use the fielded style for `PlacesApiError` in places.udl.  Updated
`PlacesApiError` to use named fields to be compatible with this.

On swift renamed `PlacesApiError`, which was defined on top of the
normal errors to `PlacesConnectionError`.
2022-10-27 18:37:45 -04:00
Ben Dean-Kawamura 1c4093bb3d Refactored places to use the new error handling system
Replaced the error_support method with the new system that consists of:
  - `PlacesInternalError`: used internally in the crate.  This replaces
    the old `ErrorKind` enum and is the error for `Result<>`.
  - `PlacesError`: used for external errors that we return to UniFFI
    consumers.  This replaces the old `Error` enum and is the error for
    `ApiResult<>`
  - A `GetErrorHandling` impl to convert internal errors to external
    errors and report to sentry.  For now, I tried to make the sentry
    error reporting more-or-less match the old error reporting, which
    means reporting lots of internal errors.  The plan is going to be to
    check sentry and most likely turn some of those into logs rather
    than errors.

Reworked all top-level API methods to return `PlacesApiResults` and use
the `handle_error!` macro to do the error conversion/reporting.

Use `thiserror` to handle converting errors from other crates into
`PlacesInternalError`.
2022-10-20 09:05:59 -04:00
Ben Dean-Kawamura 7155bbb4a9 Updating UniFFI to 0.21.0 2022-10-19 11:37:03 -04:00
Mark Hammond e21ad997c3
Sync Manager syncs engines in a deterministic order, fixes #5171 (#5172) 2022-10-13 11:11:13 +11:00
Mark Hammond d8503475f4
Merge sync15-traits back into sync15 via features. (#5125) 2022-09-15 11:09:04 +10:00
Ben Dean-Kawamura b82517cde3 Updating Rust versions to 1.61/1.63
This matches the nightly versions for FF desktop.
2022-09-13 19:13:44 -04:00
Mark Hammond e5d8a6d76c
Get sync-test working again. (#5107)
sync-test was removed from the workspace some time ago, which meant it
was never built or checked, so it went quite stale, particularly with
respect to logins changes.

We not keep it in the workspace but as an "excluded" item, which means
you can run it from its directory. To prevent it going stale again, CI
runs clippy on it.

Also needed a few misc tweaks to some other crates.
2022-09-08 20:02:18 +10:00
Mark Hammond 71cb0f6fa4
Add a 'full-sync' feature to tabs. (#5102)
If the new feature is enabled, tabs can sync - otherwise it can not.
The intention is that later there will be a "bridged-sync" feature,
and that in-practice, one or the other will be enabled - however, the
way features work, it must be possible that no features are enabled.

The new feature is not a default feature because I expect we will
want the default features to be what desktop consumes - ie, that
the default feature will be bridged-sync once that exists.

This isn't strictly required yet, but is being done now to make
future reviews of the bridged engine easier to reason about.
2022-09-01 10:52:50 +10:00
Tarik Eshaq ad9dd96c60
Adds error-support to the iOS megazords (#5094)
* Adds error-support to the iOS megazords

* Updates UniFFI to 0.19

* Adds changelog

* fixup dependency summaries

* Fixup changelog
2022-08-29 13:01:30 -07:00
Mark Hammond 5c63cc5c40
Move the bso_record and key_bundle into the sync15_traits crate. (#5083)
(Which further reinforces that the name of that crate should be something like
`sync15-types`)

This is preparatory work for a much larger patch that will get us further down
the path to #2841 and also fix #2712. It should not change any behaviour.

As part of this, the sync15_traits errors needs to be addressed. It's not
reasonable to just create another enum that we expect clients to add to
their error types because many of the errors overlap which makes handling
them very difficult (eg, if we want to catch a serde error, you don't want
to know which crate it originated in) - so sync15 duplicates the sync15_traits
errors and can convert between them - so consumers can continue to catch
sync15::Error and still get errors which originated in sync15-traits.

sync15-traits now has a `crypto` feature - sync15 enables that feature, but
crates which just use a `bridged_engine` do not. This means that when
vendoring into Desktop Firefox, this feature isn't enabled, so we don't
pull in any of the crypto libs there.
2022-08-22 13:43:10 +10:00
Ben Dean-Kawamura 72d6425836 Reworking the logins error handling (#5033)
- Use `thiserror` only to define our errors rather than a weird
  combination of `thiserror` and `error_support`
- There's now a few error enums:
  - `LoginsStorageError` is for public API errors
  - `LoginsError` is for internal errors
  - `InvalidLoginsReason` is a subtype for `LoginsError::InvalidLogin`
- Extracted the error tracking code from `impl From<LoginsError>
  for LoginsStorageError` and put it in its own methods.
- Made `LoginsError::InvalidKey` convert to
  `LoginsStorageError::CryptoError`.  I think this makes sense since
  from the app's point of view an invalid key is the same thing as
  data that can't be decrypted.  Note: that `InvalidKey` used to mean
  something different when we were using sqlcipher databases, but that's
  not applicable anymore.
- Dropped the `throw!` macro.  The error types are simple enough now
  that we can just use a return statement.
- Added note about PII
- Renamed `LoginsError::label()` to `LoginsError::group_name()`
- Updated the rest of the code to use the new API
- Removed the backtrace functionality from `sync-pass`.  I'm kind of
  doubt it was working anyways.
2022-07-13 13:56:31 +10:00
Mark Hammond e7537c93a4
Put the new error-reporting capability behind a feature (#4987) 2022-06-07 09:25:17 +10:00
Ben Dean-Kawamura d163d0561f Added error reporting code to track down #4856
Report breadcrumbs for:
  - Syncing
  - History DB operations that delete rows.
  - The delete_everything transaction

Added code to report errors from `delete_everything_history`.

Added changelog entry
2022-06-02 12:56:22 -04:00
Mark Hammond 627426f567
Depend on parking_lot 0.11 or 0.12 so app-services and mozilla-central can use different versions (#4962) 2022-05-20 11:03:16 +10:00
Tarik Eshaq a6af58fac6
Bumps uniffi to 0.18 [ci full] (#4949)
* Bumps uniffi to 0.18

* Fixes dependency summaries

* Fixes uniffi duplicate type definitions

* Adds changelog

* Renames Timestamp to PlacesTimestamp

* Adds focus dependency changes from rebase

* Fix typo in dependency summaries comment
2022-05-16 10:26:20 -07:00
Tarik Eshaq f7c5588b1e
Update rand and parking lot (#4937)
* Update rand and parking_lot.

I need this to update other Gecko dependencies.

* Update dependency_summary to account for various windows-rs crates.

I'm not sure why it wasn't failing to find the relevant licenses before,
it was likely a pre-existing issue.

* Update dependency summaries.

* Runs dependency summaries on a mac

Co-authored-by: Emilio Cobos Álvarez <emilio@crisal.io>
2022-05-02 17:18:12 -07:00
Mark Hammond 862e30d43f
Remove duplicate DeviceType enum implementations. (#4397) 2022-02-23 10:09:59 +11:00
Ben Dean-Kawamura f504aa09ae Refactoring the interrupt code
- Refactored the `SqlInterruptHandle` and `SqlInterruptScope` types to
  work better with the new code.

  - Types now store an `SqlInterruptHandle` and use that to create
    `SqlInterruptScope` instances. This seems more natural than storing
    an `Arc<AtomicUsize>` and using that to create both the scope and
    handle.
  - Creating an `SqlInterruptScope` can fail if we are in shutdown mode.
    Updated the calling code to handle this error.
  - We now use `Ordering::Relaxed`.  This has less overhead compared to
    `Ordering::SeqCst` and I'm pretty sure we don't need the extra
    synchronization guarantees

- Moved the `Interrupted` and `Interuptee` types to their own modules.
  Updated the shutdown module documentation.

- Changed the `PlacesApi` sync methods to to just send `NeverInterrupts`
  to the `sync_multiple()`.  I think this is fine given that we only use
  these methods on iOS and we don't have actual interruption support
  there yet.

- Removed the `PlacesApi::new_sync_conn_interrupt_handle()` method.  If we want
  to interrupt syncing, then we should just enter shutdown mode.
2022-02-16 10:57:10 -05:00
Ben Dean-Kawamura db23ab40f6 Moving modules from sql-support to interrupt-support
The `SqlInterruptHandle` and `SqlInterruptScope` types and especially
the shutdown code feels like belongs in `interrupt-support` better than
`sql-support`.

Removed the `implement_into_ffi_by_pointer!(SqlInterruptHandle)` call.
I don't think we need that now that everything is UniFFIed.
2022-02-16 10:57:10 -05:00
jhugman 98e611c51d
Prepare components for using uniffi Custom types (#4829) r=bdk
* Prepare Nimbus for using uniffi Custom types

* Update places to use renamed Custom types

* Increment uniffi version number

* Update Cargo.lock

* Fixup ktlint
2022-02-08 16:52:37 +00:00
Tarik Eshaq 68c10e0673
upgrades to rust 2021 [ci full] (#4822)
* upgrades to rust 2021

* Push rust minimum version to 1.57
2022-02-07 09:38:05 -08:00
Sammy Khamis 73427f79a6
Places uniffication (#4770)
* initial conversion of errors for places uniffication

* Converted history metadata functions for places uniffication

* Converted kotlin history metadata functions

* Converted iOS history metadata functions

* [Places uniffication] Fix places error issues (#4687)

* remove uniffi-specific wrapper and updated error test

* Uniffi VisitObservation and apply_observation (#4689)

* uniffied VisitObservation, HistoryVisitInfo and methods using those structs

* Uniffi top frecent site info (#4711)

* Uniffi top frecent site info

* Uniffis FrecencyThresholdOption

* Uniffi Places Sync (#4714)

* uniffi places sync and sync15 functions

* Uniffi Search result and match url (#4720)

* Uniffi query autocomplete

* uniffi places_accept_result

* uniffi places_match_url

* cargo fmt

* cargo clippy

* remove accept_result from ffi crate

* Adds comment on the uniffi bug with varaint shadowing type

* Uniffi Places Interrupt methods (#4726)

* uniffi places interrupt functions

* Consolidate types (#4736)

* Updates the visit observation to use URL

* Uses VisitTransition for HistoryVisitInfo

* updates uniffi to 0.16

* Uniffied bookmarks

* switch to use uint in the apis for adding bookmarks (#4747)

* Remove the manual places FFI entirely.

* folders and separators now have non-nullable parents

* Always insert via Insertable items, and clarify separation between node types.

* Add json_tree module with all json-based types and implementation.

* Fix swift warnings re non-null parentGuid

* bookmarks: Remove public_node and introduce a fetch module

* Update swift code to make breaking changes fixes cleaner (#4766)

* rebased and added changelog entry

Co-authored-by: lougeniac64 <lougeniaC64@users.noreply.github.com>
Co-authored-by: Tarik Eshaq <teshaq@mozilla.com>
Co-authored-by: Mark Hammond <mhammond@skippinet.com.au>
2022-01-20 15:00:00 -05:00
Ben Dean-Kawamura c4c7774c59 Cleaning up Sync Manager code
Added an enum that contains all possible sync engines and a method to
iterate over registered sync engines.  Used that, plus the existing
`get_engine()` method to remove a lot of redundant code.

Use "passwords" to identify the logins engine in `wipe()`, `reset()` and
other methods (#4728)
2021-12-14 09:34:09 -05:00
Mark Hammond 59c049af40
Update to uniffi 0.15.2 (#4677) 2021-11-25 12:00:46 +11:00
Mark Hammond 2661c5d74c
Move to parking_lot::Mutex in logins, places and sync_manager (#4663) 2021-11-22 11:00:53 +11:00
Ben Dean-Kawamura de16ab8d36 Added method to check which sync engines are available
This allows us to test register_with_sync_manager
2021-11-17 09:28:39 -05:00
Ben Dean-Kawamura 9159829fc1 Updating SyncManager documentation 2021-11-17 09:28:39 -05:00
Ben Dean-Kawamura c63dd82c8a UniFFI SyncManager
- Replaced hand-written FFI code with UniFFI code
- Updated error handling to just use thiserror.  There's no need for
  error-support anymore.
- Added an enum for the SyncParams.engine.  This seems cleaner than
  having None mean sync all engines.
- Replaced `SyncResult.results` with `SyncResult.successful` and
  `SyncSyncResult.failures`.  Before this was handled in the Kotlin
  wrapaper code.
- Made the megazord depend on tabs directly.  Before it pulled in tabs
  because of a transitive dependency from sync_manager_ffi.
2021-11-17 09:28:39 -05:00
Ben Dean-Kawamura 1a2d97a23f Added mutex for the sync manager MemCachedState
This allows the SyncManager methods follow the UniFFI model and take
`&self` rather than `&mut self`.
2021-11-17 09:28:39 -05:00
Ben Dean-Kawamura 4e55cd8733 Use the new places sync manager code
- Updated sync_manager to use `places::get_registered_sync_engine` rather
  than having places call `sync_manager::set_places`.

- Updated the FFI code
2021-11-17 09:28:37 -05:00
Mark Hammond ff6156416b
We rely on url version 2.2 and just got lucky that we had it (#4489) 2021-09-22 07:56:29 +10:00
Ryan Kelly c12b286312 Extract the bulk of shared gradle logic into script plugins.
Prior to this commit, the `build.gradle` for each individual
project contained copy-pasted logic for configuring Android
and protobuf. Some of them were even using slightly different
versions of the same dependencies.

With this commit, there are two new gradle scripts that encapsulate
this shared logic:

* ./build-scripts/component-common.gradle, for basic Android
  and Kotlin setup.
* ./build-scripts/protobuf-common.gradle, for configuration specific
  to the protobuf plugin.

Hopefully this will make the logic easier to maintain going forward.
2021-07-20 13:56:15 +10:00
Ryan Kelly 28e4982cd2
Consolidate megazord-related gradle logic into a shared helper. (#4187)
Prior to this commit, each of our individual components had its
own copy of gradle logic for depending on the megazord, including
a couple of lengthy comments about fiddling around with JNA for
the Android Studio test runner.

I've moved all that logic into a helper function in `publish.gradle`
so that we can maintain it in a single location from here out.
There may be a cleaner or more idiomatic way to achieve this kind
of code-sharing in gradle, but I figure this *has* to be better
than our current copy-paste-based approach.

I've manually confirmed that a local `./gradlew test` completes
successfully, as well as testing via Android Studio.
2021-07-19 13:14:08 +10:00
Sammy Khamis d0b7b74cea
Uniffi-ing the Tabs component (#4192)
* uniffi-ed the tabs component

Co-authored-by: Grisha Kruglov <gkruglov@mozilla.com>
2021-07-13 09:40:33 -10:00
Tarik Eshaq 46fccb5cea Updates cargo dependencies and bumps prost to 0.8 2021-07-12 15:39:18 +10:00
Sammy Khamis b43d90441d
Uniffi-ing the Logins component (#4068)
* converting logins to using uniffi

* nits and review changes

* update changelog to put breaking changes on top
2021-06-08 15:29:01 -10:00
Mark Hammond 3f3c551840
Use uniffi's [Self=ByArc] and kill the Store/StoreImpl split (#4145) 2021-05-27 11:08:30 +10:00
Mark Hammond 5570a07379 logins: split the DB from the sync engine 2021-05-21 07:51:26 +10:00