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

Side by Side Diff: Source/core/inspector/InspectorBaseAgent.cpp

Issue 17030009: Inspector: wrapped inspector agent instances into factory-like wrappers (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Made InspectorBaseAgent RefCounted Created 7 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 | Annotate | Revision Log
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 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 19 matching lines...) Expand all
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "core/inspector/InspectorBaseAgent.h" 32 #include "core/inspector/InspectorBaseAgent.h"
33 33
34 #include "core/dom/WebCoreMemoryInstrumentation.h" 34 #include "core/dom/WebCoreMemoryInstrumentation.h"
35 #include "core/inspector/InspectorState.h" 35 #include "core/inspector/InspectorState.h"
36 #include "wtf/MemoryInstrumentationVector.h" 36 #include "wtf/MemoryInstrumentationVector.h"
37 37
38 namespace WebCore { 38 namespace WebCore {
39 39
40 InspectorBaseAgentInterface::InspectorBaseAgentInterface(const String& name, Ins trumentingAgents* instrumentingAgents, InspectorCompositeState* inspectorState) 40 InspectorBaseAgent::InspectorBaseAgent(InstrumentingAgents* instrumentingAgents, InspectorState* state)
41 : m_instrumentingAgents(instrumentingAgents) 41 : m_instrumentingAgents(instrumentingAgents)
42 , m_state(inspectorState->createAgentState(name)) 42 , m_state(state)
43 , m_name(name)
44 { 43 {
45 } 44 }
46 45
47 InspectorBaseAgentInterface::~InspectorBaseAgentInterface() 46 InspectorBaseAgent::~InspectorBaseAgent()
48 { 47 {
49 } 48 }
50 49
51 void InspectorBaseAgentInterface::reportMemoryUsage(MemoryObjectInfo* memoryObje ctInfo) const 50 void InspectorBaseAgent::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) c onst
52 { 51 {
53 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Inspector); 52 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Inspector);
54 info.addMember(m_name, "name");
55 info.addWeakPointer(m_instrumentingAgents); 53 info.addWeakPointer(m_instrumentingAgents);
56 info.addWeakPointer(m_state); 54 info.addWeakPointer(m_state);
57 } 55 }
58 56
59 void InspectorAgentRegistry::append(PassOwnPtr<InspectorBaseAgentInterface> agen t) 57 InspectorBaseControllerInterface::InspectorBaseControllerInterface(const String& name, InstrumentingAgents* instrumentingAgents, InspectorCompositeState* compos iteState)
58 : m_instrumentingAgents(instrumentingAgents)
59 , m_state(compositeState->createAgentState(name))
60 , m_frontend(0)
60 { 61 {
61 m_agents.append(agent); 62 }
63
64 InspectorBaseControllerInterface::~InspectorBaseControllerInterface()
65 {
66 }
67
68 void InspectorBaseControllerInterface::setAgent(PassRefPtr<InspectorBaseAgent> a gent)
69 {
70 ASSERT(!m_agent);
71 ASSERT(!m_frontend);
72 m_agent = agent;
73 }
74
75 void InspectorBaseControllerInterface::setFrontend(InspectorFrontend* frontend)
76 {
77 m_frontend = frontend;
78 m_agent->setFrontend(m_frontend);
79 }
80
81 void InspectorBaseControllerInterface::clearFrontend()
82 {
83 m_agent->clearFrontend();
84 m_frontend = 0;
85 }
86
87 void InspectorBaseControllerInterface::restore()
88 {
89 m_agent->restore();
90 }
91
92 void InspectorBaseControllerInterface::discardAgent()
93 {
94 m_agent->discardAgent();
95 }
96
97 void InspectorBaseControllerInterface::reportMemoryUsage(MemoryObjectInfo* memor yObjectInfo) const
98 {
99 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Inspector);
100 info.addMember(m_agent.get(), "agent");
101 }
102
103
104 void InspectorAgentRegistry::append(PassOwnPtr<InspectorBaseControllerInterface> agent)
105 {
106 m_controllers.append(agent);
62 } 107 }
63 108
64 void InspectorAgentRegistry::setFrontend(InspectorFrontend* frontend) 109 void InspectorAgentRegistry::setFrontend(InspectorFrontend* frontend)
65 { 110 {
66 for (size_t i = 0; i < m_agents.size(); i++) 111 for (size_t i = 0; i < m_controllers.size(); i++)
67 m_agents[i]->setFrontend(frontend); 112 m_controllers[i]->setFrontend(frontend);
68 } 113 }
69 114
70 void InspectorAgentRegistry::clearFrontend() 115 void InspectorAgentRegistry::clearFrontend()
71 { 116 {
72 for (size_t i = 0; i < m_agents.size(); i++) 117 for (size_t i = 0; i < m_controllers.size(); i++)
73 m_agents[i]->clearFrontend(); 118 m_controllers[i]->clearFrontend();
74 } 119 }
75 120
76 void InspectorAgentRegistry::restore() 121 void InspectorAgentRegistry::restore()
77 { 122 {
78 for (size_t i = 0; i < m_agents.size(); i++) 123 for (size_t i = 0; i < m_controllers.size(); i++)
79 m_agents[i]->restore(); 124 m_controllers[i]->restore();
80 } 125 }
81 126
82 void InspectorAgentRegistry::registerInDispatcher(InspectorBackendDispatcher* di spatcher) 127 void InspectorAgentRegistry::registerInDispatcher(InspectorBackendDispatcher* di spatcher)
83 { 128 {
84 for (size_t i = 0; i < m_agents.size(); i++) 129 for (size_t i = 0; i < m_controllers.size(); i++)
85 m_agents[i]->registerInDispatcher(dispatcher); 130 m_controllers[i]->registerInDispatcher(dispatcher);
86 } 131 }
87 132
88 void InspectorAgentRegistry::discardAgents() 133 void InspectorAgentRegistry::discardAgents()
89 { 134 {
90 for (size_t i = 0; i < m_agents.size(); i++) 135 for (size_t i = 0; i < m_controllers.size(); i++)
91 m_agents[i]->discardAgent(); 136 m_controllers[i]->discardAgent();
92 } 137 }
93 138
94 void InspectorAgentRegistry::reportMemoryUsage(MemoryObjectInfo* memoryObjectInf o) const 139 void InspectorAgentRegistry::reportMemoryUsage(MemoryObjectInfo* memoryObjectInf o) const
95 { 140 {
96 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Inspector); 141 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Inspector);
97 info.addMember(&m_agents, "agents"); 142 info.addMember(&m_controllers, "agent_controllers");
98 } 143 }
99 144
100 } // namespace WebCore 145 } // namespace WebCore
101 146
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698