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 12 matching lines...) Expand all Loading... |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
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 #include "core/inspector/InspectorBaseAgent.h" | 31 #include "core/inspector/InspectorBaseAgent.h" |
32 | 32 |
33 #include "platform/JSONParser.h" | 33 #include "platform/inspector_protocol/Parser.h" |
34 #include "wtf/PassOwnPtr.h" | 34 #include "wtf/PassOwnPtr.h" |
35 | 35 |
36 namespace blink { | 36 namespace blink { |
37 | 37 |
38 InspectorAgent::InspectorAgent(const String& name) | 38 InspectorAgent::InspectorAgent(const String& name) |
39 : m_name(name) | 39 : m_name(name) |
40 { | 40 { |
41 } | 41 } |
42 | 42 |
43 InspectorAgent::~InspectorAgent() | 43 InspectorAgent::~InspectorAgent() |
44 { | 44 { |
45 } | 45 } |
46 | 46 |
47 DEFINE_TRACE(InspectorAgent) | 47 DEFINE_TRACE(InspectorAgent) |
48 { | 48 { |
49 visitor->trace(m_instrumentingAgents); | 49 visitor->trace(m_instrumentingAgents); |
50 } | 50 } |
51 | 51 |
52 void InspectorAgent::appended(InstrumentingAgents* instrumentingAgents) | 52 void InspectorAgent::appended(InstrumentingAgents* instrumentingAgents) |
53 { | 53 { |
54 m_instrumentingAgents = instrumentingAgents; | 54 m_instrumentingAgents = instrumentingAgents; |
55 init(); | 55 init(); |
56 } | 56 } |
57 | 57 |
58 void InspectorAgent::setState(PassRefPtr<JSONObject> state) | 58 void InspectorAgent::setState(PassRefPtr<protocol::DictionaryValue> state) |
59 { | 59 { |
60 m_state = state; | 60 m_state = state; |
61 } | 61 } |
62 | 62 |
63 InspectorAgentRegistry::InspectorAgentRegistry(InstrumentingAgents* instrumentin
gAgents) | 63 InspectorAgentRegistry::InspectorAgentRegistry(InstrumentingAgents* instrumentin
gAgents) |
64 : m_instrumentingAgents(instrumentingAgents) | 64 : m_instrumentingAgents(instrumentingAgents) |
65 , m_state(JSONObject::create()) | 65 , m_state(protocol::DictionaryValue::create()) |
66 { | 66 { |
67 } | 67 } |
68 | 68 |
69 void InspectorAgentRegistry::append(PassOwnPtrWillBeRawPtr<InspectorAgent> agent
) | 69 void InspectorAgentRegistry::append(PassOwnPtrWillBeRawPtr<InspectorAgent> agent
) |
70 { | 70 { |
71 ASSERT(m_state->find(agent->name()) == m_state->end()); | 71 ASSERT(m_state->find(agent->name()) == m_state->end()); |
72 RefPtr<JSONObject> agentState = JSONObject::create(); | 72 RefPtr<protocol::DictionaryValue> agentState = protocol::DictionaryValue::cr
eate(); |
73 m_state->setObject(agent->name(), agentState); | 73 m_state->setObject(agent->name(), agentState); |
74 agent->setState(agentState); | 74 agent->setState(agentState); |
75 agent->appended(m_instrumentingAgents); | 75 agent->appended(m_instrumentingAgents); |
76 m_agents.append(agent); | 76 m_agents.append(agent); |
77 } | 77 } |
78 | 78 |
79 void InspectorAgentRegistry::setFrontend(protocol::Frontend* frontend) | 79 void InspectorAgentRegistry::setFrontend(protocol::Frontend* frontend) |
80 { | 80 { |
81 for (size_t i = 0; i < m_agents.size(); i++) | 81 for (size_t i = 0; i < m_agents.size(); i++) |
82 m_agents[i]->setFrontend(frontend); | 82 m_agents[i]->setFrontend(frontend); |
83 } | 83 } |
84 | 84 |
85 void InspectorAgentRegistry::clearFrontend() | 85 void InspectorAgentRegistry::clearFrontend() |
86 { | 86 { |
87 for (size_t i = 0; i < m_agents.size(); i++) | 87 for (size_t i = 0; i < m_agents.size(); i++) |
88 m_agents[i]->clearFrontend(); | 88 m_agents[i]->clearFrontend(); |
89 } | 89 } |
90 | 90 |
91 void InspectorAgentRegistry::restore(const String& savedState) | 91 void InspectorAgentRegistry::restore(const String& savedState) |
92 { | 92 { |
93 RefPtr<JSONValue> state = parseJSON(savedState); | 93 RefPtr<protocol::Value> state = protocol::parseJSON(savedState); |
94 if (state) | 94 if (state) |
95 m_state = JSONObject::cast(state); | 95 m_state = protocol::DictionaryValue::cast(state); |
96 if (!m_state) | 96 if (!m_state) |
97 m_state = JSONObject::create(); | 97 m_state = protocol::DictionaryValue::create(); |
98 | 98 |
99 for (size_t i = 0; i < m_agents.size(); i++) { | 99 for (size_t i = 0; i < m_agents.size(); i++) { |
100 RefPtr<JSONObject> agentState = m_state->getObject(m_agents[i]->name()); | 100 RefPtr<protocol::DictionaryValue> agentState = m_state->getObject(m_agen
ts[i]->name()); |
101 if (!agentState) { | 101 if (!agentState) { |
102 agentState = JSONObject::create(); | 102 agentState = protocol::DictionaryValue::create(); |
103 m_state->setObject(m_agents[i]->name(), agentState); | 103 m_state->setObject(m_agents[i]->name(), agentState); |
104 } | 104 } |
105 m_agents[i]->setState(agentState); | 105 m_agents[i]->setState(agentState); |
106 } | 106 } |
107 | 107 |
108 for (size_t i = 0; i < m_agents.size(); i++) | 108 for (size_t i = 0; i < m_agents.size(); i++) |
109 m_agents[i]->restore(); | 109 m_agents[i]->restore(); |
110 } | 110 } |
111 | 111 |
112 String InspectorAgentRegistry::state() | 112 String InspectorAgentRegistry::state() |
(...skipping 28 matching lines...) Expand all Loading... |
141 } | 141 } |
142 | 142 |
143 void InspectorAgentRegistry::didCommitLoadForLocalFrame(LocalFrame* frame) | 143 void InspectorAgentRegistry::didCommitLoadForLocalFrame(LocalFrame* frame) |
144 { | 144 { |
145 for (size_t i = 0; i < m_agents.size(); i++) | 145 for (size_t i = 0; i < m_agents.size(); i++) |
146 m_agents[i]->didCommitLoadForLocalFrame(frame); | 146 m_agents[i]->didCommitLoadForLocalFrame(frame); |
147 } | 147 } |
148 | 148 |
149 } // namespace blink | 149 } // namespace blink |
150 | 150 |
OLD | NEW |