compute pressure: Remove Factors from compute pressure

Due to fingerprinting concerns, it was decided to not expose
contributing factors. [1]

[1] https://github.com/w3c/compute-pressure/pull/203

Bug: 1428859, 1365627
Change-Id: If90b2c27e04076795a77ff0d255c5a3a05e220ec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4381885
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Reviewed-by: Raphael Kubo Da Costa <raphael.kubo.da.costa@intel.com>
Commit-Queue: Arnaud Mandy <arnaud.mandy@intel.com>
Cr-Commit-Position: refs/heads/main@{#1131804}
diff --git a/compute-pressure/compute_pressure_duplicate_updates.tentative.https.any.js b/compute-pressure/compute_pressure_duplicate_updates.tentative.https.any.js
index b5d7690..dde9293 100644
--- a/compute-pressure/compute_pressure_duplicate_updates.tentative.https.any.js
+++ b/compute-pressure/compute_pressure_duplicate_updates.tentative.https.any.js
@@ -30,33 +30,3 @@
   assert_equals(pressureChanges[0][0].state, 'critical');
   assert_equals(pressureChanges[1][0].state, 'nominal');
 }, 'Changes that fail the "has change in data" test are discarded.');
-
-pressure_test(async (t, mockPressureService) => {
-  const pressureChanges = await new Promise(async resolve => {
-    const observer_changes = [];
-    let n = 0;
-    const observer = new PressureObserver(changes => {
-      observer_changes.push(changes);
-      if (++n === 2)
-        resolve(observer_changes);
-    }, {sampleRate: 5.0});
-    observer.observe('cpu');
-    const updatesDelivered = mockPressureService.updatesDelivered();
-    mockPressureService.setPressureUpdate('cpu', 'critical', ['thermal']);
-    mockPressureService.startPlatformCollector(/*sampleRate*/ 5.0);
-
-    // Deliver 2 updates.
-    await t.step_wait(
-        () => mockPressureService.updatesDelivered() >= (updatesDelivered + 2),
-        'Wait for more than one update to be delivered to the observer');
-    mockPressureService.setPressureUpdate('cpu', 'critical', ['power-supply']);
-    // Deliver more updates, |resolve()| will be called when the new pressure
-    // state reaches PressureObserver and its callback is invoked
-    // for the second time.
-  });
-  assert_equals(pressureChanges.length, 2);
-  assert_equals(pressureChanges[0][0].state, 'critical');
-  assert_equals(pressureChanges[0][0].factors[0], 'thermal');
-  assert_equals(pressureChanges[1][0].state, 'critical');
-  assert_equals(pressureChanges[1][0].factors[0], 'power-supply');
-}, 'Factors that fail the "has change in data" test are discarded.');
diff --git a/compute-pressure/compute_pressure_factors.tentative.https.any.js b/compute-pressure/compute_pressure_factors.tentative.https.any.js
index 7486a70..60d38d3 100644
--- a/compute-pressure/compute_pressure_factors.tentative.https.any.js
+++ b/compute-pressure/compute_pressure_factors.tentative.https.any.js
@@ -9,12 +9,11 @@
     const observer = new PressureObserver(resolve);
     t.add_cleanup(() => observer.disconnect());
     observer.observe('cpu');
-    mockPressureService.setPressureUpdate('cpu', 'critical', ['thermal']);
+    mockPressureService.setPressureUpdate('cpu', 'critical');
     mockPressureService.startPlatformCollector(/*sampleRate=*/ 5.0);
   });
   assert_true(changes.length === 1);
   assert_equals(changes[0].state, 'critical');
   assert_equals(changes[0].source, 'cpu');
   assert_equals(typeof changes[0].time, 'number');
-  assert_equals(changes[0].factors[0], 'thermal');
 }, 'Basic factors functionality test');
diff --git a/compute-pressure/compute_pressure_update_toJSON.tentative.https.any.js b/compute-pressure/compute_pressure_update_toJSON.tentative.https.any.js
index c1cd240..0024d69 100644
--- a/compute-pressure/compute_pressure_update_toJSON.tentative.https.any.js
+++ b/compute-pressure/compute_pressure_update_toJSON.tentative.https.any.js
@@ -6,13 +6,12 @@
   const changes = await new Promise(resolve => {
     const observer = new PressureObserver(resolve);
     observer.observe('cpu');
-    mockPressureService.setPressureUpdate('cpu', 'critical', ['thermal']);
+    mockPressureService.setPressureUpdate('cpu', 'critical');
     mockPressureService.startPlatformCollector(/*sampleRate=*/ 5.0);
   });
   assert_true(changes.length === 1);
   const json = changes[0].toJSON();
   assert_equals(json.state, 'critical');
   assert_equals(json.source, 'cpu');
-  assert_equals(json.factors[0], 'thermal');
   assert_equals(typeof json.time, 'number');
 }, 'Basic functionality test');
diff --git a/resources/chromium/mock-pressure-service.js b/resources/chromium/mock-pressure-service.js
index 21811ed..02d10f8 100644
--- a/resources/chromium/mock-pressure-service.js
+++ b/resources/chromium/mock-pressure-service.js
@@ -1,5 +1,5 @@
 import {PressureManager, PressureManagerReceiver, PressureStatus} from '/gen/services/device/public/mojom/pressure_manager.mojom.m.js'
-import {PressureFactor, PressureSource, PressureState} from '/gen/services/device/public/mojom/pressure_update.mojom.m.js'
+import {PressureSource, PressureState} from '/gen/services/device/public/mojom/pressure_update.mojom.m.js'
 
 class MockPressureService {
   constructor() {
@@ -15,10 +15,6 @@
       ['nominal', PressureState.kNominal], ['fair', PressureState.kFair],
       ['serious', PressureState.kSerious], ['critical', PressureState.kCritical]
     ]);
-    this.mojomFactorType_ = new Map([
-      ['thermal', PressureFactor.kThermal],
-      ['power-supply', PressureFactor.kPowerSupply]
-    ]);
     this.pressureServiceReadingTimerId_ = null;
   }
 
@@ -109,26 +105,16 @@
     return this.updatesDelivered_;
   }
 
-  setPressureUpdate(source, state, factors) {
+  setPressureUpdate(source, state) {
     if (!this.mojomSourceType_.has(source))
       throw new Error(`PressureSource '${source}' is invalid`);
 
     if (!this.mojomStateType_.has(state))
       throw new Error(`PressureState '${state}' is invalid`);
 
-    let pressureFactors = [];
-    if (Array.isArray(factors)) {
-      for (const factor of factors) {
-        if (!this.mojomFactorType_.has(factor))
-          throw new Error(`PressureFactor '${factor}' is invalid`);
-        pressureFactors.push(this.mojomFactorType_.get(factor));
-      }
-    }
-
     this.pressureUpdate_ = {
       source: this.mojomSourceType_.get(source),
       state: this.mojomStateType_.get(state),
-      factors: pressureFactors,
     };
   }