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

Side by Side Diff: Source/modules/devicelight/DeviceLightDispatcher.h

Issue 143823004: Implement DeviceLight (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: DeviceLight API working fine (make the flag back to status=experimental) Created 6 years, 9 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2014 Intel Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY 13 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #ifndef SpeechInputResultList_h 26 #ifndef DeviceLightDispatcher_h
27 #define SpeechInputResultList_h 27 #define DeviceLightDispatcher_h
28 28
29 #if ENABLE(INPUT_SPEECH) 29 // TODO(riju) make DeviceSensorEventDispatcher.h common to all Device Apis
30 30 // by extracting it out of device_orientation
31 #include "bindings/v8/ScriptWrappable.h" 31 #include "modules/device_orientation/DeviceSensorEventDispatcher.h"
abarth-chromium 2014/03/04 18:59:32 Yeah, we'll need to do that before landing this CL
riju_ 2014/03/05 15:47:27 Yes. I will do this in a separate CL to avoid conf
32 #include "core/speech/SpeechInputResult.h" 32 #include "public/platform/WebDeviceLightListener.h"
33 #include "heap/Handle.h" 33 #include "wtf/RefPtr.h"
34 #include "wtf/PassRefPtr.h"
35 #include "wtf/RefCounted.h"
36 34
37 namespace WebCore { 35 namespace WebCore {
38 36
39 class SpeechInputResultList : public RefCountedWillBeGarbageCollectedFinalized<S peechInputResultList>, public ScriptWrappable { 37 class DeviceLightController;
38
39 // This class listens to device light data and dispatches it to all
40 // listening controllers
41 class DeviceLightDispatcher : public DeviceSensorEventDispatcher, public blink:: WebDeviceLightListener {
40 public: 42 public:
41 static PassRefPtrWillBeRawPtr<SpeechInputResultList> create(const SpeechInpu tResultArray& results); 43 static DeviceLightDispatcher& instance();
42 44
43 // Methods from the IDL. 45 double latestDeviceLightData();
44 size_t length() { return m_results.size(); }
45 SpeechInputResult* item(unsigned index);
46 46
47 void trace(Visitor *); 47 // This method is called every time new device light data is available.
48 virtual void didChangeDeviceLight(const double&) OVERRIDE;
49 void addDeviceLightController(DeviceLightController*);
50 void removeDeviceLightController(DeviceLightController*);
48 51
49 private: 52 private:
50 explicit SpeechInputResultList(const SpeechInputResultArray& results); 53 DeviceLightDispatcher();
54 ~DeviceLightDispatcher();
51 55
52 SpeechInputResultArray m_results; 56 virtual void startListening() OVERRIDE;
57 virtual void stopListening() OVERRIDE;
58
59 double m_lastDeviceLightData;
53 }; 60 };
54 61
55 } // namespace WebCore 62 } // namespace WebCore
56 63
57 #endif // ENABLE(INPUT_SPEECH) 64 #endif // DeviceLightDispatcher_h
58
59 #endif // SpeechInputResultList_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698