Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(872)

Issue 1892083002: Generic Sensor API : Ambient Light Sensor API.

Created:
4 years, 8 months ago by riju_
Modified:
4 years, 6 months ago
Reviewers:
timvolodine
CC:
chromium-reviews, mlamouri+watch-content_chromium.org, creis+watch_chromium.org, qsr+mojo_chromium.org, viettrungluu+watch_chromium.org, nasko+codewatch_chromium.org, jam, yzshen+watch_chromium.org, abarth-chromium, haraken, Aaron Boodman, blink-reviews, darin-cc_chromium.org, asvitkine+watch_chromium.org, mkwst+moarreviews-renderer_chromium.org, darin (slow to review), ben+mojo_chromium.org, kinuko+watch
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Generic Sensor API : Ambient Light Sensor API. [DO NOT LAND]: This CL is for comments. This CL implements the new Ambient Light Sensor API for chrome on android based on the Generic Sensor API. The ED for the Generic Sensor API is here - https://w3c.github.io/sensors/ The ED for the Ambient Light Sensor API is here - http://w3c.github.io/ambient-light/ The new way to use the ambient light sensor readings is - var s = new AmbientLightSensor(); s.start(); s.onchange = event => console.log(event.reading.illuminance); s.stop(); BUG=

Patch Set 1 #

Total comments: 9

Patch Set 2 : rebase + some changes #

Patch Set 3 : rebase + mojo-in-blink changes #

Patch Set 4 : Move more stuff to Sensor from ALS #

Patch Set 5 : re entrancy fix #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1971 lines, -1 line) Patch
M content/browser/BUILD.gn View 1 2 3 4 2 chunks +2 lines, -0 lines 0 comments Download
M content/browser/DEPS View 1 2 3 4 1 chunk +1 line, -0 lines 0 comments Download
M content/browser/renderer_host/render_process_host_impl.cc View 1 2 3 4 2 chunks +5 lines, -0 lines 0 comments Download
M content/content.gyp View 1 2 3 4 1 chunk +1 line, -0 lines 0 comments Download
M content/content_browser.gypi View 1 2 3 4 1 chunk +2 lines, -0 lines 0 comments Download
M content/content_renderer.gypi View 1 2 3 4 1 chunk +2 lines, -0 lines 0 comments Download
M content/public/android/BUILD.gn View 1 2 3 4 1 chunk +2 lines, -0 lines 0 comments Download
M content/public/android/java/src/org/chromium/content/browser/ServiceRegistrar.java View 1 2 3 2 chunks +19 lines, -0 lines 0 comments Download
M content/renderer/BUILD.gn View 1 2 3 4 1 chunk +1 line, -0 lines 0 comments Download
A device/sensor/BUILD.gn View 1 chunk +40 lines, -0 lines 0 comments Download
A device/sensor/OWNERS View 1 2 3 4 1 chunk +2 lines, -0 lines 0 comments Download
A device/sensor/als_reading.mojom View 1 chunk +12 lines, -0 lines 0 comments Download
A device/sensor/android/BUILD.gn View 1 chunk +19 lines, -0 lines 0 comments Download
A device/sensor/android/java/src/org/chromium/device/sensor/AmbientLightSensorImpl.java View 1 chunk +100 lines, -0 lines 0 comments Download
A device/sensor/sensor.gyp View 1 2 3 4 1 chunk +87 lines, -0 lines 0 comments Download
A device/sensor/sensor.mojom View 1 chunk +13 lines, -0 lines 0 comments Download
A device/sensor/sensor_export.h View 1 chunk +29 lines, -0 lines 0 comments Download
A device/sensor/sensor_impl.h View 1 1 chunk +49 lines, -0 lines 0 comments Download
A device/sensor/sensor_impl.cc View 1 chunk +63 lines, -0 lines 0 comments Download
A device/sensor/sensor_manager.h View 1 1 chunk +36 lines, -0 lines 0 comments Download
A device/sensor/sensor_manager_default.cc View 1 1 chunk +39 lines, -0 lines 0 comments Download
A device/sensor/sensor_service.h View 1 1 chunk +63 lines, -0 lines 0 comments Download
A device/sensor/sensor_service.cc View 1 2 3 4 1 chunk +93 lines, -0 lines 0 comments Download
M third_party/WebKit/LayoutTests/fast/dom/Window/property-access-on-cached-properties-after-frame-navigated-expected.txt View 1 2 3 1 chunk +4 lines, -0 lines 0 comments Download
M third_party/WebKit/LayoutTests/fast/dom/Window/property-access-on-cached-properties-after-frame-removed-and-gced-expected.txt View 1 2 3 1 chunk +4 lines, -0 lines 0 comments Download
M third_party/WebKit/LayoutTests/fast/dom/Window/property-access-on-cached-properties-after-frame-removed-expected.txt View 1 2 3 1 chunk +4 lines, -0 lines 0 comments Download
M third_party/WebKit/LayoutTests/fast/dom/Window/property-access-on-cached-window-after-frame-navigated-expected.txt View 1 2 3 1 chunk +4 lines, -0 lines 0 comments Download
M third_party/WebKit/LayoutTests/fast/dom/Window/property-access-on-cached-window-after-frame-removed-and-gced-expected.txt View 1 2 3 1 chunk +4 lines, -0 lines 0 comments Download
M third_party/WebKit/LayoutTests/fast/dom/Window/property-access-on-cached-window-after-frame-removed-expected.txt View 1 2 3 1 chunk +4 lines, -0 lines 0 comments Download
M third_party/WebKit/LayoutTests/fast/dom/Window/resources/window-property-collector.js View 1 2 3 4 1 chunk +4 lines, -0 lines 0 comments Download
M third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt View 1 2 3 4 4 chunks +48 lines, -1 line 0 comments Download
M third_party/WebKit/Source/core/frame/UseCounter.h View 1 2 3 4 1 chunk +2 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/modules/BUILD.gn View 1 2 3 1 chunk +1 line, -0 lines 0 comments Download
M third_party/WebKit/Source/modules/EventTargetModulesFactory.in View 1 1 chunk +1 line, -0 lines 0 comments Download
M third_party/WebKit/Source/modules/modules.gyp View 1 2 3 4 1 chunk +1 line, -0 lines 0 comments Download
M third_party/WebKit/Source/modules/modules.gypi View 1 2 3 4 6 chunks +36 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/modules/sensor/AmbientLightSensor.h View 1 2 3 4 1 chunk +56 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/modules/sensor/AmbientLightSensor.cpp View 1 2 3 1 chunk +92 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/modules/sensor/AmbientLightSensor.idl View 1 2 3 4 1 chunk +16 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/modules/sensor/AmbientLightSensorDispatcher.h View 1 2 3 4 1 chunk +50 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/modules/sensor/AmbientLightSensorDispatcher.cpp View 1 2 3 4 1 chunk +74 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/modules/sensor/AmbientLightSensorReading.h View 1 2 3 1 chunk +47 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/modules/sensor/AmbientLightSensorReading.cpp View 1 2 3 1 chunk +37 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/modules/sensor/AmbientLightSensorReading.idl View 1 chunk +13 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/modules/sensor/DEPS View 1 2 3 4 1 chunk +15 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/modules/sensor/NavigatorAmbientLightSensor.h View 1 chunk +40 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/modules/sensor/NavigatorAmbientLightSensor.cpp View 1 chunk +57 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/modules/sensor/NavigatorAmbientLightSensor.idl View 1 2 3 4 1 chunk +13 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/modules/sensor/OWNERS View 1 2 3 4 1 chunk +2 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/modules/sensor/Sensor.h View 1 2 3 4 1 chunk +70 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/modules/sensor/Sensor.cpp View 1 2 3 4 1 chunk +136 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/modules/sensor/Sensor.idl View 1 2 3 1 chunk +27 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/modules/sensor/SensorErrorEvent.h View 1 1 chunk +50 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/modules/sensor/SensorErrorEvent.cpp View 1 chunk +42 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/modules/sensor/SensorErrorEvent.idl View 1 2 3 4 1 chunk +14 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/modules/sensor/SensorErrorEventInit.idl View 1 2 3 4 1 chunk +10 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/modules/sensor/SensorOptions.idl View 1 1 chunk +11 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/modules/sensor/SensorReading.h View 1 2 3 4 1 chunk +47 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/modules/sensor/SensorReading.cpp View 1 2 3 1 chunk +36 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/modules/sensor/SensorReading.idl View 1 2 3 1 chunk +12 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/modules/sensor/SensorReadingEvent.h View 1 2 3 4 1 chunk +62 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/modules/sensor/SensorReadingEvent.cpp View 1 chunk +47 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/modules/sensor/SensorReadingEvent.idl View 1 2 3 4 1 chunk +13 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/modules/sensor/SensorReadingEventInit.idl View 1 2 3 4 1 chunk +10 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/modules/sensor/SensorState.h View 1 2 3 4 1 chunk +19 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/modules/sensor/als_reading.h View 1 2 3 4 1 chunk +31 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/modules/sensor/sensor_error_type.h View 1 2 3 1 chunk +22 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in View 1 2 3 4 1 chunk +1 line, -0 lines 0 comments Download
M tools/metrics/histograms/histograms.xml View 1 2 3 4 1 chunk +2 lines, -0 lines 0 comments Download

Messages

Total messages: 9 (6 generated)
timvolodine
https://codereview.chromium.org/1892083002/diff/1/third_party/WebKit/Source/modules/sensor/AmbientLightSensor.cpp File third_party/WebKit/Source/modules/sensor/AmbientLightSensor.cpp (right): https://codereview.chromium.org/1892083002/diff/1/third_party/WebKit/Source/modules/sensor/AmbientLightSensor.cpp#newcode119 third_party/WebKit/Source/modules/sensor/AmbientLightSensor.cpp:119: m_hasEventListener = false; could this go to the Sensor ...
4 years, 7 months ago (2016-05-06 17:05:41 UTC) #3
riju_
hi Tim, PTAL. https://codereview.chromium.org/1892083002/diff/1/device/sensor/android/java/src/org/chromium/device/sensor/AmbientLightSensorImpl.java File device/sensor/android/java/src/org/chromium/device/sensor/AmbientLightSensorImpl.java (right): https://codereview.chromium.org/1892083002/diff/1/device/sensor/android/java/src/org/chromium/device/sensor/AmbientLightSensorImpl.java#newcode91 device/sensor/android/java/src/org/chromium/device/sensor/AmbientLightSensorImpl.java:91: public void onSensorChanged(SensorEvent event) { TODO(riju) ...
4 years, 7 months ago (2016-05-16 16:58:52 UTC) #5
timvolodine
4 years, 7 months ago (2016-05-17 17:46:18 UTC) #6
https://codereview.chromium.org/1892083002/diff/1/third_party/WebKit/Source/m...
File third_party/WebKit/Source/modules/sensor/AmbientLightSensor.h (right):

https://codereview.chromium.org/1892083002/diff/1/third_party/WebKit/Source/m...
third_party/WebKit/Source/modules/sensor/AmbientLightSensor.h:66:
Member<AmbientLightSensorReading> m_lightReading;
On 2016/05/16 16:58:51, riju_ wrote:
> On 2016/05/06 17:05:41, timvolodine wrote:
> > does this mean we have two readings now? one from Sensor an this one
> 
> We can make SensorReading and SensorOptions private in Sensor to restrict
> access?

I think the idea would be to use the member of Sensor to store lightReading,
otherwise what's the point of having a member in Sensor?

https://codereview.chromium.org/1892083002/diff/1/third_party/WebKit/Source/m...
File third_party/WebKit/Source/modules/sensor/AmbientLightSensorDispatcher.cpp
(right):

https://codereview.chromium.org/1892083002/diff/1/third_party/WebKit/Source/m...
third_party/WebKit/Source/modules/sensor/AmbientLightSensorDispatcher.cpp:62:
Platform::current()->serviceRegistry()->connectToRemoteService(mojo::GetProxy(&m_lightSensor));
On 2016/05/16 16:58:51, riju_ wrote:
> On 2016/05/06 17:05:41, timvolodine wrote:
> > does this mean that for for each blink instance we would have a separate
mojo
> > service? i.e. multiple registrations for 'light sensor' on the platform
side.
> if
> > so, are there any issues with that?
> 
> Isn't it the case that even for multiple blink instance of concrete sensors,
> there is 1 dispatcher per sensor type ?
> I think there is 1 interface_ptr, i.e m_lightSensor for all concrete sensor of
> ALS, and if that is bound (connection exists), then we skip registration.

yeah sorry I wasn't clear, I meant there are multiple instances of mojo
implementations (i.e. sensorImpl in your case), but it looks like they all go to
a singleton SensorService anyway so you would not register multiple times on the
platform side. (Registering multiple times on platform side would probably work
as well, was just checking if there would be any issues with that). 

Looking ahead though looks like creating two ALS sensors in javascript with
different frequencies would be non-trivial to implement..

Powered by Google App Engine
This is Rietveld 408576698