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

Side by Side Diff: Source/modules/gamepad/Gamepad.h

Issue 195993007: Factor out GamepadCommon base class from Gamepad and WebKitGamepad (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Tweak 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/modules/gamepad/Gamepad.cpp » ('j') | Source/modules/gamepad/GamepadList.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, Google Inc. All rights reserved. 2 * Copyright (C) 2011, Google 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 are met: 5 * modification, are permitted provided that the following conditions are met:
6 * 6 *
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. 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
(...skipping 11 matching lines...) Expand all
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
23 * DAMAGE. 23 * DAMAGE.
24 */ 24 */
25 25
26 #ifndef Gamepad_h 26 #ifndef Gamepad_h
27 #define Gamepad_h 27 #define Gamepad_h
28 28
29 #include "bindings/v8/ScriptWrappable.h" 29 #include "bindings/v8/ScriptWrappable.h"
30 #include "heap/Handle.h" 30 #include "heap/Handle.h"
31 #include "modules/gamepad/GamepadButton.h" 31 #include "modules/gamepad/GamepadButton.h"
32 #include "modules/gamepad/GamepadCommon.h"
32 #include "public/platform/WebGamepad.h" 33 #include "public/platform/WebGamepad.h"
33 #include "wtf/RefCounted.h" 34 #include "wtf/RefCounted.h"
34 #include "wtf/Vector.h"
35 #include "wtf/text/WTFString.h"
36 35
37 namespace WebCore { 36 namespace WebCore {
38 37
39 class Gamepad FINAL : public RefCountedWillBeGarbageCollectedFinalized<Gamepad>, public ScriptWrappable { 38 class Gamepad FINAL : public GamepadCommon, public RefCountedWillBeGarbageCollec tedFinalized<Gamepad>, public ScriptWrappable {
kouhei (in TOK) 2014/03/13 09:05:11 RefCountedWillBeGarbageCollectedFinalized must be
Nils Barth (inactive) 2014/03/13 09:15:14 Thanks, got it, done!
40 public: 39 public:
41 static PassRefPtrWillBeRawPtr<Gamepad> create() 40 static PassRefPtrWillBeRawPtr<Gamepad> create()
42 { 41 {
43 return adoptRefWillBeNoop(new Gamepad); 42 return adoptRefWillBeNoop(new Gamepad);
44 } 43 }
45 ~Gamepad(); 44 ~Gamepad() { }
46
47 typedef Vector<float> FloatVector;
48
49 const String& id() const { return m_id; }
50 void setId(const String& id) { m_id = id; }
51
52 unsigned index() const { return m_index; }
53 void setIndex(unsigned val) { m_index = val; }
54
55 bool connected() const { return m_connected; }
56 void setConnected(bool val) { m_connected = val; }
57
58 unsigned long long timestamp() const { return m_timestamp; }
59 void setTimestamp(unsigned long long val) { m_timestamp = val; }
60
61 const String& mapping() const { return m_mapping; }
62 void setMapping(const String& val) { m_mapping = val; }
63
64 const FloatVector& axes() const { return m_axes; }
65 void setAxes(unsigned count, const float* data);
66 45
67 const GamepadButtonVector& buttons() const { return m_buttons; } 46 const GamepadButtonVector& buttons() const { return m_buttons; }
68 void setButtons(unsigned count, const blink::WebGamepadButton* data); 47 void setButtons(unsigned count, const blink::WebGamepadButton* data);
69 48
70 void trace(Visitor*); 49 void trace(Visitor* visitor) { visitor->trace(m_buttons); }
kouhei (in TOK) 2014/03/13 09:05:11 write this in cpp file.
Nils Barth (inactive) 2014/03/13 09:15:14 ok; is there a rule about this? (When to inline?)
kouhei (in TOK) 2014/03/13 09:17:10 IIRC the oilpan rule for trace() was write in cpp
Nils Barth (inactive) 2014/03/13 09:19:52 Thanks for explaining!
71 50
72 private: 51 private:
73 Gamepad(); 52 Gamepad() { ScriptWrappable::init(this); }
74 String m_id;
75 unsigned m_index;
76 bool m_connected;
77 unsigned long long m_timestamp;
78 String m_mapping;
79 FloatVector m_axes;
80 GamepadButtonVector m_buttons; 53 GamepadButtonVector m_buttons;
81 }; 54 };
82 55
83 } // namespace WebCore 56 } // namespace WebCore
84 57
85 #endif // Gamepad_h 58 #endif // Gamepad_h
OLDNEW
« no previous file with comments | « no previous file | Source/modules/gamepad/Gamepad.cpp » ('j') | Source/modules/gamepad/GamepadList.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698