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

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/V8ProfilerAgentImpl.cpp

Issue 2012753003: DevTools: consolidate protocol generators for front-end, backend and type builder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/v8_inspector/V8ProfilerAgentImpl.h" 5 #include "platform/v8_inspector/V8ProfilerAgentImpl.h"
6 6
7 #include "platform/v8_inspector/Atomics.h" 7 #include "platform/v8_inspector/Atomics.h"
8 #include "platform/v8_inspector/V8DebuggerImpl.h" 8 #include "platform/v8_inspector/V8DebuggerImpl.h"
9 #include "platform/v8_inspector/V8InspectorSessionImpl.h" 9 #include "platform/v8_inspector/V8InspectorSessionImpl.h"
10 #include "platform/v8_inspector/V8StackTraceImpl.h" 10 #include "platform/v8_inspector/V8StackTraceImpl.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 114
115 class V8ProfilerAgentImpl::ProfileDescriptor { 115 class V8ProfilerAgentImpl::ProfileDescriptor {
116 public: 116 public:
117 ProfileDescriptor(const String16& id, const String16& title) 117 ProfileDescriptor(const String16& id, const String16& title)
118 : m_id(id) 118 : m_id(id)
119 , m_title(title) { } 119 , m_title(title) { }
120 String16 m_id; 120 String16 m_id;
121 String16 m_title; 121 String16 m_title;
122 }; 122 };
123 123
124 V8ProfilerAgentImpl::V8ProfilerAgentImpl(V8InspectorSessionImpl* session, protoc ol::Profiler::Frontend* frontend, protocol::DictionaryValue* state) 124 V8ProfilerAgentImpl::V8ProfilerAgentImpl(V8InspectorSessionImpl* session, protoc ol::FrontendChannel* frontendChannel, protocol::DictionaryValue* state)
125 : m_session(session) 125 : m_session(session)
126 , m_isolate(m_session->debugger()->isolate()) 126 , m_isolate(m_session->debugger()->isolate())
127 , m_state(state) 127 , m_state(state)
128 , m_frontend(frontend) 128 , m_frontend(frontendChannel)
129 , m_enabled(false) 129 , m_enabled(false)
130 , m_recordingCPUProfile(false) 130 , m_recordingCPUProfile(false)
131 { 131 {
132 } 132 }
133 133
134 V8ProfilerAgentImpl::~V8ProfilerAgentImpl() 134 V8ProfilerAgentImpl::~V8ProfilerAgentImpl()
135 { 135 {
136 } 136 }
137 137
138 void V8ProfilerAgentImpl::consoleProfile(const String16& title) 138 void V8ProfilerAgentImpl::consoleProfile(const String16& title)
139 { 139 {
140 if (!m_enabled) 140 if (!m_enabled)
141 return; 141 return;
142 DCHECK(m_frontend);
143 String16 id = nextProfileId(); 142 String16 id = nextProfileId();
144 m_startedProfiles.append(ProfileDescriptor(id, title)); 143 m_startedProfiles.append(ProfileDescriptor(id, title));
145 startProfiling(id); 144 startProfiling(id);
146 m_frontend->consoleProfileStarted(id, currentDebugLocation(m_session->debugg er()), title); 145 m_frontend.consoleProfileStarted(id, currentDebugLocation(m_session->debugge r()), title);
147 } 146 }
148 147
149 void V8ProfilerAgentImpl::consoleProfileEnd(const String16& title) 148 void V8ProfilerAgentImpl::consoleProfileEnd(const String16& title)
150 { 149 {
151 if (!m_enabled) 150 if (!m_enabled)
152 return; 151 return;
153 DCHECK(m_frontend);
154 String16 id; 152 String16 id;
155 String16 resolvedTitle; 153 String16 resolvedTitle;
156 // Take last started profile if no title was passed. 154 // Take last started profile if no title was passed.
157 if (title.isEmpty()) { 155 if (title.isEmpty()) {
158 if (m_startedProfiles.isEmpty()) 156 if (m_startedProfiles.isEmpty())
159 return; 157 return;
160 id = m_startedProfiles.last().m_id; 158 id = m_startedProfiles.last().m_id;
161 resolvedTitle = m_startedProfiles.last().m_title; 159 resolvedTitle = m_startedProfiles.last().m_title;
162 m_startedProfiles.removeLast(); 160 m_startedProfiles.removeLast();
163 } else { 161 } else {
164 for (size_t i = 0; i < m_startedProfiles.size(); i++) { 162 for (size_t i = 0; i < m_startedProfiles.size(); i++) {
165 if (m_startedProfiles[i].m_title == title) { 163 if (m_startedProfiles[i].m_title == title) {
166 resolvedTitle = title; 164 resolvedTitle = title;
167 id = m_startedProfiles[i].m_id; 165 id = m_startedProfiles[i].m_id;
168 m_startedProfiles.remove(i); 166 m_startedProfiles.remove(i);
169 break; 167 break;
170 } 168 }
171 } 169 }
172 if (id.isEmpty()) 170 if (id.isEmpty())
173 return; 171 return;
174 } 172 }
175 std::unique_ptr<protocol::Profiler::CPUProfile> profile = stopProfiling(id, true); 173 std::unique_ptr<protocol::Profiler::CPUProfile> profile = stopProfiling(id, true);
176 if (!profile) 174 if (!profile)
177 return; 175 return;
178 std::unique_ptr<protocol::Debugger::Location> location = currentDebugLocatio n(m_session->debugger()); 176 std::unique_ptr<protocol::Debugger::Location> location = currentDebugLocatio n(m_session->debugger());
179 m_frontend->consoleProfileFinished(id, std::move(location), std::move(profil e), resolvedTitle); 177 m_frontend.consoleProfileFinished(id, std::move(location), std::move(profile ), resolvedTitle);
180 } 178 }
181 179
182 void V8ProfilerAgentImpl::enable(ErrorString*) 180 void V8ProfilerAgentImpl::enable(ErrorString*)
183 { 181 {
184 if (m_enabled) 182 if (m_enabled)
185 return; 183 return;
186 m_enabled = true; 184 m_enabled = true;
187 m_state->setBoolean(ProfilerAgentState::profilerEnabled, true); 185 m_state->setBoolean(ProfilerAgentState::profilerEnabled, true);
188 m_session->changeInstrumentationCounter(+1); 186 m_session->changeInstrumentationCounter(+1);
189 } 187 }
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 profile->Delete(); 283 profile->Delete();
286 return result; 284 return result;
287 } 285 }
288 286
289 bool V8ProfilerAgentImpl::isRecording() const 287 bool V8ProfilerAgentImpl::isRecording() const
290 { 288 {
291 return m_recordingCPUProfile || !m_startedProfiles.isEmpty(); 289 return m_recordingCPUProfile || !m_startedProfiles.isEmpty();
292 } 290 }
293 291
294 } // namespace blink 292 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698