Revert (Bug 1956519, Bug 1965086) - for causing bc failures @browser_quicksuggest_dynamicSuggestions.js.

This reverts commit 49a5a6c0bf.

Revert "Bug 1965086 - Vendor app-services 72a070750ff979f4aac29da7c02a9cb6e53ac087, r=nanj"

This reverts commit 7b45ba29ff.
This commit is contained in:
agoloman
2025-05-15 21:39:22 +03:00
committed by agoloman@mozilla.com
parent 91327bb458
commit d66860ebe0
14 changed files with 130 additions and 251 deletions

View File

@@ -70,9 +70,9 @@ git = "https://github.com/jfkthame/mapped_hyph.git"
rev = "eff105f6ad7ec9b79816cfc1985a28e5340ad14b"
replace-with = "vendored-sources"
[source."git+https://github.com/mozilla/application-services?rev=72a070750ff979f4aac29da7c02a9cb6e53ac087"]
[source."git+https://github.com/mozilla/application-services?rev=40ae79e2825fa242a349e17fcfc84fb99fd92197"]
git = "https://github.com/mozilla/application-services"
rev = "72a070750ff979f4aac29da7c02a9cb6e53ac087"
rev = "40ae79e2825fa242a349e17fcfc84fb99fd92197"
replace-with = "vendored-sources"
[source."git+https://github.com/mozilla/audioipc?rev=e6f44a2bd1e57d11dfc737632a9e849077632330"]

32
Cargo.lock generated
View File

@@ -1894,7 +1894,7 @@ dependencies = [
[[package]]
name = "error-support"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=72a070750ff979f4aac29da7c02a9cb6e53ac087#72a070750ff979f4aac29da7c02a9cb6e53ac087"
source = "git+https://github.com/mozilla/application-services?rev=40ae79e2825fa242a349e17fcfc84fb99fd92197#40ae79e2825fa242a349e17fcfc84fb99fd92197"
dependencies = [
"error-support-macros",
"lazy_static",
@@ -1906,7 +1906,7 @@ dependencies = [
[[package]]
name = "error-support-macros"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=72a070750ff979f4aac29da7c02a9cb6e53ac087#72a070750ff979f4aac29da7c02a9cb6e53ac087"
source = "git+https://github.com/mozilla/application-services?rev=40ae79e2825fa242a349e17fcfc84fb99fd92197#40ae79e2825fa242a349e17fcfc84fb99fd92197"
dependencies = [
"proc-macro2",
"quote",
@@ -2025,7 +2025,7 @@ dependencies = [
[[package]]
name = "firefox-versioning"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=72a070750ff979f4aac29da7c02a9cb6e53ac087#72a070750ff979f4aac29da7c02a9cb6e53ac087"
source = "git+https://github.com/mozilla/application-services?rev=40ae79e2825fa242a349e17fcfc84fb99fd92197#40ae79e2825fa242a349e17fcfc84fb99fd92197"
dependencies = [
"serde_json",
"thiserror 1.999.999",
@@ -3365,7 +3365,7 @@ dependencies = [
[[package]]
name = "interrupt-support"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=72a070750ff979f4aac29da7c02a9cb6e53ac087#72a070750ff979f4aac29da7c02a9cb6e53ac087"
source = "git+https://github.com/mozilla/application-services?rev=40ae79e2825fa242a349e17fcfc84fb99fd92197#40ae79e2825fa242a349e17fcfc84fb99fd92197"
dependencies = [
"lazy_static",
"parking_lot",
@@ -5086,7 +5086,7 @@ checksum = "d01a5bd0424d00070b0098dd17ebca6f961a959dead1dbcbbbc1d1cd8d3deeba"
[[package]]
name = "payload-support"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=72a070750ff979f4aac29da7c02a9cb6e53ac087#72a070750ff979f4aac29da7c02a9cb6e53ac087"
source = "git+https://github.com/mozilla/application-services?rev=40ae79e2825fa242a349e17fcfc84fb99fd92197#40ae79e2825fa242a349e17fcfc84fb99fd92197"
dependencies = [
"serde",
"serde_derive",
@@ -5589,7 +5589,7 @@ checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da"
[[package]]
name = "relevancy"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=72a070750ff979f4aac29da7c02a9cb6e53ac087#72a070750ff979f4aac29da7c02a9cb6e53ac087"
source = "git+https://github.com/mozilla/application-services?rev=40ae79e2825fa242a349e17fcfc84fb99fd92197#40ae79e2825fa242a349e17fcfc84fb99fd92197"
dependencies = [
"anyhow",
"base64 0.21.999",
@@ -5614,7 +5614,7 @@ dependencies = [
[[package]]
name = "remote_settings"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=72a070750ff979f4aac29da7c02a9cb6e53ac087#72a070750ff979f4aac29da7c02a9cb6e53ac087"
source = "git+https://github.com/mozilla/application-services?rev=40ae79e2825fa242a349e17fcfc84fb99fd92197#40ae79e2825fa242a349e17fcfc84fb99fd92197"
dependencies = [
"anyhow",
"camino",
@@ -5916,7 +5916,7 @@ dependencies = [
[[package]]
name = "search"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=72a070750ff979f4aac29da7c02a9cb6e53ac087#72a070750ff979f4aac29da7c02a9cb6e53ac087"
source = "git+https://github.com/mozilla/application-services?rev=40ae79e2825fa242a349e17fcfc84fb99fd92197#40ae79e2825fa242a349e17fcfc84fb99fd92197"
dependencies = [
"error-support",
"firefox-versioning",
@@ -6208,7 +6208,7 @@ dependencies = [
[[package]]
name = "sql-support"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=72a070750ff979f4aac29da7c02a9cb6e53ac087#72a070750ff979f4aac29da7c02a9cb6e53ac087"
source = "git+https://github.com/mozilla/application-services?rev=40ae79e2825fa242a349e17fcfc84fb99fd92197#40ae79e2825fa242a349e17fcfc84fb99fd92197"
dependencies = [
"interrupt-support",
"lazy_static",
@@ -6414,7 +6414,7 @@ checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc"
[[package]]
name = "suggest"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=72a070750ff979f4aac29da7c02a9cb6e53ac087#72a070750ff979f4aac29da7c02a9cb6e53ac087"
source = "git+https://github.com/mozilla/application-services?rev=40ae79e2825fa242a349e17fcfc84fb99fd92197#40ae79e2825fa242a349e17fcfc84fb99fd92197"
dependencies = [
"anyhow",
"chrono",
@@ -6466,7 +6466,7 @@ dependencies = [
[[package]]
name = "sync-guid"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=72a070750ff979f4aac29da7c02a9cb6e53ac087#72a070750ff979f4aac29da7c02a9cb6e53ac087"
source = "git+https://github.com/mozilla/application-services?rev=40ae79e2825fa242a349e17fcfc84fb99fd92197#40ae79e2825fa242a349e17fcfc84fb99fd92197"
dependencies = [
"base64 0.21.999",
"rand",
@@ -6477,7 +6477,7 @@ dependencies = [
[[package]]
name = "sync15"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=72a070750ff979f4aac29da7c02a9cb6e53ac087#72a070750ff979f4aac29da7c02a9cb6e53ac087"
source = "git+https://github.com/mozilla/application-services?rev=40ae79e2825fa242a349e17fcfc84fb99fd92197#40ae79e2825fa242a349e17fcfc84fb99fd92197"
dependencies = [
"anyhow",
"error-support",
@@ -6517,7 +6517,7 @@ dependencies = [
[[package]]
name = "tabs"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=72a070750ff979f4aac29da7c02a9cb6e53ac087#72a070750ff979f4aac29da7c02a9cb6e53ac087"
source = "git+https://github.com/mozilla/application-services?rev=40ae79e2825fa242a349e17fcfc84fb99fd92197#40ae79e2825fa242a349e17fcfc84fb99fd92197"
dependencies = [
"anyhow",
"error-support",
@@ -6861,7 +6861,7 @@ checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba"
[[package]]
name = "types"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=72a070750ff979f4aac29da7c02a9cb6e53ac087#72a070750ff979f4aac29da7c02a9cb6e53ac087"
source = "git+https://github.com/mozilla/application-services?rev=40ae79e2825fa242a349e17fcfc84fb99fd92197#40ae79e2825fa242a349e17fcfc84fb99fd92197"
dependencies = [
"rusqlite 0.33.0",
"serde",
@@ -7264,7 +7264,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]]
name = "viaduct"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=72a070750ff979f4aac29da7c02a9cb6e53ac087#72a070750ff979f4aac29da7c02a9cb6e53ac087"
source = "git+https://github.com/mozilla/application-services?rev=40ae79e2825fa242a349e17fcfc84fb99fd92197#40ae79e2825fa242a349e17fcfc84fb99fd92197"
dependencies = [
"ffi-support",
"log",
@@ -7434,7 +7434,7 @@ dependencies = [
[[package]]
name = "webext-storage"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=72a070750ff979f4aac29da7c02a9cb6e53ac087#72a070750ff979f4aac29da7c02a9cb6e53ac087"
source = "git+https://github.com/mozilla/application-services?rev=40ae79e2825fa242a349e17fcfc84fb99fd92197#40ae79e2825fa242a349e17fcfc84fb99fd92197"
dependencies = [
"anyhow",
"error-support",

View File

@@ -262,14 +262,14 @@ wr_malloc_size_of = { path = "gfx/wr/wr_malloc_size_of" }
objc = { git = "https://github.com/glandium/rust-objc", rev = "4de89f5aa9851ceca4d40e7ac1e2759410c04324" }
# application-services overrides to make updating them all simpler.
interrupt-support = { git = "https://github.com/mozilla/application-services", rev = "72a070750ff979f4aac29da7c02a9cb6e53ac087" }
relevancy = { git = "https://github.com/mozilla/application-services", rev = "72a070750ff979f4aac29da7c02a9cb6e53ac087" }
search = { git = "https://github.com/mozilla/application-services", rev = "72a070750ff979f4aac29da7c02a9cb6e53ac087" }
sql-support = { git = "https://github.com/mozilla/application-services", rev = "72a070750ff979f4aac29da7c02a9cb6e53ac087" }
suggest = { git = "https://github.com/mozilla/application-services", rev = "72a070750ff979f4aac29da7c02a9cb6e53ac087" }
sync15 = { git = "https://github.com/mozilla/application-services", rev = "72a070750ff979f4aac29da7c02a9cb6e53ac087" }
tabs = { git = "https://github.com/mozilla/application-services", rev = "72a070750ff979f4aac29da7c02a9cb6e53ac087" }
viaduct = { git = "https://github.com/mozilla/application-services", rev = "72a070750ff979f4aac29da7c02a9cb6e53ac087" }
webext-storage = { git = "https://github.com/mozilla/application-services", rev = "72a070750ff979f4aac29da7c02a9cb6e53ac087" }
interrupt-support = { git = "https://github.com/mozilla/application-services", rev = "40ae79e2825fa242a349e17fcfc84fb99fd92197" }
relevancy = { git = "https://github.com/mozilla/application-services", rev = "40ae79e2825fa242a349e17fcfc84fb99fd92197" }
search = { git = "https://github.com/mozilla/application-services", rev = "40ae79e2825fa242a349e17fcfc84fb99fd92197" }
sql-support = { git = "https://github.com/mozilla/application-services", rev = "40ae79e2825fa242a349e17fcfc84fb99fd92197" }
suggest = { git = "https://github.com/mozilla/application-services", rev = "40ae79e2825fa242a349e17fcfc84fb99fd92197" }
sync15 = { git = "https://github.com/mozilla/application-services", rev = "40ae79e2825fa242a349e17fcfc84fb99fd92197" }
tabs = { git = "https://github.com/mozilla/application-services", rev = "40ae79e2825fa242a349e17fcfc84fb99fd92197" }
viaduct = { git = "https://github.com/mozilla/application-services", rev = "40ae79e2825fa242a349e17fcfc84fb99fd92197" }
webext-storage = { git = "https://github.com/mozilla/application-services", rev = "40ae79e2825fa242a349e17fcfc84fb99fd92197" }
allocator-api2 = { path = "third_party/rust/allocator-api2" }

View File

@@ -13,8 +13,11 @@ ChromeUtils.defineESModuleGetters(lazy, {
InterruptKind: "resource://gre/modules/RustSuggest.sys.mjs",
ObjectUtils: "resource://gre/modules/ObjectUtils.sys.mjs",
QuickSuggest: "resource:///modules/QuickSuggest.sys.mjs",
SharedRemoteSettingsService:
"resource://gre/modules/RustSharedRemoteSettingsService.sys.mjs",
Region: "resource://gre/modules/Region.sys.mjs",
RemoteSettingsConfig2: "resource://gre/modules/RustRemoteSettings.sys.mjs",
RemoteSettingsContext: "resource://gre/modules/RustRemoteSettings.sys.mjs",
RemoteSettingsServer: "resource://gre/modules/RustRemoteSettings.sys.mjs",
RemoteSettingsService: "resource://gre/modules/RustRemoteSettings.sys.mjs",
SuggestIngestionConstraints: "resource://gre/modules/RustSuggest.sys.mjs",
SuggestStoreBuilder: "resource://gre/modules/RustSuggest.sys.mjs",
Suggestion: "resource://gre/modules/RustSuggest.sys.mjs",
@@ -94,16 +97,18 @@ export class SuggestBackendRust extends SuggestBackend {
// which is a "cannot-be-a-base" URL. The error is harmless, but it can be
// logged many times during a test suite.
//
// To prevent Suggest from using the dummy URL, we skip setting the
// remoteSettingsService, which prevents the Suggest store from being
// To prevent Suggest from using the dummy URL, we skip setting the initial
// RS config here during tests, which prevents the Suggest store from being
// created, effectively disabling Rust suggestions. Suggest tests manually
// set the RS config when they set up the mock RS server, so they'll work
// fine. Alternatively the test harnesses could disable Suggest by default
// just like they set the server pref to the dummy URL, but Suggest is more
// than Rust suggestions.
if (!lazy.Utils.shouldSkipRemoteActivityDueToTests) {
this.#remoteSettingsService =
lazy.SharedRemoteSettingsService.rustService();
this.#setRemoteSettingsConfig({
serverUrl: lazy.Utils.SERVER_URL,
bucketName: lazy.Utils.actualBucketName("main"),
});
}
}
@@ -454,6 +459,15 @@ export class SuggestBackendRust extends SuggestBackend {
);
}
/**
* @returns {string}
* The path of the directory that should contain the remote settings cache
* used internally by the Rust component.
*/
get #remoteSettingsStoragePath() {
return Services.dirsvc.get("ProfLD", Ci.nsIFile).path;
}
/**
* @returns {Array}
* Each item in this array identifies an enabled Rust suggestion type and
@@ -534,8 +548,44 @@ export class SuggestBackendRust extends SuggestBackend {
}
#makeStore() {
this.logger.info("Creating SuggestStore");
if (!this.#remoteSettingsService) {
this.logger.info("Creating SuggestStore", {
server: this.#remoteSettingsServer,
bucketName: this.#remoteSettingsBucketName,
dataPath: this.#storeDataPath,
storagePath: this.#remoteSettingsStoragePath,
});
if (!this.#remoteSettingsServer) {
return null;
}
let rsContext = {
formFactor: "desktop",
appId: Services.appinfo.ID || "",
channel: AppConstants.IS_ESR ? "esr" : AppConstants.MOZ_UPDATE_CHANNEL,
appVersion: Services.appinfo.version,
locale: Services.locale.appLocaleAsBCP47,
os: AppConstants.platform,
osVersion: Services.sysinfo.get("version"),
};
// We assume `QuickSuggest` init already awaited `Region.init()`.
if (lazy.Region.home) {
rsContext.country = lazy.Region.home;
}
let rsService;
try {
rsService = lazy.RemoteSettingsService.init(
this.#remoteSettingsStoragePath,
new lazy.RemoteSettingsConfig2({
server: this.#remoteSettingsServer,
bucketName: this.#remoteSettingsBucketName,
appContext: new lazy.RemoteSettingsContext(rsContext),
})
);
} catch (error) {
this.logger.error("Error creating RemoteSettingsService", error);
return null;
}
@@ -543,7 +593,7 @@ export class SuggestBackendRust extends SuggestBackend {
try {
builder = lazy.SuggestStoreBuilder.init()
.dataPath(this.#storeDataPath)
.remoteSettingsService(this.#remoteSettingsService)
.remoteSettingsService(rsService)
.loadExtension(
AppConstants.SQLITE_LIBRARY_FILENAME,
"sqlite3_fts5_init"
@@ -677,6 +727,14 @@ export class SuggestBackendRust extends SuggestBackend {
return lazy.SuggestionProvider[key];
}
#setRemoteSettingsConfig(options) {
let { serverUrl, bucketName } = options || {};
this.#remoteSettingsServer = serverUrl
? new lazy.RemoteSettingsServer.Custom(serverUrl)
: null;
this.#remoteSettingsBucketName = bucketName;
}
/**
* Dismissals are stored in the Rust component but were previously stored as
* URL digests in a pref. This method migrates the pref to the Rust component
@@ -750,8 +808,8 @@ export class SuggestBackendRust extends SuggestBackend {
return this.#enabledSuggestionTypes;
}
async _test_setRemoteSettingsService(remoteSettingsService) {
this.#remoteSettingsService = remoteSettingsService;
async _test_setRemoteSettingsConfig(options) {
this.#setRemoteSettingsConfig(options);
if (this.isEnabled) {
// Recreate the store and re-ingest.
Services.prefs.clearUserPref(INGEST_TIMER_LAST_UPDATE_PREF);
@@ -782,7 +840,8 @@ export class SuggestBackendRust extends SuggestBackend {
#ingestQueue;
#shutdownBlocker;
#remoteSettingsService;
#remoteSettingsServer;
#remoteSettingsBucketName;
}
/**

View File

@@ -13,8 +13,6 @@ ChromeUtils.defineESModuleGetters(lazy, {
Region: "resource://gre/modules/Region.sys.mjs",
RemoteSettingsServer:
"resource://testing-common/RemoteSettingsServer.sys.mjs",
SharedRemoteSettingsService:
"resource://gre/modules/RustSharedRemoteSettingsService.sys.mjs",
SearchUtils: "resource://gre/modules/SearchUtils.sys.mjs",
Suggestion: "resource://gre/modules/RustSuggest.sys.mjs",
TestUtils: "resource://testing-common/TestUtils.sys.mjs",
@@ -239,13 +237,10 @@ class _QuickSuggestTestUtils {
}
// Tell the Rust backend to use the local remote setting server.
lazy.SharedRemoteSettingsService.updateServer({
url: this.#remoteSettingsServer.url.toString(),
await lazy.QuickSuggest.rustBackend._test_setRemoteSettingsConfig({
bucketName: "main",
serverUrl: this.#remoteSettingsServer.url.toString(),
});
await lazy.QuickSuggest.rustBackend._test_setRemoteSettingsService(
lazy.SharedRemoteSettingsService.rustService()
);
// Wait for the Rust backend to finish syncing.
await this.forceSync();
@@ -295,7 +290,7 @@ class _QuickSuggestTestUtils {
lazy.UrlbarPrefs.clear("quicksuggest.dataCollection.enabled");
}
await lazy.QuickSuggest.rustBackend._test_setRemoteSettingsService(null);
await lazy.QuickSuggest.rustBackend._test_setRemoteSettingsConfig(null);
this.#log("#uninitQuickSuggest", "Done");
}
@@ -1423,7 +1418,7 @@ class _QuickSuggestTestUtils {
let originalHome = lazy.Region.home;
if (homeRegion) {
lazy.Region._setHomeRegion(homeRegion, true);
lazy.Region._setHomeRegion(homeRegion, false);
}
let available = Services.locale.availableLocales;
@@ -1444,7 +1439,7 @@ class _QuickSuggestTestUtils {
await callback();
if (homeRegion) {
lazy.Region._setHomeRegion(originalHome, true);
lazy.Region._setHomeRegion(originalHome, false);
}
promise = promiseChanges(requested);

File diff suppressed because one or more lines are too long

View File

@@ -507,15 +507,9 @@ impl RemoteSettingsClient<ViaductApiClient> {
Self::new_from_parts(collection_name, storage, jexl_filter, api_client)
}
pub fn update_config(
&self,
server_url: BaseUrl,
bucket_name: String,
context: Option<RemoteSettingsContext>,
) -> Result<()> {
pub fn update_config(&self, server_url: BaseUrl, bucket_name: String) -> Result<()> {
let mut inner = self.inner.lock();
inner.api_client = ViaductApiClient::new(server_url, &bucket_name, &self.collection_name);
inner.jexl_filter = JexlFilter::new(context);
inner.storage.empty()
}
}
@@ -2046,76 +2040,6 @@ mod jexl_tests {
Some(vec![])
);
}
#[test]
fn test_update_jexl_context() {
let mut api_client = MockApiClient::new();
let records = vec![RemoteSettingsRecord {
id: "record-0001".into(),
last_modified: 100,
deleted: false,
attachment: None,
fields: serde_json::json!({
"filter_expression": "env.country == \"US\""
})
.as_object()
.unwrap()
.clone(),
}];
let changeset = ChangesetResponse {
changes: records.clone(),
timestamp: 42,
metadata: CollectionMetadata::default(),
};
api_client.expect_collection_url().returning(|| {
"http://rs.example.com/v1/buckets/main/collections/test-collection".into()
});
api_client.expect_fetch_changeset().returning({
let changeset = changeset.clone();
move |timestamp| {
assert_eq!(timestamp, None);
Ok(changeset.clone())
}
});
api_client.expect_is_prod_server().returning(|| Ok(false));
let context = RemoteSettingsContext {
country: Some("US".to_string()),
..Default::default()
};
let mut storage = Storage::new(":memory:".into());
let _ = storage.insert_collection_content(
"http://rs.example.com/v1/buckets/main/collections/test-collection",
&records,
42,
CollectionMetadata::default(),
);
let rs_client = RemoteSettingsClient::new_from_parts(
"test-collection".into(),
storage,
JexlFilter::new(Some(context)),
api_client,
);
assert_eq!(
rs_client.get_records(false).expect("Error getting records"),
Some(records)
);
// We can't call `update_config` directly, since that only works with a real API client.
// Instead, just execute the code from that method that updates the JEXL filter.
rs_client.inner.lock().jexl_filter = JexlFilter::new(Some(RemoteSettingsContext {
country: Some("UK".to_string()),
..Default::default()
}));
assert_eq!(
rs_client.get_records(false).expect("Error getting records"),
Some(vec![])
);
}
}
#[cfg(feature = "signatures")]

View File

@@ -105,15 +105,12 @@ impl RemoteSettingsService {
let bucket_name = config.bucket_name.unwrap_or_else(|| String::from("main"));
let mut inner = self.inner.lock();
for client in inner.active_clients() {
client.internal.update_config(
base_url.clone(),
bucket_name.clone(),
config.app_context.clone(),
)?;
client
.internal
.update_config(base_url.clone(), bucket_name.clone())?;
}
inner.base_url = base_url;
inner.bucket_name = bucket_name;
inner.app_context = config.app_context;
Ok(())
}
}

View File

@@ -14,8 +14,8 @@ ChromeUtils.defineESModuleGetters(lazy, {
Interest: "resource://gre/modules/RustRelevancy.sys.mjs",
InterestVector: "resource://gre/modules/RustRelevancy.sys.mjs",
RelevancyStore: "resource://gre/modules/RustRelevancy.sys.mjs",
SharedRemoteSettingsService:
"resource://gre/modules/RustSharedRemoteSettingsService.sys.mjs",
RemoteSettingsConfig2: "resource://gre/modules/RustRemoteSettings.sys.mjs",
RemoteSettingsService: "resource://gre/modules/RustRemoteSettings.sys.mjs",
score: "resource://gre/modules/RustRelevancy.sys.mjs",
});
@@ -376,7 +376,6 @@ class RelevancyManager {
) ??
false
) {
await this.#storeManager.store.ensureInterestDataPopulated();
interestVector = await this.#storeManager.store.ingest(urls);
}
@@ -499,10 +498,18 @@ class RustRelevancyStoreManager {
if (rustRelevancyStore === undefined) {
rustRelevancyStore = lazy.RelevancyStore;
}
this.#store = rustRelevancyStore.init(
path,
lazy.SharedRemoteSettingsService.rustService()
// Initialize a RemoteSettingsService for the relevancy store
// TODO (1956519): consolidate this with the Suggest code and only create a single app-wide remote settings
// service. For now this duplication is okay though because we're not really shipping Relevancy -- it's only enabled via a
// pref.
const rsService = lazy.RemoteSettingsService.init(
PathUtils.join(
Services.dirsvc.get("ProfLD", Ci.nsIFile).path,
"remote-settings"
),
new lazy.RemoteSettingsConfig2({})
);
this.#store = rustRelevancyStore.init(path, rsService);
}
get store() {

View File

@@ -7,8 +7,6 @@ ChromeUtils.defineESModuleGetters(this, {
AsyncShutdown: "resource://gre/modules/AsyncShutdown.sys.mjs",
ContentRelevancyManager:
"resource://gre/modules/ContentRelevancyManager.sys.mjs",
SharedRemoteSettingsService:
"resource://gre/modules/RustSharedRemoteSettingsService.sys.mjs",
exposedForTesting: "resource://gre/modules/ContentRelevancyManager.sys.mjs",
TestUtils: "resource://testing-common/TestUtils.sys.mjs",
setTimeout: "resource://gre/modules/Timer.sys.mjs",
@@ -64,10 +62,8 @@ add_task(function test_store_manager() {
);
Assert.equal(fakeRustRelevancyStore.init.callCount, 1);
Assert.deepEqual(fakeRustRelevancyStore.init.firstCall.args[0], "test-path");
Assert.strictEqual(
fakeRustRelevancyStore.init.firstCall.args[1],
SharedRemoteSettingsService.rustService()
);
// TODO (1956519): test that the second arg is the app-wide RemoteSettingsService
// store should throw before the manager is enabled
Assert.throws(() => storeManager.store, /StoreDisabledError/);
// Once the manager is enabled, store should return the RustRelevancyStore
storeManager.enable();

View File

@@ -941,13 +941,17 @@ export class RemoteSettingsService {
}
throw e;
}
return UniFFIScaffolding.callSync(
return UniFFIScaffolding.callAsyncWrapper(
25, // remote_settings:uniffi_remote_settings_fn_method_remotesettingsservice_update_config
FfiConverterTypeRemoteSettingsService.lower(this),
FfiConverterTypeRemoteSettingsConfig2.lower(config),
)
}
return handleRustResult(functionCall(), liftResult, liftError);
try {
return functionCall().then((result) => handleRustResult(result, liftResult, liftError));
} catch (error) {
return Promise.reject(error)
}
}
}

View File

@@ -56,7 +56,6 @@ enable = true
main_thread = [
"RemoteSettings.new",
"RemoteSettingsService.new",
"RemoteSettingsService.update_config",
]
[error_support.async_wrappers]

View File

@@ -1,99 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Import these directly, since we're going to be using them immediately to construct SharedRemoteSettingsService
import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
import { Region } from "resource://gre/modules/Region.sys.mjs";
import {
RemoteSettingsConfig2,
RemoteSettingsContext,
RemoteSettingsServer,
RemoteSettingsService,
} from "resource://gre/modules/RustRemoteSettings.sys.mjs";
import { Utils } from "resource://services-settings/Utils.sys.mjs";
/**
* Rust RemoteSettingsService singleton
*
* This component manages the app-wide Rust RemoteSetingsService that's
* shared by various other Rust components.
*
* This is only intended to be passed to Rust code. If you want a
* general-purpose Remote settings client, use the JS one:
*
* - https://firefox-source-docs.mozilla.org/services/settings/index.html
* - https://searchfox.org/mozilla-central/source/services/settings/remote-settings.sys.mjs
*/
class _SharedRemoteSettingsService {
#config;
#rustService;
constructor() {
const storageDir = PathUtils.join(
Services.dirsvc.get("ProfLD", Ci.nsIFile).path,
"remote-settings"
);
this.#config = new RemoteSettingsConfig2({
server: new RemoteSettingsServer.Custom(Utils.SERVER_URL),
bucketName: Utils.actualBucketName("main"),
appContext: new RemoteSettingsContext({
formFactor: "desktop",
appId: Services.appinfo.ID || "",
channel: AppConstants.IS_ESR ? "esr" : AppConstants.MOZ_UPDATE_CHANNEL,
appVersion: Services.appinfo.version,
locale: Services.locale.appLocaleAsBCP47,
os: AppConstants.platform,
osVersion: Services.sysinfo.get("version"),
country: Region.home ?? undefined,
}),
});
Services.obs.addObserver(this, Region.REGION_TOPIC);
this.#rustService = RemoteSettingsService.init(storageDir, this.#config);
}
/**
* Update the Remote Settings server
*
* @param {object} opts object with the following fields:
* - `url`: server URL (defaults to the production URL)
* - `bucketName`: bucket name (defaults to "main")
*/
updateServer(opts) {
this.#config.server = opts.url
? new RemoteSettingsServer.Custom(opts.url)
: undefined;
this.#config.bucketName = opts.bucketName ?? Utils.actualBucketName("main");
this.#rustService.updateConfig(this.#config);
}
/**
* Get a reference to the Rust RemoteSettingsService object
*/
rustService() {
return this.#rustService;
}
/**
* Sync server data for all active clients
*/
async sync() {
// TODO (1966163): Hook this up to a timer. There's currently no mechanism that calls this.
await this.#rustService.sync();
}
observe(subj, topic) {
if (topic == Region.REGION_TOPIC) {
const newCountry = subj.data;
if (newCountry != this.#config.appContext.country) {
this.#config.appContext.country = newCountry;
this.#rustService.updateConfig(this.#config);
}
}
}
}
export const SharedRemoteSettingsService = new _SharedRemoteSettingsService();

View File

@@ -108,9 +108,6 @@ with Files("PrivateBrowsingUtils.sys.mjs"):
with Files("Promise*.sys.mjs"):
BUG_COMPONENT = ("Toolkit", "Async Tooling")
with Files("RustSharedRemoteSettingsService.sys.mjs"):
BUG_COMPONENT = ("Application Services", "Remote Settings")
with Files("ShortcutUtils.sys.mjs"):
BUG_COMPONENT = ("Firefox", "Toolbars and Customization")
@@ -129,6 +126,7 @@ with Files("WindowsLaunchOnLogin.sys.mjs"):
with Files("WindowsRegistry.sys.mjs"):
BUG_COMPONENT = ("Toolkit", "General")
XPCSHELL_TESTS_MANIFESTS += ["tests/xpcshell/xpcshell.toml"]
BROWSER_CHROME_MANIFESTS += ["tests/browser/browser.toml"]
MOCHITEST_CHROME_MANIFESTS += ["tests/chrome/chrome.toml"]
@@ -201,7 +199,6 @@ EXTRA_JS_MODULES += [
"Region.sys.mjs",
"RemotePageAccessManager.sys.mjs",
"ResetProfile.sys.mjs",
"RustSharedRemoteSettingsService.sys.mjs",
"SelectionUtils.sys.mjs",
"ServiceRequest.sys.mjs",
"ShortcutUtils.sys.mjs",