Skip to content

Commit

Permalink
Revert of Move //device/generic_sensor to be part of the internal imp…
Browse files Browse the repository at this point in the history
…lementation of the Device Service. (patchset chromium#11 id:200001 of https://codereview.chromium.org/2865263002/ )

Reason for revert:
Seems to have broken GenericSensorBrowserTest.AmbientLightSensorTest:

https://build.chromium.org/p/chromium.win/builders/Win7%20Tests%20(dbg)(1)/builds/60103
https://build.chromium.org/p/chromium.mac/builders/Mac10.9%20Tests%20(dbg)/builds/40665
https://build.chromium.org/p/chromium.chromiumos/builders/Linux%20ChromiumOS%20Tests%20%28dbg%29%281%29/builds/26223

Original issue's description:
> Remove the *.export.h, change the gn target 'component' to 'source_set', which makes the generic sensor to be the internal implementation of //services.
>
> BUG=689384
>
> Review-Url: https://codereview.chromium.org/2865263002
> Cr-Commit-Position: refs/heads/master@{#473160}
> Committed: https://chromium.googlesource.com/chromium/src/+/9b5cf7f93a4b2f246d08208ccd17804856c38f6a

TBR=rockot@chromium.org,blundell@chromium.org,jam@chromium.org,alexander.shalamov@intel.com,tsepez@chromium.org,reillyg@chromium.org,ke.he@intel.com
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=689384

Review-Url: https://codereview.chromium.org/2898433002
Cr-Commit-Position: refs/heads/master@{#473172}
  • Loading branch information
treib authored and Commit bot committed May 19, 2017
1 parent ab6a896 commit b6fa2c5
Show file tree
Hide file tree
Showing 92 changed files with 386 additions and 297 deletions.
1 change: 1 addition & 0 deletions content/app/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ template("implement_content_app") {
"//content/public/android:jni",
"//device/bluetooth",
"//device/gamepad",
"//device/generic_sensor",
"//device/geolocation",
"//device/power_save_blocker",
"//device/sensors",
Expand Down
1 change: 1 addition & 0 deletions content/app/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ include_rules = [
"+content",
"+device/bluetooth",
"+device/gamepad",
"+device/generic_sensor",
"+device/geolocation",
"+device/power_save_blocker",
"+device/sensors",
Expand Down
4 changes: 4 additions & 0 deletions content/app/android/library_loader_hooks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "content/public/common/result_codes.h"
#include "device/bluetooth/android/bluetooth_jni_registrar.h"
#include "device/gamepad/android/gamepad_jni_registrar.h"
#include "device/generic_sensor/android/sensors_jni_registrar.h"
#include "device/geolocation/android/geolocation_jni_registrar.h"
#include "device/sensors/android/device_sensor_jni_registrar.h"
#include "device/usb/android/usb_jni_registrar.h"
Expand Down Expand Up @@ -89,6 +90,9 @@ bool EnsureJniRegistered(JNIEnv* env) {
if (!device::android::RegisterGeolocationJni(env))
return false;

if (!device::android::RegisterSensorsJni(env))
return false;

if (!device::android::RegisterUsbJni(env))
return false;

Expand Down
1 change: 1 addition & 0 deletions content/browser/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ include_rules = [
"+content/app/strings/grit", # For generated headers
"+content/public/browser",
"+device/gamepad", # For gamepad API
"+device/generic_sensor", # For sensors service.
"+device/geolocation",
"+device/nfc",
"+device/power_save_blocker",
Expand Down
6 changes: 3 additions & 3 deletions content/browser/generic_sensor_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
#include "content/public/test/test_utils.h"
#include "content/shell/browser/shell.h"
#include "content/shell/browser/shell_javascript_dialog_manager.h"
#include "services/device/generic_sensor/platform_sensor.h"
#include "services/device/generic_sensor/platform_sensor_provider.h"
#include "services/device/generic_sensor/sensor_provider_impl.h"
#include "device/generic_sensor/platform_sensor.h"
#include "device/generic_sensor/platform_sensor_provider.h"
#include "device/generic_sensor/sensor_provider_impl.h"

namespace content {

Expand Down
1 change: 1 addition & 0 deletions content/public/android/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ android_library("content_java") {
"//base:base_java",
"//device/bluetooth:java",
"//device/gamepad:java",
"//device/generic_sensor:java",
"//device/nfc:mojo_bindings_java",
"//device/nfc/public/java:nfc_java",
"//device/power_save_blocker:java",
Expand Down
2 changes: 1 addition & 1 deletion content/test/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,7 @@ test("content_browsertests") {
"//content/shell:pak",
"//content/test:test_support",
"//device/base/synchronization",
"//device/generic_sensor",
"//device/power_save_blocker",
"//device/screen_orientation/public/interfaces",
"//device/sensors",
Expand All @@ -778,7 +779,6 @@ test("content_browsertests") {
"//net:test_support",
"//ppapi/features",
"//services/catalog:lib",
"//services/device/generic_sensor",
"//services/device/public/interfaces",
"//services/device/public/interfaces:constants",
"//services/service_manager/public/cpp",
Expand Down
15 changes: 15 additions & 0 deletions device/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ test("device_unittests") {
"gamepad/gamepad_provider_unittest.cc",
"gamepad/gamepad_service_unittest.cc",
"gamepad/public/interfaces/gamepad_struct_traits_unittest.cc",
"generic_sensor/platform_sensor_and_provider_unittest_win.cc",
"generic_sensor/platform_sensor_provider_unittest.cc",
"sensors/data_fetcher_shared_memory_base_unittest.cc",
"sensors/sensor_manager_android_unittest.cc",
"sensors/sensor_manager_chromeos_unittest.cc",
Expand All @@ -86,6 +88,8 @@ test("device_unittests") {
"//device/gamepad/public/cpp:shared_with_blink",
"//device/gamepad/public/interfaces",
"//device/gamepad/public/interfaces:gamepad_struct_traits_test",
"//device/generic_sensor",
"//device/generic_sensor:testing",
"//device/geolocation:unittests",
"//device/power_save_blocker",
"//device/sensors",
Expand All @@ -103,6 +107,11 @@ test("device_unittests") {
"//url",
]

if (!is_linux_without_udev) {
sources +=
[ "generic_sensor/platform_sensor_and_provider_unittest_linux.cc" ]
}

# HID and Serial:
# Android doesn't compile.
# Linux, requires udev.
Expand Down Expand Up @@ -238,6 +247,12 @@ test("device_unittests") {
"bluetooth/bluetooth_low_energy_win_fake.cc",
"bluetooth/bluetooth_low_energy_win_fake.h",
]

# Needed for "generic_sensor/platform_sensor_and_provider_unittest_win.cc"
libs = [
"propsys.lib",
"sensorsapi.lib",
]
}

if (enable_vr) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ if (is_android) {
import("//build/config/android/rules.gni") # For generate_jni().
}

source_set("generic_sensor") {
component("generic_sensor") {
output_name = "generic_sensor"
sources = [
"generic_sensor_consts.h",
"generic_sensor_export.h",
"linux/sensor_data_linux.cc",
"linux/sensor_data_linux.h",
"platform_sensor.cc",
Expand Down Expand Up @@ -46,13 +47,15 @@ source_set("generic_sensor") {
"sensor_provider_impl.h",
]

defines = [ "DEVICE_GENERIC_SENSOR_IMPLEMENTATION" ]

deps = [
"//base",
"//device/base/synchronization",
]

public_deps = [
"//services/device/public/cpp/generic_sensor",
"//device/generic_sensor/public/cpp",
]

if (is_android) {
Expand Down Expand Up @@ -113,7 +116,7 @@ if (is_android) {

deps = [
"//base:base_java",
"//services/device/public/interfaces:generic_sensor_java",
"//device/generic_sensor/public/interfaces:interfaces_java",
]
}
}
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Sensors

`services/device/generic_sensor` contains the platform-specific parts of the Sensor APIs
`device/generic_sensor` contains the platform-specific parts of the Sensor APIs
implementation.

Sensors Mojo interfaces are defined in the `services/public/interfaces` subdirectory.
Sensors Mojo interfaces are defined in the `public/interfaces` subdirectory.

The JS bindings are implemented in `third_party/WebKit/Source/modules/sensor`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "services/device/generic_sensor/android/sensors_jni_registrar.h"
#include "device/generic_sensor/android/sensors_jni_registrar.h"

#include "base/android/jni_android.h"
#include "base/android/jni_registrar.h"
#include "services/device/generic_sensor/platform_sensor_android.h"
#include "device/generic_sensor/platform_sensor_android.h"

namespace device {
namespace android {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,23 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef SERVICES_DEVICE_GENERIC_SENSOR_ANDROID_SENSORS_JNI_REGISTRAR_H_
#define SERVICES_DEVICE_GENERIC_SENSOR_ANDROID_SENSORS_JNI_REGISTRAR_H_
#ifndef DEVICE_GENERIC_SENSOR_ANDROID_SENSORS_JNI_REGISTRAR_H_
#define DEVICE_GENERIC_SENSOR_ANDROID_SENSORS_JNI_REGISTRAR_H_

#include <jni.h>

#include "device/generic_sensor/generic_sensor_export.h"

namespace device {
namespace android {

// Registers C++ methods in device/generic_sensor classes with JNI.
// See https://www.chromium.org/developers/design-documents/android-jni
//
// Must be called before classes in the Sensors module are used.
bool RegisterSensorsJni(JNIEnv* env);
bool DEVICE_GENERIC_SENSOR_EXPORT RegisterSensorsJni(JNIEnv* env);

} // namespace android
} // namespace device

#endif // SERVICES_DEVICE_GENERIC_SENSOR_ANDROID_SENSORS_JNI_REGISTRAR_H_
#endif // DEVICE_GENERIC_SENSOR_ANDROID_SENSORS_JNI_REGISTRAR_H_
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "services/device/generic_sensor/fake_platform_sensor.h"
#include "device/generic_sensor/fake_platform_sensor.h"

namespace device {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef SERVICES_DEVICE_GENERIC_SENSOR_FAKE_PLATFORM_SENSOR_H_
#define SERVICES_DEVICE_GENERIC_SENSOR_FAKE_PLATFORM_SENSOR_H_
#ifndef DEVICE_GENERIC_SENSOR_FAKE_PLATFORM_SENSOR_H_
#define DEVICE_GENERIC_SENSOR_FAKE_PLATFORM_SENSOR_H_

#include "services/device/generic_sensor/platform_sensor.h"
#include "device/generic_sensor/platform_sensor.h"

namespace device {

Expand Down Expand Up @@ -43,4 +43,4 @@ class FakePlatformSensor : public PlatformSensor {

} // namespace device

#endif // SERVICES_DEVICE_GENERIC_SENSOR_FAKE_PLATFORM_SENSOR_H
#endif // DEVICE_GENERIC_SENSOR_FAKE_PLATFORM_SENSOR_H
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

#include "base/memory/singleton.h"

#include "services/device/generic_sensor/fake_platform_sensor.h"
#include "services/device/generic_sensor/fake_platform_sensor_provider.h"
#include "device/generic_sensor/fake_platform_sensor.h"
#include "device/generic_sensor/fake_platform_sensor_provider.h"

namespace device {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef SERVICES_DEVICE_GENERIC_SENSOR_FAKE_PLATFORM_SENSOR_PROVIDER_H_
#define SERVICES_DEVICE_GENERIC_SENSOR_FAKE_PLATFORM_SENSOR_PROVIDER_H_
#ifndef DEVICE_GENERIC_SENSOR_FAKE_PLATFORM_SENSOR_PROVIDER_H_
#define DEVICE_GENERIC_SENSOR_FAKE_PLATFORM_SENSOR_PROVIDER_H_

#include "services/device/generic_sensor/platform_sensor_provider.h"
#include "device/generic_sensor/platform_sensor_provider.h"
#include "testing/gmock/include/gmock/gmock.h"

namespace device {
Expand All @@ -28,4 +28,4 @@ class FakePlatformSensorProvider : public PlatformSensorProvider {

} // namespace device

#endif // SERVICES_DEVICE_GENERIC_SENSOR_MOCK_PLATFORM_SENSOR_PROVIDER_H_
#endif // DEVICE_GENERIC_SENSOR_MOCK_PLATFORM_SENSOR_PROVIDER_H_
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef SERVICES_DEVICE_GENERIC_SENSOR_GENERIC_SENSOR_CONSTS_H_
#define SERVICES_DEVICE_GENERIC_SENSOR_GENERIC_SENSOR_CONSTS_H_
#ifndef DEVICE_GENERIC_SENSOR_GENERIC_SENSOR_CONSTS_H_
#define DEVICE_GENERIC_SENSOR_GENERIC_SENSOR_CONSTS_H_

#define _USE_MATH_DEFINES
#include <math.h>
Expand Down Expand Up @@ -36,4 +36,4 @@ constexpr int kDefaultMagnetometerFrequencyHz = 10;

} // namespace device

#endif // SERVICES_DEVICE_GENERIC_SENSOR_GENERIC_SENSOR_CONSTS_H_
#endif // DEVICE_GENERIC_SENSOR_GENERIC_SENSOR_CONSTS_H_
29 changes: 29 additions & 0 deletions device/generic_sensor/generic_sensor_export.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef DEVICE_GENERIC_SENSOR_GENERIC_SENSOR_EXPORT_H_
#define DEVICE_GENERIC_SENSOR_GENERIC_SENSOR_EXPORT_H_

#if defined(COMPONENT_BUILD)
#if defined(WIN32)

#if defined(DEVICE_GENERIC_SENSOR_IMPLEMENTATION)
#define DEVICE_GENERIC_SENSOR_EXPORT __declspec(dllexport)
#else
#define DEVICE_GENERIC_SENSOR_EXPORT __declspec(dllimport)
#endif // defined(DEVICE_GENERIC_SENSOR_IMPLEMENTATION)

#else // defined(WIN32)
#if defined(DEVICE_GENERIC_SENSOR_IMPLEMENTATION)
#define DEVICE_GENERIC_SENSOR_EXPORT __attribute__((visibility("default")))
#else
#define DEVICE_GENERIC_SENSOR_EXPORT
#endif
#endif

#else // defined(COMPONENT_BUILD)
#define DEVICE_GENERIC_SENSOR_EXPORT
#endif

#endif // DEVICE_GENERIC_SENSOR_GENERIC_SENSOR_EXPORT_H_
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "services/device/generic_sensor/linux/sensor_data_linux.h"
#include "base/sys_info.h"
#include "base/version.h"
#include "services/device/generic_sensor/generic_sensor_consts.h"
#include "services/device/public/cpp/generic_sensor/sensor_reading.h"
#include "device/generic_sensor/generic_sensor_consts.h"
#include "device/generic_sensor/linux/sensor_data_linux.h"
#include "device/generic_sensor/public/cpp/sensor_reading.h"

namespace device {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef SERVICES_DEVICE_GENERIC_SENSOR_LINUX_SENSOR_DATA_LINUX_H_
#define SERVICES_DEVICE_GENERIC_SENSOR_LINUX_SENSOR_DATA_LINUX_H_
#ifndef DEVICE_GENERIC_SENSOR_LINUX_SENSOR_DATA_LINUX_H_
#define DEVICE_GENERIC_SENSOR_LINUX_SENSOR_DATA_LINUX_H_

#include "services/device/public/interfaces/sensor.mojom.h"
#include "device/generic_sensor/generic_sensor_export.h"
#include "device/generic_sensor/public/interfaces/sensor.mojom.h"

namespace device {

Expand All @@ -17,7 +18,7 @@ struct SensorReading;
// SensorDeviceManager receives a udev device, it uses this structure to
// identify what type of sensor that is and creates a SensorInfoLinux structure
// that holds all the necessary information to create a PlatformSensorLinux.
struct SensorPathsLinux {
struct DEVICE_GENERIC_SENSOR_EXPORT SensorPathsLinux {
using ReaderFunctor = base::Callback<
void(double scaling, double offset, SensorReading& reading)>;

Expand All @@ -43,7 +44,8 @@ struct SensorPathsLinux {
};

// Initializes sensor data according to |type|.
bool InitSensorData(mojom::SensorType type, SensorPathsLinux* data);
bool DEVICE_GENERIC_SENSOR_EXPORT InitSensorData(mojom::SensorType type,
SensorPathsLinux* data);

// This structure represents an iio device, which info is taken
// from udev service. If a client requests a sensor from a provider,
Expand Down Expand Up @@ -77,4 +79,4 @@ struct SensorInfoLinux {

} // namespace device

#endif // SERVICES_DEVICE_GENERIC_SENSOR_LINUX_SENSOR_DATA_LINUX_H_
#endif // DEVICE_GENERIC_SENSOR_LINUX_SENSOR_DATA_LINUX_H_
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "services/device/generic_sensor/linux/sensor_device_manager.h"
#include "device/generic_sensor/linux/sensor_device_manager.h"

#include "base/strings/string_number_conversions.h"
#include "base/threading/thread_restrictions.h"
#include "base/threading/thread_task_runner_handle.h"
#include "services/device/generic_sensor/linux/sensor_data_linux.h"
#include "device/generic_sensor/linux/sensor_data_linux.h"

namespace device {

Expand Down
Loading

0 comments on commit b6fa2c5

Please sign in to comment.