Please be aware that this feature will likely require a privacy and security review.
If one of you could let me know when you have the code landed and are a few weeks out from enabling I will get the reviews started at that point.

Ofcourse Owen. I will keep you in the loop.
If somebody is interested to have a look right now, I have a first version of the code at https://codereview.chromium.org/1892083002/ . This CL is mainly for comments on the overall structure. Details will be filled up as we go.

The last CL is causing new test failures on Blink bots -- both of the two new tests, mock-sensor and ambient-light-sensor are failing consistently.
See
https://test-results.appspot.com/dashboards/flakiness_dashboard.html#tests=sensor%2Fambient-light-sensor.html%2C%20sensor%2Fmock-sensor.html
First failed build on MacOS 10.10:
https://build.chromium.org/p/chromium.webkit/builders/WebKit%20Mac10.10/builds/23859
Reverting this CL until those can be fixed.

The following revision refers to this bug:
https://chromium.googlesource.com/chromium/src.git/+/85cc22d79580bc5ad58db03ff3e4fb8f9db539a6
commit 85cc22d79580bc5ad58db03ff3e4fb8f9db539a6
Author: maksim.sisov <maksim.sisov@intel.com>
Date: Wed Oct 05 11:13:30 2016
[sensors] Introduce asynchronous way to create sensors.
As long as sensors implementation on Linux/ChromeOS will
be based on reading from files (sensors' files are located
in /sys/dev/iio/devices), asynchronous way of creating
sensors is introduced with this patch.
To be more specific, the asynchronous path is needed because
sensors' existence will be checked by blocking IO methods in
case of Linux/ChromeOS and in order to be able to say
whether a sensor exists or not, asynchronous path will be
used.
In case of Android and Mac, callbacks will be
called immediately as soon as a sensor manager in Android or
IOServiceGetMatchingService in Mac returns a sensor object
or nullptr.
How it works:
As soon as a request for a new sensor is received, callbacks
are stored into a vector which is pushed into a map with a
type key and the vector itself. If no callback has been
stored before, CreateSensorInternal() method is called.
Then:
*Linux/ChromeOS (under development): a new thread is
created which will handle concrete sensors creation.
*Android: when CreateSensorInternal() is called, java code
is called and everything is handled by the sensor manager,
which returns synchronously. Once sensor found, it is
returned. Otherwise, nullptr is returned.
*Mac (under development)
https://codereview.chromium.org/2332903002/: everything
is handled by IOServiceGetMatchingService, which returns
synchronously.
BUG=606766
Review-Url: https://codereview.chromium.org/2368193003
Cr-Commit-Position: refs/heads/master@{#423127}
[modify] https://crrev.com/85cc22d79580bc5ad58db03ff3e4fb8f9db539a6/device/generic_sensor/fake_platform_sensor_provider.cc
[modify] https://crrev.com/85cc22d79580bc5ad58db03ff3e4fb8f9db539a6/device/generic_sensor/fake_platform_sensor_provider.h
[modify] https://crrev.com/85cc22d79580bc5ad58db03ff3e4fb8f9db539a6/device/generic_sensor/platform_sensor_provider_android.cc
[modify] https://crrev.com/85cc22d79580bc5ad58db03ff3e4fb8f9db539a6/device/generic_sensor/platform_sensor_provider_base.cc
[modify] https://crrev.com/85cc22d79580bc5ad58db03ff3e4fb8f9db539a6/device/generic_sensor/platform_sensor_provider_base.h
[modify] https://crrev.com/85cc22d79580bc5ad58db03ff3e4fb8f9db539a6/device/generic_sensor/platform_sensor_provider_unittest.cc
[modify] https://crrev.com/85cc22d79580bc5ad58db03ff3e4fb8f9db539a6/device/generic_sensor/sensor_provider_impl.cc
[modify] https://crrev.com/85cc22d79580bc5ad58db03ff3e4fb8f9db539a6/device/generic_sensor/sensor_provider_impl.h

The following revision refers to this bug:
https://chromium.googlesource.com/chromium/src.git/+/24e8468bd738a1df17fe4f20ea251b3d87c4978a
commit 24e8468bd738a1df17fe4f20ea251b3d87c4978a
Author: alexis.menard <alexis.menard@intel.com>
Date: Wed Oct 05 19:48:53 2016
[sensors] Fix crash after 85cc22d when using async creation of sensors.
The fix is simple as the callback was called with null pointers. Make
sure to call it with the right arguments.
BUG=606766
Review-Url: https://codereview.chromium.org/2396873002
Cr-Commit-Position: refs/heads/master@{#423259}
[modify] https://crrev.com/24e8468bd738a1df17fe4f20ea251b3d87c4978a/device/generic_sensor/sensor_provider_impl.cc

The following revision refers to this bug:
https://chromium.googlesource.com/chromium/src.git/+/a5d055a1bd9e2db124cd7e2ef13c827f765f3c38
commit a5d055a1bd9e2db124cd7e2ef13c827f765f3c38
Author: alexis.menard <alexis.menard@intel.com>
Date: Tue Oct 11 17:50:36 2016
[sensors] [mac] Implement ambient light sensor for macOS
Use IOKit to get information from the platform and callback
when the value of the sensor is changing.
Make sure to provide the time stamp as well (which is required
by the spec). The data is passed in a shared buffer using
seqlock mechanism.
The patch also moves around code in content/device_sensors
because they are needed by this implementation. This will
avoid device/ to depend on content/. The default frequency
to pull the ambient light is now inside device/sensors/public/cpp
(shared amongst platforms). The method to convert the value
returned by the LMU sensor (on mac machines) to lux is moved
to device/sensors/public/cpp) as well.
Finally the patch also add a smart pointer to handle IONotificationPortRef.
There are other opportunities in the chromium codebase to use that new smart
pointer, I will land a follow up CL.
Intent to Implement: https://groups.google.com/a/chromium.org/forum/#!msg/blink-dev/TkfdVqYAYiE/xLGN2b1-AAAJ
BUG=606766
Review-Url: https://codereview.chromium.org/2332903002
Cr-Commit-Position: refs/heads/master@{#424479}
[modify] https://crrev.com/a5d055a1bd9e2db124cd7e2ef13c827f765f3c38/base/BUILD.gn
[add] https://crrev.com/a5d055a1bd9e2db124cd7e2ef13c827f765f3c38/base/mac/scoped_ionotificationportref.h
[modify] https://crrev.com/a5d055a1bd9e2db124cd7e2ef13c827f765f3c38/content/browser/device_sensors/DEPS
[modify] https://crrev.com/a5d055a1bd9e2db124cd7e2ef13c827f765f3c38/content/browser/device_sensors/data_fetcher_shared_memory_mac.cc
[modify] https://crrev.com/a5d055a1bd9e2db124cd7e2ef13c827f765f3c38/content/renderer/DEPS
[modify] https://crrev.com/a5d055a1bd9e2db124cd7e2ef13c827f765f3c38/content/renderer/device_sensors/device_light_event_pump.cc
[modify] https://crrev.com/a5d055a1bd9e2db124cd7e2ef13c827f765f3c38/device/generic_sensor/BUILD.gn
[modify] https://crrev.com/a5d055a1bd9e2db124cd7e2ef13c827f765f3c38/device/generic_sensor/DEPS
[add] https://crrev.com/a5d055a1bd9e2db124cd7e2ef13c827f765f3c38/device/generic_sensor/platform_sensor_ambient_light_mac.cc
[add] https://crrev.com/a5d055a1bd9e2db124cd7e2ef13c827f765f3c38/device/generic_sensor/platform_sensor_ambient_light_mac.h
[add] https://crrev.com/a5d055a1bd9e2db124cd7e2ef13c827f765f3c38/device/generic_sensor/platform_sensor_provider_mac.cc
[add] https://crrev.com/a5d055a1bd9e2db124cd7e2ef13c827f765f3c38/device/generic_sensor/platform_sensor_provider_mac.h
[modify] https://crrev.com/a5d055a1bd9e2db124cd7e2ef13c827f765f3c38/device/sensors/public/cpp/BUILD.gn
[add] https://crrev.com/a5d055a1bd9e2db124cd7e2ef13c827f765f3c38/device/sensors/public/cpp/device_sensors_consts.h
[add] https://crrev.com/a5d055a1bd9e2db124cd7e2ef13c827f765f3c38/device/sensors/public/cpp/device_util_mac.cc
[add] https://crrev.com/a5d055a1bd9e2db124cd7e2ef13c827f765f3c38/device/sensors/public/cpp/device_util_mac.h

The following revision refers to this bug:
https://chromium.googlesource.com/chromium/src.git/+/ed8fd058823b1502c6290e19c2c4eac7f8739db5
commit ed8fd058823b1502c6290e19c2c4eac7f8739db5
Author: alexis.menard <alexis.menard@intel.com>
Date: Thu Oct 20 19:45:28 2016
[sensors] Make generic_sensor a component
The motivation is to allow classes to be exported (for component builds) so that
a browser test can be written outside of device/ and on top
of content/ and the needed classes can be used to write a fake/mock
provider with fake/mock sensors (the test will come in follow up CL).
The motivation is to test end to end the feature in a cross platform
and non hardware dependent way and checking JavaScript behavior.
BUG=606766
Review-Url: https://chromiumcodereview.appspot.com/2431163004
Cr-Commit-Position: refs/heads/master@{#426567}
[modify] https://crrev.com/ed8fd058823b1502c6290e19c2c4eac7f8739db5/device/generic_sensor/BUILD.gn
[modify] https://crrev.com/ed8fd058823b1502c6290e19c2c4eac7f8739db5/device/generic_sensor/android/sensors_jni_registrar.h
[add] https://crrev.com/ed8fd058823b1502c6290e19c2c4eac7f8739db5/device/generic_sensor/generic_sensor_export.h
[modify] https://crrev.com/ed8fd058823b1502c6290e19c2c4eac7f8739db5/device/generic_sensor/platform_sensor.h
[modify] https://crrev.com/ed8fd058823b1502c6290e19c2c4eac7f8739db5/device/generic_sensor/platform_sensor_provider.h
[modify] https://crrev.com/ed8fd058823b1502c6290e19c2c4eac7f8739db5/device/generic_sensor/platform_sensor_provider_base.h
[modify] https://crrev.com/ed8fd058823b1502c6290e19c2c4eac7f8739db5/device/generic_sensor/public/cpp/BUILD.gn
[modify] https://crrev.com/ed8fd058823b1502c6290e19c2c4eac7f8739db5/device/generic_sensor/public/cpp/platform_sensor_configuration.h
[modify] https://crrev.com/ed8fd058823b1502c6290e19c2c4eac7f8739db5/device/generic_sensor/public/cpp/sensor_reading.h
[modify] https://crrev.com/ed8fd058823b1502c6290e19c2c4eac7f8739db5/device/generic_sensor/public/interfaces/BUILD.gn
[modify] https://crrev.com/ed8fd058823b1502c6290e19c2c4eac7f8739db5/device/generic_sensor/public/interfaces/sensor.typemap
[modify] https://crrev.com/ed8fd058823b1502c6290e19c2c4eac7f8739db5/device/generic_sensor/sensor_provider_impl.h

The following revision refers to this bug:
https://chromium.googlesource.com/chromium/src.git/+/75daa868751b28b3bad9dcc033198c201129ae7d
commit 75daa868751b28b3bad9dcc033198c201129ae7d
Author: alexis.menard <alexis.menard@intel.com>
Date: Fri Oct 21 16:10:32 2016
[sensors][mac] Make sure to update the sensor value when initializing the sensor.
IOServiceAddInterestNotification will only notify when the hardware sensor
value changes however when calling StartSensor we need to make
sure to query the value of the sensor right away to return the correct
value to JavaScript. The reason is that after calling StartSensor
the light conditions may never change and the IOServiceAddInterestNotification
callback will never be called and we return the default 0.0 sensor value. We
can fix this by making sure to initialize the sensor value in
PlatformSensorAmbientLightMac StartSensor.
BUG=606766
Review-Url: https://chromiumcodereview.appspot.com/2417643006
Cr-Commit-Position: refs/heads/master@{#426806}
[modify] https://crrev.com/75daa868751b28b3bad9dcc033198c201129ae7d/device/generic_sensor/platform_sensor_ambient_light_mac.cc
[modify] https://crrev.com/75daa868751b28b3bad9dcc033198c201129ae7d/device/generic_sensor/platform_sensor_ambient_light_mac.h

The following revision refers to this bug:
https://chromium.googlesource.com/chromium/src.git/+/17dc30da8eac6754b74cadf5a530cad8c14c22f8
commit 17dc30da8eac6754b74cadf5a530cad8c14c22f8
Author: alexis.menard <alexis.menard@intel.com>
Date: Thu Oct 27 14:47:21 2016
[sensors] Add a browser test to sanity check ambient light sensor.
The idea of the test is to sanity check the entire generic sensor
integration especially to verify that the data put in the shared
buffer is correctly handled by Blink.
The patch add a way to provide a fake provider which will create
fake sensors so we have a reliable and hardware independent solution.
The rest of the testing is happening either as layout tests or
as unittests in device/generic_sensor.
BUG=606766
Review-Url: https://codereview.chromium.org/2434563005
Cr-Commit-Position: refs/heads/master@{#428025}
[add] https://crrev.com/17dc30da8eac6754b74cadf5a530cad8c14c22f8/content/browser/generic_sensor_browsertest.cc
[modify] https://crrev.com/17dc30da8eac6754b74cadf5a530cad8c14c22f8/content/test/BUILD.gn
[add] https://crrev.com/17dc30da8eac6754b74cadf5a530cad8c14c22f8/content/test/data/generic_sensor/ambient_light_sensor_test.html
[modify] https://crrev.com/17dc30da8eac6754b74cadf5a530cad8c14c22f8/device/generic_sensor/BUILD.gn
[add] https://crrev.com/17dc30da8eac6754b74cadf5a530cad8c14c22f8/device/generic_sensor/platform_sensor_provider.cc
[modify] https://crrev.com/17dc30da8eac6754b74cadf5a530cad8c14c22f8/device/generic_sensor/platform_sensor_provider.h
[modify] https://crrev.com/17dc30da8eac6754b74cadf5a530cad8c14c22f8/device/generic_sensor/platform_sensor_provider_android.cc
[add] https://crrev.com/17dc30da8eac6754b74cadf5a530cad8c14c22f8/device/generic_sensor/platform_sensor_provider_android.h
[delete] https://crrev.com/de18de17de1d3867f99394275792ef81b15bbf46/device/generic_sensor/platform_sensor_provider_default.cc
[modify] https://crrev.com/17dc30da8eac6754b74cadf5a530cad8c14c22f8/device/generic_sensor/platform_sensor_provider_mac.cc

The following revision refers to this bug:
https://chromium.googlesource.com/chromium/src.git/+/85cc22d79580bc5ad58db03ff3e4fb8f9db539a6
commit 85cc22d79580bc5ad58db03ff3e4fb8f9db539a6
Author: maksim.sisov <maksim.sisov@intel.com>
Date: Wed Oct 05 11:13:30 2016
[sensors] Introduce asynchronous way to create sensors.
As long as sensors implementation on Linux/ChromeOS will
be based on reading from files (sensors' files are located
in /sys/dev/iio/devices), asynchronous way of creating
sensors is introduced with this patch.
To be more specific, the asynchronous path is needed because
sensors' existence will be checked by blocking IO methods in
case of Linux/ChromeOS and in order to be able to say
whether a sensor exists or not, asynchronous path will be
used.
In case of Android and Mac, callbacks will be
called immediately as soon as a sensor manager in Android or
IOServiceGetMatchingService in Mac returns a sensor object
or nullptr.
How it works:
As soon as a request for a new sensor is received, callbacks
are stored into a vector which is pushed into a map with a
type key and the vector itself. If no callback has been
stored before, CreateSensorInternal() method is called.
Then:
*Linux/ChromeOS (under development): a new thread is
created which will handle concrete sensors creation.
*Android: when CreateSensorInternal() is called, java code
is called and everything is handled by the sensor manager,
which returns synchronously. Once sensor found, it is
returned. Otherwise, nullptr is returned.
*Mac (under development)
https://codereview.chromium.org/2332903002/: everything
is handled by IOServiceGetMatchingService, which returns
synchronously.
BUG=606766
Review-Url: https://codereview.chromium.org/2368193003
Cr-Commit-Position: refs/heads/master@{#423127}
[modify] https://crrev.com/85cc22d79580bc5ad58db03ff3e4fb8f9db539a6/device/generic_sensor/fake_platform_sensor_provider.cc
[modify] https://crrev.com/85cc22d79580bc5ad58db03ff3e4fb8f9db539a6/device/generic_sensor/fake_platform_sensor_provider.h
[modify] https://crrev.com/85cc22d79580bc5ad58db03ff3e4fb8f9db539a6/device/generic_sensor/platform_sensor_provider_android.cc
[modify] https://crrev.com/85cc22d79580bc5ad58db03ff3e4fb8f9db539a6/device/generic_sensor/platform_sensor_provider_base.cc
[modify] https://crrev.com/85cc22d79580bc5ad58db03ff3e4fb8f9db539a6/device/generic_sensor/platform_sensor_provider_base.h
[modify] https://crrev.com/85cc22d79580bc5ad58db03ff3e4fb8f9db539a6/device/generic_sensor/platform_sensor_provider_unittest.cc
[modify] https://crrev.com/85cc22d79580bc5ad58db03ff3e4fb8f9db539a6/device/generic_sensor/sensor_provider_impl.cc
[modify] https://crrev.com/85cc22d79580bc5ad58db03ff3e4fb8f9db539a6/device/generic_sensor/sensor_provider_impl.h

The following revision refers to this bug:
https://chromium.googlesource.com/chromium/src.git/+/24e8468bd738a1df17fe4f20ea251b3d87c4978a
commit 24e8468bd738a1df17fe4f20ea251b3d87c4978a
Author: alexis.menard <alexis.menard@intel.com>
Date: Wed Oct 05 19:48:53 2016
[sensors] Fix crash after 85cc22d when using async creation of sensors.
The fix is simple as the callback was called with null pointers. Make
sure to call it with the right arguments.
BUG=606766
Review-Url: https://codereview.chromium.org/2396873002
Cr-Commit-Position: refs/heads/master@{#423259}
[modify] https://crrev.com/24e8468bd738a1df17fe4f20ea251b3d87c4978a/device/generic_sensor/sensor_provider_impl.cc

The following revision refers to this bug:
https://chromium.googlesource.com/chromium/src.git/+/f0948b6c3cec6e8764fef47ed299d5a77414a987
commit f0948b6c3cec6e8764fef47ed299d5a77414a987
Author: alexander.shalamov <alexander.shalamov@intel.com>
Date: Thu Nov 03 13:50:34 2016
[sensors] Close mock sensor stubs after test is finished
Before this CL, mock sensor instance was reused by all tests. This CL adds
code that closes mocked sensor stubs after each test, so that on the Blink
side, SensorProxy will reset and release resources associated with the sensor.
This allows to write layout tests that simulate different behavior for the
sensor of the same type.
BUG=606766
Review-Url: https://codereview.chromium.org/2471103002
Cr-Commit-Position: refs/heads/master@{#429564}
[modify] https://crrev.com/f0948b6c3cec6e8764fef47ed299d5a77414a987/third_party/WebKit/LayoutTests/sensor/ambient-light-sensor.html
[modify] https://crrev.com/f0948b6c3cec6e8764fef47ed299d5a77414a987/third_party/WebKit/LayoutTests/sensor/resources/sensor-helpers.js
[modify] https://crrev.com/f0948b6c3cec6e8764fef47ed299d5a77414a987/third_party/WebKit/Source/modules/sensor/SensorProxy.cpp
[modify] https://crrev.com/f0948b6c3cec6e8764fef47ed299d5a77414a987/third_party/WebKit/Source/modules/sensor/SensorProxy.h

The following revision refers to this bug:
https://chromium.googlesource.com/chromium/src.git/+/de2d07084492be68633a47bae161cf9014ac88e2
commit de2d07084492be68633a47bae161cf9014ac88e2
Author: maksim.sisov <maksim.sisov@intel.com>
Date: Thu Nov 03 14:56:42 2016
[sensors] Ambient light sensor implementation for ChromeOS and Linux.
The patch introduces sensors implementation for
ChromeOS/Linux platforms using ambient light sensor. Both
platforms share the same code and require polling threads to
be used.
SensorDataIio structure is used to initialize a generic
SensorReader, which is created only when sensor read files
are found, and to create a concrete sensor, which takes
an ownership of the SensorReader.
A SensorReader must always be created on a polling thread,
which is further used by a sensor to poll data. Each new
sensor will have its own thread in order to avoid blocking of
each other.
As a temp solution to manage polling threads, which are not
passed to new sensors, a manager thread is used. It kills a
polling thread if a sensor cannot be created. In the future,
the manager thread will evolve to a manager class that will
manage finding new sensors attached to a system and notify a
provider about that. The provider will have its own cache in
order to avoid trying to find sensors each time after it
fails to find a requested sensor. Once the manager notifies
the provider about a new sensor, the provider updates its
cache and starts to process requests for that type of sensor.
Intent to Implement:
https://groups.google.com/a/chromium.org/forum/#!msg/blink-dev/TkfdVqYAYiE/xLGN2b1-AAAJ
BUG=606766
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_site_isolation
Review-Url: https://codereview.chromium.org/2370343002
Cr-Commit-Position: refs/heads/master@{#429584}
[modify] https://crrev.com/de2d07084492be68633a47bae161cf9014ac88e2/chrome/browser/about_flags.cc
[modify] https://crrev.com/de2d07084492be68633a47bae161cf9014ac88e2/content/browser/frame_host/render_frame_host_impl.cc
[modify] https://crrev.com/de2d07084492be68633a47bae161cf9014ac88e2/device/BUILD.gn
[modify] https://crrev.com/de2d07084492be68633a47bae161cf9014ac88e2/device/generic_sensor/BUILD.gn
[add] https://crrev.com/de2d07084492be68633a47bae161cf9014ac88e2/device/generic_sensor/linux/platform_sensor_utils_linux.cc
[add] https://crrev.com/de2d07084492be68633a47bae161cf9014ac88e2/device/generic_sensor/linux/platform_sensor_utils_linux.h
[add] https://crrev.com/de2d07084492be68633a47bae161cf9014ac88e2/device/generic_sensor/linux/sensor_data_linux.cc
[add] https://crrev.com/de2d07084492be68633a47bae161cf9014ac88e2/device/generic_sensor/linux/sensor_data_linux.h
[add] https://crrev.com/de2d07084492be68633a47bae161cf9014ac88e2/device/generic_sensor/linux/sensor_reader_unittest.cc
[add] https://crrev.com/de2d07084492be68633a47bae161cf9014ac88e2/device/generic_sensor/platform_sensor_linux.cc
[add] https://crrev.com/de2d07084492be68633a47bae161cf9014ac88e2/device/generic_sensor/platform_sensor_linux.h
[modify] https://crrev.com/de2d07084492be68633a47bae161cf9014ac88e2/device/generic_sensor/platform_sensor_provider.cc
[modify] https://crrev.com/de2d07084492be68633a47bae161cf9014ac88e2/device/generic_sensor/platform_sensor_provider_base.h
[add] https://crrev.com/de2d07084492be68633a47bae161cf9014ac88e2/device/generic_sensor/platform_sensor_provider_linux.cc
[add] https://crrev.com/de2d07084492be68633a47bae161cf9014ac88e2/device/generic_sensor/platform_sensor_provider_linux.h
[modify] https://crrev.com/de2d07084492be68633a47bae161cf9014ac88e2/device/generic_sensor/sensor_provider_impl.cc
[modify] https://crrev.com/de2d07084492be68633a47bae161cf9014ac88e2/device/generic_sensor/sensor_provider_impl.h

The following revision refers to this bug:
https://chromium.googlesource.com/chromium/src.git/+/ae21a578c51e7d8a6a228dbd27594dea0416cf8b
commit ae21a578c51e7d8a6a228dbd27594dea0416cf8b
Author: mathp <mathp@chromium.org>
Date: Thu Nov 03 16:02:54 2016
Revert of [sensors] Ambient light sensor implementation for ChromeOS and Linux. (patchset #26 id:1050001 of https://codereview.chromium.org/2370343002/ )
Reason for revert:
Causing a failure on Linux bot:
https://build.chromium.org/p/chromium/builders/Linux%20x64/builds/28030
Original issue's description:
> [sensors] Ambient light sensor implementation for ChromeOS and Linux.
>
> The patch introduces sensors implementation for
> ChromeOS/Linux platforms using ambient light sensor. Both
> platforms share the same code and require polling threads to
> be used.
>
> SensorDataIio structure is used to initialize a generic
> SensorReader, which is created only when sensor read files
> are found, and to create a concrete sensor, which takes
> an ownership of the SensorReader.
>
> A SensorReader must always be created on a polling thread,
> which is further used by a sensor to poll data. Each new
> sensor will have its own thread in order to avoid blocking of
> each other.
>
> As a temp solution to manage polling threads, which are not
> passed to new sensors, a manager thread is used. It kills a
> polling thread if a sensor cannot be created. In the future,
> the manager thread will evolve to a manager class that will
> manage finding new sensors attached to a system and notify a
> provider about that. The provider will have its own cache in
> order to avoid trying to find sensors each time after it
> fails to find a requested sensor. Once the manager notifies
> the provider about a new sensor, the provider updates its
> cache and starts to process requests for that type of sensor.
>
> Intent to Implement:
> https://groups.google.com/a/chromium.org/forum/#!msg/blink-dev/TkfdVqYAYiE/xLGN2b1-AAAJ
>
> BUG=606766
> CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_site_isolation
>
> Committed: https://crrev.com/de2d07084492be68633a47bae161cf9014ac88e2
> Cr-Commit-Position: refs/heads/master@{#429584}
TBR=reillyg@chromium.org,alexander.shalamov@intel.com,alexis.menard@intel.com,alexmos@chromium.org,mikhail.pozdnyakov@intel.com,rockot@chromium.org,timvolodine@chromium.org,maksim.sisov@intel.com
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=606766
Review-Url: https://codereview.chromium.org/2468283003
Cr-Commit-Position: refs/heads/master@{#429604}
[modify] https://crrev.com/ae21a578c51e7d8a6a228dbd27594dea0416cf8b/chrome/browser/about_flags.cc
[modify] https://crrev.com/ae21a578c51e7d8a6a228dbd27594dea0416cf8b/content/browser/frame_host/render_frame_host_impl.cc
[modify] https://crrev.com/ae21a578c51e7d8a6a228dbd27594dea0416cf8b/device/BUILD.gn
[modify] https://crrev.com/ae21a578c51e7d8a6a228dbd27594dea0416cf8b/device/generic_sensor/BUILD.gn
[delete] https://crrev.com/74836cf56afe5eca812e274200c210dd24d067c1/device/generic_sensor/linux/platform_sensor_utils_linux.cc
[delete] https://crrev.com/74836cf56afe5eca812e274200c210dd24d067c1/device/generic_sensor/linux/platform_sensor_utils_linux.h
[delete] https://crrev.com/74836cf56afe5eca812e274200c210dd24d067c1/device/generic_sensor/linux/sensor_data_linux.cc
[delete] https://crrev.com/74836cf56afe5eca812e274200c210dd24d067c1/device/generic_sensor/linux/sensor_data_linux.h
[delete] https://crrev.com/74836cf56afe5eca812e274200c210dd24d067c1/device/generic_sensor/linux/sensor_reader_unittest.cc
[delete] https://crrev.com/74836cf56afe5eca812e274200c210dd24d067c1/device/generic_sensor/platform_sensor_linux.cc
[delete] https://crrev.com/74836cf56afe5eca812e274200c210dd24d067c1/device/generic_sensor/platform_sensor_linux.h
[modify] https://crrev.com/ae21a578c51e7d8a6a228dbd27594dea0416cf8b/device/generic_sensor/platform_sensor_provider.cc
[modify] https://crrev.com/ae21a578c51e7d8a6a228dbd27594dea0416cf8b/device/generic_sensor/platform_sensor_provider_base.h
[delete] https://crrev.com/74836cf56afe5eca812e274200c210dd24d067c1/device/generic_sensor/platform_sensor_provider_linux.cc
[delete] https://crrev.com/74836cf56afe5eca812e274200c210dd24d067c1/device/generic_sensor/platform_sensor_provider_linux.h
[modify] https://crrev.com/ae21a578c51e7d8a6a228dbd27594dea0416cf8b/device/generic_sensor/sensor_provider_impl.cc
[modify] https://crrev.com/ae21a578c51e7d8a6a228dbd27594dea0416cf8b/device/generic_sensor/sensor_provider_impl.h

The following revision refers to this bug:
https://chromium.googlesource.com/chromium/src.git/+/c0876ac8f8439dc4511f4172bc4856d2358e9f67
commit c0876ac8f8439dc4511f4172bc4856d2358e9f67
Author: maksim.sisov <maksim.sisov@intel.com>
Date: Fri Nov 04 22:54:12 2016
Reland of [sensors] Ambient light sensor implementation for ChromeOS and Linux.
The patch introduces sensors implementation for
ChromeOS/Linux platforms using ambient light sensor. Both
platforms share the same code and require polling threads to
be used.
SensorDataIio structure is used to initialize a generic
SensorReader, which is created only when sensor read files
are found, and to create a concrete sensor, which takes
an ownership of the SensorReader.
A SensorReader must always be created on a polling thread,
which is further used by a sensor to poll data. Each new
sensor will have its own thread in order to avoid blocking of
each other.
As a temp solution to manage polling threads, which are not
passed to new sensors, a manager thread is used. It kills a
polling thread if a sensor cannot be created. In the future,
the manager thread will evolve to a manager class that will
manage finding new sensors attached to a system and notify a
provider about that. The provider will have its own cache in
order to avoid trying to find sensors each time after it
fails to find a requested sensor. Once the manager notifies
the provider about a new sensor, the provider updates its
cache and starts to process requests for that type of sensor.
Intent to Implement:
https://groups.google.com/a/chromium.org/forum/#!msg/blink-dev/TkfdVqYAYiE/xLGN2b1-AAAJ
The first patchset is a last reverted patch. The second one provides
a fix to reland the code.
reverted cl:
https://codereview.chromium.org/2370343002/
BUG=606766
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_site_isolation
Review-Url: https://codereview.chromium.org/2480773002
Cr-Commit-Position: refs/heads/master@{#430049}
[modify] https://crrev.com/c0876ac8f8439dc4511f4172bc4856d2358e9f67/chrome/browser/about_flags.cc
[modify] https://crrev.com/c0876ac8f8439dc4511f4172bc4856d2358e9f67/content/browser/frame_host/render_frame_host_impl.cc
[modify] https://crrev.com/c0876ac8f8439dc4511f4172bc4856d2358e9f67/device/BUILD.gn
[modify] https://crrev.com/c0876ac8f8439dc4511f4172bc4856d2358e9f67/device/generic_sensor/BUILD.gn
[add] https://crrev.com/c0876ac8f8439dc4511f4172bc4856d2358e9f67/device/generic_sensor/linux/platform_sensor_utils_linux.cc
[add] https://crrev.com/c0876ac8f8439dc4511f4172bc4856d2358e9f67/device/generic_sensor/linux/platform_sensor_utils_linux.h
[add] https://crrev.com/c0876ac8f8439dc4511f4172bc4856d2358e9f67/device/generic_sensor/linux/sensor_data_linux.cc
[add] https://crrev.com/c0876ac8f8439dc4511f4172bc4856d2358e9f67/device/generic_sensor/linux/sensor_data_linux.h
[add] https://crrev.com/c0876ac8f8439dc4511f4172bc4856d2358e9f67/device/generic_sensor/linux/sensor_reader_unittest.cc
[add] https://crrev.com/c0876ac8f8439dc4511f4172bc4856d2358e9f67/device/generic_sensor/platform_sensor_linux.cc
[add] https://crrev.com/c0876ac8f8439dc4511f4172bc4856d2358e9f67/device/generic_sensor/platform_sensor_linux.h
[modify] https://crrev.com/c0876ac8f8439dc4511f4172bc4856d2358e9f67/device/generic_sensor/platform_sensor_provider.cc
[modify] https://crrev.com/c0876ac8f8439dc4511f4172bc4856d2358e9f67/device/generic_sensor/platform_sensor_provider_base.h
[add] https://crrev.com/c0876ac8f8439dc4511f4172bc4856d2358e9f67/device/generic_sensor/platform_sensor_provider_linux.cc
[add] https://crrev.com/c0876ac8f8439dc4511f4172bc4856d2358e9f67/device/generic_sensor/platform_sensor_provider_linux.h
[modify] https://crrev.com/c0876ac8f8439dc4511f4172bc4856d2358e9f67/device/generic_sensor/sensor_provider_impl.cc
[modify] https://crrev.com/c0876ac8f8439dc4511f4172bc4856d2358e9f67/device/generic_sensor/sensor_provider_impl.h

The following revision refers to this bug:
https://chromium.googlesource.com/chromium/src.git/+/8fd4ba018ddfebcfc47966eea9ea3a75ed0b5fa0
commit 8fd4ba018ddfebcfc47966eea9ea3a75ed0b5fa0
Author: alexis.menard <alexis.menard@intel.com>
Date: Wed Nov 09 22:03:15 2016
[sensors] [mac] Fix ambient light sensor not updating its value when closing the lid with a monitor connected.
Right now we use IOServiceAddInterestNotification with kIOGeneralInterest
as a way to get value changes from the AppleLMUController whenever
the ambient light condition changes.
However when closing the lid rapidly and a monitor is connected (which
prevents the computer to go to sleep) we don't receive a notification
and callback from the controller the whole way (until the lid is fully
closed). It means that the latest value received in JavaScript is not what
would be expected : as a developer point of view, lid closed = dark = 0.0
as a lux value.
The patch now listen kIOBusyInterest as well because when closing
the lid the AppleLMUController sends busy events which we can use
to fetch the value of the sensor and report it back in JavaScript.
BUG=606766
Review-Url: https://codereview.chromium.org/2447273002
Cr-Commit-Position: refs/heads/master@{#431046}
[modify] https://crrev.com/8fd4ba018ddfebcfc47966eea9ea3a75ed0b5fa0/device/generic_sensor/platform_sensor_ambient_light_mac.cc
[modify] https://crrev.com/8fd4ba018ddfebcfc47966eea9ea3a75ed0b5fa0/device/generic_sensor/platform_sensor_ambient_light_mac.h

The following revision refers to this bug:
https://chromium.googlesource.com/chromium/src.git/+/d6305cf853f1e9e6fb1cd9afbf3f9483204e33be
commit d6305cf853f1e9e6fb1cd9afbf3f9483204e33be
Author: alexis.menard <alexis.menard@intel.com>
Date: Mon Nov 14 23:20:38 2016
[sensors] Improve the generic sensors current layout tests.
Move all the tests that are going to be common in a single file.
Each of the sensor type will call a function to get the generic
tests to run. Specific sensor test can still be added in their
respective html files.
BUG=606766
Review-Url: https://codereview.chromium.org/2494773004
Cr-Commit-Position: refs/heads/master@{#431960}
[modify] https://crrev.com/d6305cf853f1e9e6fb1cd9afbf3f9483204e33be/third_party/WebKit/LayoutTests/sensor/ambient-light-sensor.html
[add] https://crrev.com/d6305cf853f1e9e6fb1cd9afbf3f9483204e33be/third_party/WebKit/LayoutTests/sensor/resources/generic-sensor-tests.js

The following revision refers to this bug:
https://chromium.googlesource.com/chromium/src.git/+/7ef84cca9ddf9928a08967084030632d21b7fbff
commit 7ef84cca9ddf9928a08967084030632d21b7fbff
Author: mikhail.pozdnyakov <mikhail.pozdnyakov@intel.com>
Date: Wed Nov 23 08:22:35 2016
[Sensors] Improvements in fetching reading for sensors with continuous reporting mode
If a platform sensors has continuous reporting mode its updates are not send via IPC, so there is a timer on Blink side which periodically reads the sensor data from shared buffer.
Before this change every sensor instance had its own repeating timer, however in case of multiple sensor instances it could bloat the thread task queue with unneeded requests to read the sensor data from shared buffer.
This patch introduces only one repeating timer per 'SensorProxy' (i.e. per frame) which is shared between all sensor instances of the same type.
Another consequent change is that now the 'SensorProxy' class is inherited from 'PageVisibilityObserver' (and the 'Sensor' class is not any more) which makes suspend/resume code path more efficient.
BUG=606766
Review-Url: https://codereview.chromium.org/2503853002
Cr-Commit-Position: refs/heads/master@{#434133}
[modify] https://crrev.com/7ef84cca9ddf9928a08967084030632d21b7fbff/third_party/WebKit/Source/modules/sensor/BUILD.gn
[modify] https://crrev.com/7ef84cca9ddf9928a08967084030632d21b7fbff/third_party/WebKit/Source/modules/sensor/Sensor.cpp
[modify] https://crrev.com/7ef84cca9ddf9928a08967084030632d21b7fbff/third_party/WebKit/Source/modules/sensor/Sensor.h
[delete] https://crrev.com/a3e6a48f576f8130788f731c8d8e6c7525118edf/third_party/WebKit/Source/modules/sensor/SensorPollingStrategy.cpp
[delete] https://crrev.com/a3e6a48f576f8130788f731c8d8e6c7525118edf/third_party/WebKit/Source/modules/sensor/SensorPollingStrategy.h
[modify] https://crrev.com/7ef84cca9ddf9928a08967084030632d21b7fbff/third_party/WebKit/Source/modules/sensor/SensorProviderProxy.cpp
[modify] https://crrev.com/7ef84cca9ddf9928a08967084030632d21b7fbff/third_party/WebKit/Source/modules/sensor/SensorProviderProxy.h
[modify] https://crrev.com/7ef84cca9ddf9928a08967084030632d21b7fbff/third_party/WebKit/Source/modules/sensor/SensorProxy.cpp
[modify] https://crrev.com/7ef84cca9ddf9928a08967084030632d21b7fbff/third_party/WebKit/Source/modules/sensor/SensorProxy.h
[add] https://crrev.com/7ef84cca9ddf9928a08967084030632d21b7fbff/third_party/WebKit/Source/modules/sensor/SensorUpdateNotificationStrategy.cpp
[add] https://crrev.com/7ef84cca9ddf9928a08967084030632d21b7fbff/third_party/WebKit/Source/modules/sensor/SensorUpdateNotificationStrategy.h

The following revision refers to this bug:
https://chromium.googlesource.com/chromium/src.git/+/8825a7140545d858daa36defc294668a79ecf1bf
commit 8825a7140545d858daa36defc294668a79ecf1bf
Author: alexander.shalamov <alexander.shalamov@intel.com>
Date: Wed Nov 30 09:01:34 2016
[sensors] Fix flakiness in generic sensors tests
This patch fixes flakiness for generic sensors layout tests by resetting
SensorProvider mock stub bindings at the end of the each layout test and
re-initializing it when needed in SensorProviderProxy.
Before this CL, if multiple sensor tests were executed by the same
content shell instance, Frame's mojo interface overrides were reset after
each test, yet SensorProviderProxy was not aware of it and kept using old
SensorProvider mojom proxy.
BUG=606766
Review-Url: https://codereview.chromium.org/2529343002
Cr-Commit-Position: refs/heads/master@{#435187}
[modify] https://crrev.com/8825a7140545d858daa36defc294668a79ecf1bf/third_party/WebKit/LayoutTests/sensor/resources/generic-sensor-tests.js
[modify] https://crrev.com/8825a7140545d858daa36defc294668a79ecf1bf/third_party/WebKit/LayoutTests/sensor/resources/sensor-helpers.js
[modify] https://crrev.com/8825a7140545d858daa36defc294668a79ecf1bf/third_party/WebKit/Source/modules/sensor/SensorProviderProxy.cpp
[modify] https://crrev.com/8825a7140545d858daa36defc294668a79ecf1bf/third_party/WebKit/Source/modules/sensor/SensorProviderProxy.h
[modify] https://crrev.com/8825a7140545d858daa36defc294668a79ecf1bf/third_party/WebKit/Source/modules/sensor/SensorProxy.cpp

The following revision refers to this bug:
https://chromium.googlesource.com/chromium/src.git/+/26947f590d1526ea0cf3d485382da6dc1a068ec5
commit 26947f590d1526ea0cf3d485382da6dc1a068ec5
Author: alexis.menard <alexis.menard@intel.com>
Date: Thu Dec 01 01:14:58 2016
[sensors] [win] Fix ambient light not working properly on Windows 10.
The event listener was never called despite SetEventSink returning
success. Debbuging further it turns out that the event listener was
created in the sensor thread, however the listener was not set in
the sensor thread (from StartSensor()), this seems to confuse COM.
BUG=606766
Review-Url: https://codereview.chromium.org/2495073002
Cr-Commit-Position: refs/heads/master@{#435513}
[modify] https://crrev.com/26947f590d1526ea0cf3d485382da6dc1a068ec5/device/generic_sensor/platform_sensor_and_provider_unittest_win.cc
[modify] https://crrev.com/26947f590d1526ea0cf3d485382da6dc1a068ec5/device/generic_sensor/platform_sensor_reader_win.cc
[modify] https://crrev.com/26947f590d1526ea0cf3d485382da6dc1a068ec5/device/generic_sensor/platform_sensor_reader_win.h

The following revision refers to this bug:
https://chromium.googlesource.com/chromium/src.git/+/061d113db7069c23fe84a0a9365965647ed97b51
commit 061d113db7069c23fe84a0a9365965647ed97b51
Author: maksim.sisov <maksim.sisov@intel.com>
Date: Fri Dec 09 16:04:21 2016
[sensors](CrOS/Linux) Implement Sensor device manager for sensors
This cl introduces a SensorDeviceManager for Linux and ChromeOS platforms.
Manager:
1) PlatformSensorProviderLinux owns a SensorDeviceManager that uses
DeviceMonitorLinux to enumerate iio devices and get removed/add udev
events. Once device is enumerated, added or removed, it is identified
and all the necessary information is put to SensorInfoLinux structure
and passed to the provider. If there is no such a device, it is added
to cache. In case of removal, manager checks if there was such a device
and updates it's cache accordingly + notifies the provider about a
removed device, which update own cache.
2) Requests: when a request for a sensor comes, it can be processed
immediately or asynchronously once service is up and running.
Reader:
1) There will be two strategies for a reader. At the moment
only polling read is supported.
2) The reader doesn't search for sensor files any more, those are passed
to it in SensorInfoLinux structure.
Unittests:
1) In order to make it possible to test the whole path, I've made
SensorDeviceManager's methods virtual, which allowed me to
mock and override them.
2) Unittests implement own udev methods that just read values from
files. If read is successful, the manager adds this type of sensor
associated with the files that have been read to it's cache and notifies
the provider.
BUG=606766
Review-Url: https://codereview.chromium.org/2533793002
Cr-Commit-Position: refs/heads/master@{#437550}
[modify] https://crrev.com/061d113db7069c23fe84a0a9365965647ed97b51/device/BUILD.gn
[modify] https://crrev.com/061d113db7069c23fe84a0a9365965647ed97b51/device/generic_sensor/BUILD.gn
[add] https://crrev.com/061d113db7069c23fe84a0a9365965647ed97b51/device/generic_sensor/linux/platform_sensor_manager.cc
[add] https://crrev.com/061d113db7069c23fe84a0a9365965647ed97b51/device/generic_sensor/linux/platform_sensor_manager.h
[delete] https://crrev.com/b0246be63c67f341421ee64196857479e7e2b9ef/device/generic_sensor/linux/platform_sensor_utils_linux.cc
[delete] https://crrev.com/b0246be63c67f341421ee64196857479e7e2b9ef/device/generic_sensor/linux/platform_sensor_utils_linux.h
[modify] https://crrev.com/061d113db7069c23fe84a0a9365965647ed97b51/device/generic_sensor/linux/sensor_data_linux.cc
[modify] https://crrev.com/061d113db7069c23fe84a0a9365965647ed97b51/device/generic_sensor/linux/sensor_data_linux.h
[delete] https://crrev.com/b0246be63c67f341421ee64196857479e7e2b9ef/device/generic_sensor/linux/sensor_reader_unittest.cc
[add] https://crrev.com/061d113db7069c23fe84a0a9365965647ed97b51/device/generic_sensor/platform_sensor_and_provider_unittest_linux.cc
[modify] https://crrev.com/061d113db7069c23fe84a0a9365965647ed97b51/device/generic_sensor/platform_sensor_linux.cc
[modify] https://crrev.com/061d113db7069c23fe84a0a9365965647ed97b51/device/generic_sensor/platform_sensor_linux.h
[modify] https://crrev.com/061d113db7069c23fe84a0a9365965647ed97b51/device/generic_sensor/platform_sensor_provider.cc
[modify] https://crrev.com/061d113db7069c23fe84a0a9365965647ed97b51/device/generic_sensor/platform_sensor_provider_base.cc
[modify] https://crrev.com/061d113db7069c23fe84a0a9365965647ed97b51/device/generic_sensor/platform_sensor_provider_base.h
[modify] https://crrev.com/061d113db7069c23fe84a0a9365965647ed97b51/device/generic_sensor/platform_sensor_provider_linux.cc
[modify] https://crrev.com/061d113db7069c23fe84a0a9365965647ed97b51/device/generic_sensor/platform_sensor_provider_linux.h
[add] https://crrev.com/061d113db7069c23fe84a0a9365965647ed97b51/device/generic_sensor/platform_sensor_reader_linux.cc
[add] https://crrev.com/061d113db7069c23fe84a0a9365965647ed97b51/device/generic_sensor/platform_sensor_reader_linux.h