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

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

Issue 458253002: [DevTools] Removed ScriptState from createScriptCallStackForConsole (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 4 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 /* 1 /*
2 * Copyright (C) 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 Google Inc. All rights reserved. 3 * Copyright (C) 2010 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 { 57 {
58 RefPtr<TypeBuilder::Profiler::CPUProfile> profile = TypeBuilder::Profiler::C PUProfile::create() 58 RefPtr<TypeBuilder::Profiler::CPUProfile> profile = TypeBuilder::Profiler::C PUProfile::create()
59 .setHead(scriptProfile.buildInspectorObjectForHead()) 59 .setHead(scriptProfile.buildInspectorObjectForHead())
60 .setStartTime(scriptProfile.startTime()) 60 .setStartTime(scriptProfile.startTime())
61 .setEndTime(scriptProfile.endTime()); 61 .setEndTime(scriptProfile.endTime());
62 profile->setSamples(scriptProfile.buildInspectorObjectForSamples()); 62 profile->setSamples(scriptProfile.buildInspectorObjectForSamples());
63 profile->setTimestamps(scriptProfile.buildInspectorObjectForTimestamps()); 63 profile->setTimestamps(scriptProfile.buildInspectorObjectForTimestamps());
64 return profile.release(); 64 return profile.release();
65 } 65 }
66 66
67 static PassRefPtr<TypeBuilder::Debugger::Location> currentDebugLocation(ScriptSt ate* scriptState) 67 static PassRefPtr<TypeBuilder::Debugger::Location> currentDebugLocation()
68 { 68 {
69 RefPtrWillBeRawPtr<ScriptCallStack> callStack(createScriptCallStackForConsol e(scriptState, 1)); 69 RefPtrWillBeRawPtr<ScriptCallStack> callStack(createScriptCallStackForConsol e(1));
vsevik 2014/08/11 15:52:03 You could simply call createScriptCallStack(1) her
kozyatinskiy1 2014/08/11 16:05:34 Done.
70 const ScriptCallFrame& lastCaller = callStack->at(0); 70 const ScriptCallFrame& lastCaller = callStack->at(0);
71 RefPtr<TypeBuilder::Debugger::Location> location = TypeBuilder::Debugger::Lo cation::create() 71 RefPtr<TypeBuilder::Debugger::Location> location = TypeBuilder::Debugger::Lo cation::create()
72 .setScriptId(lastCaller.scriptId()) 72 .setScriptId(lastCaller.scriptId())
73 .setLineNumber(lastCaller.lineNumber()); 73 .setLineNumber(lastCaller.lineNumber());
74 location->setColumnNumber(lastCaller.columnNumber()); 74 location->setColumnNumber(lastCaller.columnNumber());
75 return location.release(); 75 return location.release();
76 } 76 }
77 77
78 class InspectorProfilerAgent::ProfileDescriptor { 78 class InspectorProfilerAgent::ProfileDescriptor {
79 public: 79 public:
(...skipping 17 matching lines...) Expand all
97 , m_profileNameIdleTimeMap(ScriptProfiler::currentProfileNameIdleTimeMap()) 97 , m_profileNameIdleTimeMap(ScriptProfiler::currentProfileNameIdleTimeMap())
98 , m_idleStartTime(0.0) 98 , m_idleStartTime(0.0)
99 , m_overlay(overlay) 99 , m_overlay(overlay)
100 { 100 {
101 } 101 }
102 102
103 InspectorProfilerAgent::~InspectorProfilerAgent() 103 InspectorProfilerAgent::~InspectorProfilerAgent()
104 { 104 {
105 } 105 }
106 106
107 void InspectorProfilerAgent::consoleProfile(ExecutionContext* context, const Str ing& title, ScriptState* scriptState) 107 void InspectorProfilerAgent::consoleProfile(ExecutionContext* context, const Str ing& title)
108 { 108 {
109 UseCounter::count(context, UseCounter::DevToolsConsoleProfile); 109 UseCounter::count(context, UseCounter::DevToolsConsoleProfile);
110 ASSERT(m_frontend && enabled()); 110 ASSERT(m_frontend && enabled());
111 String id = nextProfileId(); 111 String id = nextProfileId();
112 m_startedProfiles.append(ProfileDescriptor(id, title)); 112 m_startedProfiles.append(ProfileDescriptor(id, title));
113 ScriptProfiler::start(id); 113 ScriptProfiler::start(id);
114 m_frontend->consoleProfileStarted(id, currentDebugLocation(scriptState), tit le.isNull() ? 0 : &title); 114 m_frontend->consoleProfileStarted(id, currentDebugLocation(), title.isNull() ? 0 : &title);
115 } 115 }
116 116
117 void InspectorProfilerAgent::consoleProfileEnd(const String& title, ScriptState* scriptState) 117 void InspectorProfilerAgent::consoleProfileEnd(const String& title)
118 { 118 {
119 ASSERT(m_frontend && enabled()); 119 ASSERT(m_frontend && enabled());
120 String id; 120 String id;
121 String resolvedTitle; 121 String resolvedTitle;
122 // Take last started profile if no title was passed. 122 // Take last started profile if no title was passed.
123 if (title.isNull()) { 123 if (title.isNull()) {
124 if (m_startedProfiles.isEmpty()) 124 if (m_startedProfiles.isEmpty())
125 return; 125 return;
126 id = m_startedProfiles.last().m_id; 126 id = m_startedProfiles.last().m_id;
127 resolvedTitle = m_startedProfiles.last().m_title; 127 resolvedTitle = m_startedProfiles.last().m_title;
128 m_startedProfiles.removeLast(); 128 m_startedProfiles.removeLast();
129 } else { 129 } else {
130 for (size_t i = 0; i < m_startedProfiles.size(); i++) { 130 for (size_t i = 0; i < m_startedProfiles.size(); i++) {
131 if (m_startedProfiles[i].m_title == title) { 131 if (m_startedProfiles[i].m_title == title) {
132 resolvedTitle = title; 132 resolvedTitle = title;
133 id = m_startedProfiles[i].m_id; 133 id = m_startedProfiles[i].m_id;
134 m_startedProfiles.remove(i); 134 m_startedProfiles.remove(i);
135 break; 135 break;
136 } 136 }
137 } 137 }
138 if (id.isEmpty()) 138 if (id.isEmpty())
139 return; 139 return;
140 } 140 }
141 RefPtrWillBeRawPtr<ScriptProfile> profile = ScriptProfiler::stop(id); 141 RefPtrWillBeRawPtr<ScriptProfile> profile = ScriptProfiler::stop(id);
142 if (!profile) 142 if (!profile)
143 return; 143 return;
144 RefPtr<TypeBuilder::Debugger::Location> location = currentDebugLocation(scri ptState); 144 RefPtr<TypeBuilder::Debugger::Location> location = currentDebugLocation();
145 m_frontend->consoleProfileFinished(id, location, createCPUProfile(*profile), resolvedTitle.isNull() ? 0 : &resolvedTitle); 145 m_frontend->consoleProfileFinished(id, location, createCPUProfile(*profile), resolvedTitle.isNull() ? 0 : &resolvedTitle);
146 } 146 }
147 147
148 void InspectorProfilerAgent::enable(ErrorString*) 148 void InspectorProfilerAgent::enable(ErrorString*)
149 { 149 {
150 m_state->setBoolean(ProfilerAgentState::profilerEnabled, true); 150 m_state->setBoolean(ProfilerAgentState::profilerEnabled, true);
151 doEnable(); 151 doEnable();
152 } 152 }
153 153
154 void InspectorProfilerAgent::doEnable() 154 void InspectorProfilerAgent::doEnable()
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 } 298 }
299 299
300 void InspectorProfilerAgent::trace(Visitor* visitor) 300 void InspectorProfilerAgent::trace(Visitor* visitor)
301 { 301 {
302 visitor->trace(m_injectedScriptManager); 302 visitor->trace(m_injectedScriptManager);
303 InspectorBaseAgent::trace(visitor); 303 InspectorBaseAgent::trace(visitor);
304 } 304 }
305 305
306 } // namespace blink 306 } // namespace blink
307 307
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698