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

Side by Side Diff: content/renderer/device_sensors/device_light_event_pump.h

Issue 1164563003: Extract device_sensors to /device via Mojofication (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/renderer/DEPS ('k') | content/renderer/device_sensors/device_light_event_pump.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_LIGHT_EVENT_PUMP_H_ 5 #ifndef CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_LIGHT_EVENT_PUMP_H_
6 #define CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_LIGHT_EVENT_PUMP_H_ 6 #define CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_LIGHT_EVENT_PUMP_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "content/common/device_sensors/device_light_data.h" 9 #include "components/shared_memory_seqlock/shared_memory_seqlock_reader.h"
10 #include "content/renderer/device_sensors/device_sensor_event_pump.h" 10 #include "content/renderer/device_sensors/device_sensor_event_pump.h"
11 #include "content/renderer/shared_memory_seqlock_reader.h" 11 #include "device/device_sensors/device_light_data.h"
12 #include "device/device_sensors/device_sensors.mojom.h"
12 13
13 namespace blink { 14 namespace blink {
14 class WebDeviceLightListener; 15 class WebDeviceLightListener;
15 } 16 }
16 17
17 namespace content { 18 namespace content {
18 19
19 typedef SharedMemorySeqLockReader<DeviceLightData> 20 typedef shared_memory_seqlock::SharedMemorySeqLockReader<
20 DeviceLightSharedMemoryReader; 21 device::DeviceLightData> DeviceLightSharedMemoryReader;
21 22
22 class CONTENT_EXPORT DeviceLightEventPump 23 class CONTENT_EXPORT DeviceLightEventPump : public DeviceSensorEventPump {
23 : public DeviceSensorEventPump<blink::WebDeviceLightListener> {
24 public: 24 public:
25 explicit DeviceLightEventPump(RenderThread* thread); 25 explicit DeviceLightEventPump(blink::WebDeviceLightListener* listener);
26 ~DeviceLightEventPump() override; 26 ~DeviceLightEventPump() override;
27 27
28 // Sets the listener to receive updates for device light data at 28 // Sets the listener to receive updates for device light data at
29 // regular intervals. Returns true if the registration was successful. 29 // regular intervals. Returns true if the registration was successful.
30 bool SetListener(blink::WebDeviceLightListener* listener); 30 bool SetListener(blink::WebDeviceLightListener* listener);
31 31
32 // PlatformEventObserver implementation.
33 bool OnControlMessageReceived(const IPC::Message& message) override;
34 void SendFakeDataForTesting(void* data) override; 32 void SendFakeDataForTesting(void* data) override;
35 33
36 protected: 34 protected:
37 // Methods overriden from base class DeviceSensorEventPump 35 // Methods overriden from base class DeviceSensorEventPump
38 void FireEvent() override; 36 void FireEvent() override;
39 bool InitializeReader(base::SharedMemoryHandle handle) override; 37 bool InitializeReader(base::SharedMemoryHandle handle) override;
40 38
41 // PlatformEventObserver implementation.
42 void SendStartMessage() override;
43 void SendStopMessage() override;
44
45 private: 39 private:
46 bool ShouldFireEvent(double data) const; 40 bool ShouldFireEvent(double data) const;
47 41
48 scoped_ptr<DeviceLightSharedMemoryReader> reader_; 42 scoped_ptr<DeviceLightSharedMemoryReader> reader_;
49 double last_seen_data_; 43 double last_seen_data_;
44 blink::WebDeviceLightListener* listener_;
45 device::DeviceSensorsLightPtr service_;
50 46
51 DISALLOW_COPY_AND_ASSIGN(DeviceLightEventPump); 47 DISALLOW_COPY_AND_ASSIGN(DeviceLightEventPump);
52 }; 48 };
53 49
54 } // namespace content 50 } // namespace content
55 51
56 #endif // CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_LIGHT_EVENT_PUMP_H_ 52 #endif // CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_LIGHT_EVENT_PUMP_H_
OLDNEW
« no previous file with comments | « content/renderer/DEPS ('k') | content/renderer/device_sensors/device_light_event_pump.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698