Skip to content

Commit 1c41558

Browse files
authored
Cleanup tabs sync engine. (#7076)
* Increases the size of the max payload we support to 2MB. * Primary intent was to make sure the sync-specific code and structures exist in the sync module. * In addition, all of the checks for "can this tab fit" relied on a struct that wasn't actually used by Sync. That wasn't a problem in practice but will be as we change these structs. * Also removed old support for returning tabs about clients we don't know about. This impacted tests which often required them too to know about the devices under test. The intent is that this should have no functional changes, but puts us in a better place to start metadata improvements.
1 parent 6a33033 commit 1c41558

File tree

8 files changed

+490
-441
lines changed

8 files changed

+490
-441
lines changed

components/tabs/README.md

Lines changed: 19 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,37 @@
11
# Synced Tabs Component
22

3-
![status-img](https://img.shields.io/static/v1?label=not%20implemented&message=Firefox%20Preview,%20Desktop,%20iOS&color=darkred)
4-
53
## Implementation Overview
64

7-
This crate implements an in-memory syncing engine for remote tabs.
5+
6+
This crate implements storage and a syncing engine for remote tabs, including
7+
for "tab commands" (such as closing a remote tab).
8+
9+
It uses a sqlite database, but only creates the database when remote tabs need
10+
to be stored; eg, just telling this component about local tabs will not create a database.
11+
12+
It is used on Desktop and mobile and uses UniFFI.
813

914
## Directory structure
1015
The relevant directories are as follows:
1116

1217
- `src`: The meat of the library. This contains cross-platform rust code that
1318
implements the syncing of tabs.
14-
- `ffi`: The Rust public FFI bindings. This is a (memory-unsafe, by necessity)
15-
API that is exposed to Kotlin and Swift. It leverages the `ffi_support` crate
16-
to avoid many issues and make it more safe than it otherwise would be.
17-
It uses protocol buffers for marshalling data over the FFI.
18-
- `android`: This contains android bindings to synced tabs, written in Kotlin. These
19-
use JNA to call into to the code in `ffi`.
20-
- `ios`: This contains the iOS binding to synced tabs, written in Swift. These use
21-
Swift's native support for calling code written in C to call into the code in
22-
`ffi`.
23-
24-
## Features
25-
- Synchronization of the local and remote session states.
19+
- `android`: A kotlin wrapper we should try and remove.
2620

2721
## Business Logic
2822

29-
### Storage
23+
Each client tells the component about its local tabs, and can query for other devices and their
24+
tabs.
3025

31-
The storage is all done in memory for simplicity purposes. The host applications are free to persist the remote tabs list if it makes sense to them.
26+
This all then feeds into the single Sync payload for tabs. The core shape is very old,
27+
predating this component. b/w compat concerns always apply, but can safely be "upgraded"
28+
over time.
3229

33-
### Payload format
30+
Tab commands add a layer of complexity - if we've been asked to close a remote tab, we pretend
31+
that tab doesn't exist on the remote for some period, giving that remote device a chance to act
32+
on the request and re-upload its tabs.
33+
34+
## Payload format
3435

3536
Every remote sync record is roughly a list of tabs with their URL history (think of the back button). There is one record for each client.
3637

@@ -39,24 +40,3 @@ Every remote sync record is roughly a list of tabs with their URL history (think
3940
Each remote tabs sync record is associated to a "client" using a `client_id` field, which is really a foreign-key to a `clients` collection record.
4041
However, because we'd like to move away from the clients collection, which is why this crate associates these records with Firefox Accounts device ids.
4142
Currently for platforms using the sync-manager provided in this repo, the `client_id` is really the Firefox Accounts device ID and all is well, however for older platforms it is a distinct ID, which is why we have to feed the `clients` collection to this Tabs Sync engine to associate the correct Firefox Account device id.
42-
43-
## Getting started
44-
45-
**Prerequisites**: Firefox account authentication is necessary to obtain the keys to decrypt synced tabs data. See the [android-components FxA Client readme](https://github.com/mozilla-mobile/android-components/blob/master/components/service/firefox-accounts/README.md) for details on how to implement on Android. For iOS, Firefox for iOS still implement the legacy oauth.
46-
47-
**Platform-specific details**:
48-
- <TODO-ST> Android
49-
- iOS: start with the [guide to consuming rust components on iOS](https://github.com/mozilla/application-services/blob/main/docs/howtos/consuming-rust-components-on-ios.md)
50-
51-
## API Documentation
52-
- TODO
53-
54-
## Testing
55-
56-
<TODO-ST>
57-
58-
## Telemetry
59-
<TODO-ST>
60-
61-
## Examples
62-
<TODO-ST>

components/tabs/src/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@ pub use crate::store::{RemoteCommandStore, TabsStore};
3535
pub use error::{ApiResult, Error, Result, TabsApiError};
3636
use sync15::DeviceType;
3737

38-
pub use crate::sync::engine::get_registered_sync_engine;
39-
40-
pub use crate::sync::bridge::TabsBridgedEngine;
41-
pub use crate::sync::engine::TabsEngine;
38+
pub use crate::sync::{get_registered_sync_engine, TabsBridgedEngine, TabsEngine};
4239

4340
#[derive(Clone, Eq, PartialEq, Debug)]
4441
pub enum RemoteCommand {

0 commit comments

Comments
 (0)