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

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

Issue 17030009: Inspector: wrapped inspector agent instances into factory-like wrappers (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Addressed comments 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) 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 namespace ProfilerAgentState { 58 namespace ProfilerAgentState {
59 static const char userInitiatedProfiling[] = "userInitiatedProfiling"; 59 static const char userInitiatedProfiling[] = "userInitiatedProfiling";
60 static const char profilerEnabled[] = "profilerEnabled"; 60 static const char profilerEnabled[] = "profilerEnabled";
61 static const char profileHeadersRequested[] = "profileHeadersRequested"; 61 static const char profileHeadersRequested[] = "profileHeadersRequested";
62 } 62 }
63 63
64 static const char* const userInitiatedProfileName = "org.webkit.profiles.user-in itiated"; 64 static const char* const userInitiatedProfileName = "org.webkit.profiles.user-in itiated";
65 static const char* const CPUProfileType = "CPU"; 65 static const char* const CPUProfileType = "CPU";
66 66
67 PassOwnPtr<InspectorProfilerAgent> InspectorProfilerAgent::create(InstrumentingA gents* instrumentingAgents, InspectorConsoleAgent* consoleAgent, InspectorCompos iteState* inspectorState, InjectedScriptManager* injectedScriptManager) 67 PassRefPtr<InspectorProfilerAgent> InspectorProfilerAgent::create(InstrumentingA gents* instrumentingAgents, InspectorState* inspectorState, PassRefPtr<Inspector ConsoleAgent> consoleAgent, InjectedScriptManager* injectedScriptManager)
68 { 68 {
69 return adoptPtr(new InspectorProfilerAgent(instrumentingAgents, consoleAgent , inspectorState, injectedScriptManager)); 69 return adoptRef(new InspectorProfilerAgent(instrumentingAgents, inspectorSta te, consoleAgent, injectedScriptManager));
70 } 70 }
71 71
72 InspectorProfilerAgent::InspectorProfilerAgent(InstrumentingAgents* instrumentin gAgents, InspectorConsoleAgent* consoleAgent, InspectorCompositeState* inspector State, InjectedScriptManager* injectedScriptManager) 72 InspectorProfilerAgent::InspectorProfilerAgent(InstrumentingAgents* instrumentin gAgents, InspectorState* inspectorState, PassRefPtr<InspectorConsoleAgent> conso leAgent, InjectedScriptManager* injectedScriptManager)
73 : InspectorBaseAgent<InspectorProfilerAgent>("Profiler", instrumentingAgents , inspectorState) 73 : InspectorBaseAgent(instrumentingAgents, inspectorState)
74 , m_consoleAgent(consoleAgent) 74 , m_consoleAgent(consoleAgent)
75 , m_injectedScriptManager(injectedScriptManager) 75 , m_injectedScriptManager(injectedScriptManager)
76 , m_frontend(0) 76 , m_frontend(0)
77 , m_recordingCPUProfile(false) 77 , m_recordingCPUProfile(false)
78 , m_currentUserInitiatedProfileNumber(-1) 78 , m_currentUserInitiatedProfileNumber(-1)
79 , m_nextUserInitiatedProfileNumber(1) 79 , m_nextUserInitiatedProfileNumber(1)
80 , m_profileNameIdleTimeMap(ScriptProfiler::currentProfileNameIdleTimeMap()) 80 , m_profileNameIdleTimeMap(ScriptProfiler::currentProfileNameIdleTimeMap())
81 , m_previousTaskEndTime(0.0) 81 , m_previousTaskEndTime(0.0)
82 { 82 {
83 } 83 }
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 269
270 void InspectorProfilerAgent::toggleRecordButton(bool isProfiling) 270 void InspectorProfilerAgent::toggleRecordButton(bool isProfiling)
271 { 271 {
272 if (m_frontend) 272 if (m_frontend)
273 m_frontend->setRecordingProfile(isProfiling); 273 m_frontend->setRecordingProfile(isProfiling);
274 } 274 }
275 275
276 void InspectorProfilerAgent::reportMemoryUsage(MemoryObjectInfo* memoryObjectInf o) const 276 void InspectorProfilerAgent::reportMemoryUsage(MemoryObjectInfo* memoryObjectInf o) const
277 { 277 {
278 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::InspectorPr ofilerAgent); 278 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::InspectorPr ofilerAgent);
279 InspectorBaseAgent<InspectorProfilerAgent>::reportMemoryUsage(memoryObjectIn fo); 279 InspectorBaseAgent::reportMemoryUsage(memoryObjectInfo);
280 info.addMember(m_consoleAgent, "consoleAgent"); 280 info.addMember(m_consoleAgent, "consoleAgent");
281 info.addMember(m_injectedScriptManager, "injectedScriptManager"); 281 info.addMember(m_injectedScriptManager, "injectedScriptManager");
282 info.addWeakPointer(m_frontend); 282 info.addWeakPointer(m_frontend);
283 info.addMember(m_profiles, "profiles"); 283 info.addMember(m_profiles, "profiles");
284 info.addMember(m_profileNameIdleTimeMap, "profileNameIdleTimeMap"); 284 info.addMember(m_profileNameIdleTimeMap, "profileNameIdleTimeMap");
285 } 285 }
286 286
287 void InspectorProfilerAgent::willProcessTask() 287 void InspectorProfilerAgent::willProcessTask()
288 { 288 {
289 if (!m_profileNameIdleTimeMap || !m_profileNameIdleTimeMap->size()) 289 if (!m_profileNameIdleTimeMap || !m_profileNameIdleTimeMap->size())
290 return; 290 return;
291 if (!m_previousTaskEndTime) 291 if (!m_previousTaskEndTime)
292 return; 292 return;
293 293
294 double idleTime = WTF::monotonicallyIncreasingTime() - m_previousTaskEndTime ; 294 double idleTime = WTF::monotonicallyIncreasingTime() - m_previousTaskEndTime ;
295 m_previousTaskEndTime = 0.0; 295 m_previousTaskEndTime = 0.0;
296 ProfileNameIdleTimeMap::iterator end = m_profileNameIdleTimeMap->end(); 296 ProfileNameIdleTimeMap::iterator end = m_profileNameIdleTimeMap->end();
297 for (ProfileNameIdleTimeMap::iterator it = m_profileNameIdleTimeMap->begin() ; it != end; ++it) 297 for (ProfileNameIdleTimeMap::iterator it = m_profileNameIdleTimeMap->begin() ; it != end; ++it)
298 it->value += idleTime; 298 it->value += idleTime;
299 } 299 }
300 300
301 void InspectorProfilerAgent::didProcessTask() 301 void InspectorProfilerAgent::didProcessTask()
302 { 302 {
303 if (!m_profileNameIdleTimeMap || !m_profileNameIdleTimeMap->size()) 303 if (!m_profileNameIdleTimeMap || !m_profileNameIdleTimeMap->size())
304 return; 304 return;
305 m_previousTaskEndTime = WTF::monotonicallyIncreasingTime(); 305 m_previousTaskEndTime = WTF::monotonicallyIncreasingTime();
306 } 306 }
307 307
308 InspectorProfilerFactory::InspectorProfilerFactory(InstrumentingAgents* instrume ntingAgents, InspectorCompositeState* compositeState, InspectorConsoleFactory* c onsoleFactory, InjectedScriptManager* injectedScriptManager)
309 : InspectorBaseFactory<InspectorProfilerFactory, InspectorProfilerAgent>("Pr ofiler", instrumentingAgents, compositeState)
310 {
311 setAgent(InspectorProfilerAgent::create(m_instrumentingAgents, m_state, cons oleFactory->agent(), injectedScriptManager));
312 }
313
308 } // namespace WebCore 314 } // namespace WebCore
309 315
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorProfilerAgent.h ('k') | Source/core/inspector/InspectorResourceAgent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698