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

Unified Diff: webkit/glue/devtools/js/devtools_host_stub.js

Issue 467043: Revert 34040 - DevTools: make possible profiling of scripts doing heavy calcu... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/glue/devtools/js/devtools.js ('k') | webkit/glue/devtools/js/inspector_controller_impl.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/devtools/js/devtools_host_stub.js
===================================================================
--- webkit/glue/devtools/js/devtools_host_stub.js (revision 34040)
+++ webkit/glue/devtools/js/devtools_host_stub.js (working copy)
@@ -13,6 +13,11 @@
* @constructor
*/
RemoteDebuggerAgentStub = function() {
+ this.activeProfilerModules_ =
+ devtools.DebuggerAgent.ProfilerModules.PROFILER_MODULE_NONE;
+ this.profileLogPos_ = 0;
+ this.heapProfSample_ = 0;
+ this.heapProfLog_ = '';
};
@@ -21,112 +26,82 @@
};
-/**
- * @constructor
- */
-RemoteProfilerAgentStub = function() {
-};
-
-
-RemoteProfilerAgentStub.prototype.GetActiveProfilerModules = function() {
- ProfilerStubHelper.GetInstance().GetActiveProfilerModules();
-};
-
-
-RemoteProfilerAgentStub.prototype.GetLogLines = function(pos) {
- ProfilerStubHelper.GetInstance().GetLogLines(pos);
-};
-
-
-/**
- * @constructor
- */
-RemoteToolsAgentStub = function() {
-};
-
-
-RemoteToolsAgentStub.prototype.DispatchOnInjectedScript = function() {
-};
-
-
-RemoteToolsAgentStub.prototype.DispatchOnInspectorController = function() {
-};
-
-
-RemoteToolsAgentStub.prototype.ExecuteVoidJavaScript = function() {
-};
-
-
-/**
- * @constructor
- */
-ProfilerStubHelper = function() {
- this.activeProfilerModules_ =
- devtools.ProfilerAgent.ProfilerModules.PROFILER_MODULE_NONE;
- this.heapProfSample_ = 0;
- this.log_ = '';
-};
-
-
-ProfilerStubHelper.GetInstance = function() {
- if (!ProfilerStubHelper.instance_) {
- ProfilerStubHelper.instance_ = new ProfilerStubHelper();
- }
- return ProfilerStubHelper.instance_;
-};
-
-
-ProfilerStubHelper.prototype.StopProfiling = function(modules) {
+RemoteDebuggerAgentStub.prototype.StopProfiling = function(modules) {
this.activeProfilerModules_ &= ~modules;
};
-ProfilerStubHelper.prototype.StartProfiling = function(modules) {
- var profModules = devtools.ProfilerAgent.ProfilerModules;
+RemoteDebuggerAgentStub.prototype.StartProfiling = function(modules) {
+ var profModules = devtools.DebuggerAgent.ProfilerModules;
if (modules & profModules.PROFILER_MODULE_HEAP_SNAPSHOT) {
if (modules & profModules.PROFILER_MODULE_HEAP_STATS) {
- this.log_ +=
+ this.heapProfLog_ +=
'heap-sample-begin,"Heap","allocated",' +
(new Date()).getTime() + '\n' +
'heap-sample-stats,"Heap","allocated",10000,1000\n';
- this.log_ +=
+ this.heapProfLog_ +=
'heap-sample-item,STRING_TYPE,100,1000\n' +
'heap-sample-item,CODE_TYPE,10,200\n' +
'heap-sample-item,MAP_TYPE,20,350\n';
- this.log_ +=
- ProfilerStubHelper.HeapSamples[this.heapProfSample_++];
- this.heapProfSample_ %= ProfilerStubHelper.HeapSamples.length;
- this.log_ +=
+ this.heapProfLog_ += RemoteDebuggerAgentStub.HeapSamples[this.heapProfSample_++];
+ this.heapProfSample_ %= RemoteDebuggerAgentStub.HeapSamples.length;
+ this.heapProfLog_ +=
'heap-sample-end,"Heap","allocated"\n';
}
} else {
- if (modules & profModules.PROFILER_MODULE_CPU) {
- this.log_ += ProfilerStubHelper.ProfilerLogBuffer;
- }
this.activeProfilerModules_ |= modules;
}
};
-ProfilerStubHelper.prototype.GetActiveProfilerModules = function() {
+RemoteDebuggerAgentStub.prototype.GetActiveProfilerModules = function() {
var self = this;
setTimeout(function() {
- RemoteProfilerAgent.DidGetActiveProfilerModules(
+ RemoteDebuggerAgent.DidGetActiveProfilerModules(
self.activeProfilerModules_);
}, 100);
};
-ProfilerStubHelper.prototype.GetLogLines = function(pos) {
- var profModules = devtools.ProfilerAgent.ProfilerModules;
- var logLines = this.log_.substr(pos);
+RemoteDebuggerAgentStub.prototype.GetNextLogLines = function() {
+ var profModules = devtools.DebuggerAgent.ProfilerModules;
+ var logLines = '';
+ if (this.activeProfilerModules_ & profModules.PROFILER_MODULE_CPU) {
+ if (this.profileLogPos_ < RemoteDebuggerAgentStub.ProfilerLogBuffer.length) {
+ this.profileLogPos_ += RemoteDebuggerAgentStub.ProfilerLogBuffer.length;
+ logLines += RemoteDebuggerAgentStub.ProfilerLogBuffer;
+ }
+ }
+ if (this.heapProfLog_) {
+ logLines += this.heapProfLog_;
+ this.heapProfLog_ = '';
+ }
setTimeout(function() {
- RemoteProfilerAgent.DidGetLogLines(pos + logLines.length, logLines);
+ RemoteDebuggerAgent.DidGetNextLogLines(logLines);
}, 100);
};
-ProfilerStubHelper.ProfilerLogBuffer =
+/**
+ * @constructor
+ */
+RemoteToolsAgentStub = function() {
+};
+
+
+RemoteToolsAgentStub.prototype.DispatchOnInjectedScript = function() {
+};
+
+
+RemoteToolsAgentStub.prototype.DispatchOnInspectorController = function() {
+};
+
+
+RemoteToolsAgentStub.prototype.ExecuteVoidJavaScript = function() {
+};
+
+
+RemoteDebuggerAgentStub.ProfilerLogBuffer =
'profiler,begin,1\n' +
'profiler,resume\n' +
'code-creation,LazyCompile,0x1000,256,"test1 http://aaa.js:1"\n' +
@@ -143,7 +118,7 @@
'profiler,pause\n';
-ProfilerStubHelper.HeapSamples = [
+RemoteDebuggerAgentStub.HeapSamples = [
'heap-js-cons-item,foo,1,100\n' +
'heap-js-cons-item,bar,20,2000\n' +
'heap-js-cons-item,Object,5,100\n' +
@@ -216,17 +191,6 @@
'"sourceLength":244,"scriptType":2,"compilationType":0,"context":{' +
'"ref":0}}],"refs":[{"handle":0,"type":"context","data":"page,3}],"' +
'"running":false}');
- } else if (cmd.indexOf('"command":"profile"') != -1) {
- var cmdObj = JSON.parse(cmd);
- if (cmdObj.arguments.command == 'resume') {
- ProfilerStubHelper.GetInstance().StartProfiling(
- parseInt(cmdObj.arguments.modules));
- } else if (cmdObj.arguments.command == 'pause') {
- ProfilerStubHelper.GetInstance().StopProfiling(
- parseInt(cmdObj.arguments.modules));
- } else {
- debugPrint('Unexpected profile command: ' + cmdObj.arguments.command);
- }
} else {
debugPrint('Unexpected command: ' + cmd);
}
@@ -266,7 +230,6 @@
window['RemoteDebuggerAgent'] = new RemoteDebuggerAgentStub();
window['RemoteDebuggerCommandExecutor'] =
new RemoteDebuggerCommandExecutorStub();
-window['RemoteProfilerAgent'] = new RemoteProfilerAgentStub();
window['RemoteToolsAgent'] = new RemoteToolsAgentStub();
InspectorFrontendHost = new DevToolsHostStub();
« no previous file with comments | « webkit/glue/devtools/js/devtools.js ('k') | webkit/glue/devtools/js/inspector_controller_impl.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698