OLD | NEW |
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 | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 15 matching lines...) Expand all Loading... |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef InspectorState_h | 31 #ifndef InspectorState_h |
32 #define InspectorState_h | 32 #define InspectorState_h |
33 | 33 |
34 | 34 |
35 #include "platform/JSONValues.h" | 35 #include "platform/JSONValues.h" |
| 36 #include "platform/heap/Handle.h" |
36 #include "wtf/HashMap.h" | 37 #include "wtf/HashMap.h" |
37 #include "wtf/text/WTFString.h" | 38 #include "wtf/text/WTFString.h" |
38 | 39 |
39 namespace WebCore { | 40 namespace WebCore { |
40 | 41 |
41 class InspectorStateClient; | 42 class InspectorStateClient; |
42 | 43 |
43 class InspectorStateUpdateListener { | 44 class InspectorStateUpdateListener : public WillBeGarbageCollectedMixin { |
44 public: | 45 public: |
45 virtual ~InspectorStateUpdateListener() { } | 46 virtual ~InspectorStateUpdateListener() { } |
46 virtual void inspectorStateUpdated() = 0; | 47 virtual void inspectorStateUpdated() = 0; |
47 }; | 48 }; |
48 | 49 |
49 class InspectorState FINAL { | 50 class InspectorState FINAL : public NoBaseWillBeGarbageCollectedFinalized<Inspec
torState> { |
50 WTF_MAKE_FAST_ALLOCATED; | 51 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; |
51 public: | 52 public: |
52 InspectorState(InspectorStateUpdateListener*, PassRefPtr<JSONObject>); | 53 InspectorState(InspectorStateUpdateListener*, PassRefPtr<JSONObject>); |
53 | 54 |
54 void loadFromCookie(const String& inspectorStateCookie); | 55 void loadFromCookie(const String& inspectorStateCookie); |
55 | 56 |
56 void mute(); | 57 void mute(); |
57 void unmute(); | 58 void unmute(); |
58 | 59 |
59 bool getBoolean(const String& propertyName); | 60 bool getBoolean(const String& propertyName); |
60 String getString(const String& propertyName); | 61 String getString(const String& propertyName); |
61 long getLong(const String& propertyName); | 62 long getLong(const String& propertyName); |
62 long getLong(const String& propertyName, long defaultValue); | 63 long getLong(const String& propertyName, long defaultValue); |
63 double getDouble(const String& propertyName); | 64 double getDouble(const String& propertyName); |
64 double getDouble(const String& propertyName, double defaultValue); | 65 double getDouble(const String& propertyName, double defaultValue); |
65 PassRefPtr<JSONObject> getObject(const String& propertyName); | 66 PassRefPtr<JSONObject> getObject(const String& propertyName); |
66 | 67 |
67 void setBoolean(const String& propertyName, bool value) { setValue(propertyN
ame, JSONBasicValue::create(value)); } | 68 void setBoolean(const String& propertyName, bool value) { setValue(propertyN
ame, JSONBasicValue::create(value)); } |
68 void setString(const String& propertyName, const String& value) { setValue(p
ropertyName, JSONString::create(value)); } | 69 void setString(const String& propertyName, const String& value) { setValue(p
ropertyName, JSONString::create(value)); } |
69 void setLong(const String& propertyName, long value) { setValue(propertyName
, JSONBasicValue::create((double)value)); } | 70 void setLong(const String& propertyName, long value) { setValue(propertyName
, JSONBasicValue::create((double)value)); } |
70 void setDouble(const String& propertyName, double value) { setValue(property
Name, JSONBasicValue::create(value)); } | 71 void setDouble(const String& propertyName, double value) { setValue(property
Name, JSONBasicValue::create(value)); } |
71 void setObject(const String& propertyName, PassRefPtr<JSONObject> value) { s
etValue(propertyName, value); } | 72 void setObject(const String& propertyName, PassRefPtr<JSONObject> value) { s
etValue(propertyName, value); } |
72 | 73 |
73 void remove(const String&); | 74 void remove(const String&); |
| 75 |
| 76 void trace(Visitor*); |
| 77 |
74 private: | 78 private: |
75 void updateCookie(); | 79 void updateCookie(); |
76 void setValue(const String& propertyName, PassRefPtr<JSONValue>); | 80 void setValue(const String& propertyName, PassRefPtr<JSONValue>); |
77 | 81 |
78 // Gets called from InspectorCompositeState::loadFromCookie(). | 82 // Gets called from InspectorCompositeState::loadFromCookie(). |
79 void setFromCookie(PassRefPtr<JSONObject>); | 83 void setFromCookie(PassRefPtr<JSONObject>); |
80 | 84 |
81 friend class InspectorCompositeState; | 85 friend class InspectorCompositeState; |
82 | 86 |
83 InspectorStateUpdateListener* m_listener; | 87 RawPtrWillBeMember<InspectorStateUpdateListener> m_listener; |
84 RefPtr<JSONObject> m_properties; | 88 RefPtr<JSONObject> m_properties; |
85 }; | 89 }; |
86 | 90 |
87 class InspectorCompositeState FINAL : public InspectorStateUpdateListener { | 91 class InspectorCompositeState FINAL : public NoBaseWillBeGarbageCollectedFinaliz
ed<InspectorCompositeState>, public InspectorStateUpdateListener { |
| 92 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(InspectorCompositeState); |
88 public: | 93 public: |
89 InspectorCompositeState(InspectorStateClient* inspectorClient) | 94 InspectorCompositeState(InspectorStateClient* inspectorClient) |
90 : m_client(inspectorClient) | 95 : m_client(inspectorClient) |
91 , m_stateObject(JSONObject::create()) | 96 , m_stateObject(JSONObject::create()) |
92 , m_isMuted(false) | 97 , m_isMuted(false) |
93 { | 98 { |
94 } | 99 } |
95 virtual ~InspectorCompositeState() { } | 100 virtual ~InspectorCompositeState() { } |
| 101 void trace(Visitor*); |
96 | 102 |
97 void mute(); | 103 void mute(); |
98 void unmute(); | 104 void unmute(); |
99 | 105 |
100 InspectorState* createAgentState(const String&); | 106 InspectorState* createAgentState(const String&); |
101 void loadFromCookie(const String&); | 107 void loadFromCookie(const String&); |
102 | 108 |
103 private: | 109 private: |
104 typedef HashMap<String, OwnPtr<InspectorState> > InspectorStateMap; | 110 typedef WillBeHeapHashMap<String, OwnPtrWillBeMember<InspectorState> > Inspe
ctorStateMap; |
105 | 111 |
106 // From InspectorStateUpdateListener. | 112 // From InspectorStateUpdateListener. |
107 virtual void inspectorStateUpdated() OVERRIDE; | 113 virtual void inspectorStateUpdated() OVERRIDE; |
108 | 114 |
109 InspectorStateClient* m_client; | 115 InspectorStateClient* m_client; |
110 RefPtr<JSONObject> m_stateObject; | 116 RefPtr<JSONObject> m_stateObject; |
111 bool m_isMuted; | 117 bool m_isMuted; |
112 InspectorStateMap m_inspectorStateMap; | 118 InspectorStateMap m_inspectorStateMap; |
113 }; | 119 }; |
114 | 120 |
115 } // namespace WebCore | 121 } // namespace WebCore |
116 | 122 |
117 #endif // !defined(InspectorState_h) | 123 #endif // !defined(InspectorState_h) |
OLD | NEW |