Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_SENSOR_EVENT_PUMP_H_ | 5 #ifndef CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_SENSOR_EVENT_PUMP_H_ |
| 6 #define CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_SENSOR_EVENT_PUMP_H_ | 6 #define CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_SENSOR_EVENT_PUMP_H_ |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/shared_memory.h" | 11 #include "base/memory/shared_memory.h" |
| 12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 13 #include "base/timer/timer.h" | 13 #include "base/timer/timer.h" |
| 14 #include "content/public/common/service_manager_connection.h" | |
| 14 #include "content/public/renderer/platform_event_observer.h" | 15 #include "content/public/renderer/platform_event_observer.h" |
| 15 #include "content/renderer/render_thread_impl.h" | 16 #include "content/renderer/render_thread_impl.h" |
| 16 #include "mojo/public/cpp/system/platform_handle.h" | 17 #include "mojo/public/cpp/system/platform_handle.h" |
| 17 #include "services/service_manager/public/cpp/interface_provider.h" | 18 #include "services/device/public/interfaces/constants.mojom.h" |
| 19 #include "services/service_manager/public/cpp/connector.h" | |
| 18 | 20 |
| 19 namespace content { | 21 namespace content { |
| 20 | 22 |
| 21 template <typename Base, typename MojoInterface> | 23 template <typename Base, typename MojoInterface> |
| 22 class CONTENT_EXPORT DeviceSensorMojoClientMixin : public Base { | 24 class CONTENT_EXPORT DeviceSensorMojoClientMixin : public Base { |
| 23 public: | 25 public: |
| 24 template <typename... Args> | 26 template <typename... Args> |
| 25 explicit DeviceSensorMojoClientMixin(Args&&... args) | 27 explicit DeviceSensorMojoClientMixin(Args&&... args) |
| 26 : Base(std::forward<Args>(args)...) { | 28 : Base(std::forward<Args>(args)...) { |
| 27 mojo::InterfaceRequest<MojoInterface> request(&mojo_interface_); | |
|
blundell
2017/02/22 16:30:24
The problem is here. You're now not binding |mojo_
| |
| 28 | 29 |
| 29 // When running layout tests, those observers should not listen to the | 30 // When running layout tests, those observers should not listen to the |
| 30 // actual hardware changes. In order to make that happen, don't connect | 31 // actual hardware changes. In order to make that happen, don't connect |
| 31 // the other end of the mojo pipe to anything. | 32 // the other end of the mojo pipe to anything. |
| 32 // | 33 // |
| 33 // TODO(sammc): Remove this when JS layout test support for shared buffers | 34 // TODO(sammc): Remove this when JS layout test support for shared buffers |
| 34 // is ready and the layout tests are converted to use that for mocking. | 35 // is ready and the layout tests are converted to use that for mocking. |
| 35 if (RenderThreadImpl::current() && | 36 if (RenderThreadImpl::current() && |
| 36 !RenderThreadImpl::current()->layout_test_mode()) { | 37 !RenderThreadImpl::current()->layout_test_mode()) { |
| 37 RenderThread::Get()->GetRemoteInterfaces()->GetInterface( | 38 RenderThreadImpl::current() |
| 38 std::move(request)); | 39 ->GetServiceManagerConnection() |
| 40 ->GetConnector() | |
| 41 ->BindInterface(device::mojom::kServiceName, &mojo_interface_); | |
| 39 } | 42 } |
| 40 } | 43 } |
| 41 | 44 |
| 42 void SendStartMessage() override { | 45 void SendStartMessage() override { |
| 43 mojo_interface_->StartPolling( | 46 mojo_interface_->StartPolling( |
| 44 base::Bind(&DeviceSensorMojoClientMixin<Base, MojoInterface>::DidStart, | 47 base::Bind(&DeviceSensorMojoClientMixin<Base, MojoInterface>::DidStart, |
| 45 base::Unretained(this))); | 48 base::Unretained(this))); |
| 46 } | 49 } |
| 47 void SendStopMessage() override { mojo_interface_->StopPolling(); } | 50 void SendStopMessage() override { mojo_interface_->StopPolling(); } |
| 48 | 51 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 int pump_delay_microseconds_; | 144 int pump_delay_microseconds_; |
| 142 PumpState state_; | 145 PumpState state_; |
| 143 base::RepeatingTimer timer_; | 146 base::RepeatingTimer timer_; |
| 144 | 147 |
| 145 DISALLOW_COPY_AND_ASSIGN(DeviceSensorEventPump); | 148 DISALLOW_COPY_AND_ASSIGN(DeviceSensorEventPump); |
| 146 }; | 149 }; |
| 147 | 150 |
| 148 } // namespace content | 151 } // namespace content |
| 149 | 152 |
| 150 #endif // CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_SENSOR_EVENT_PUMP_H_ | 153 #endif // CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_SENSOR_EVENT_PUMP_H_ |
| OLD | NEW |