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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/timeline/TimelinePanel.js

Issue 1521113002: DevTools: Initial implementation of slow CPU emulation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 4 landing Created 5 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * Copyright (C) 2012 Intel Inc. All rights reserved. 3 * Copyright (C) 2012 Intel 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 are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 this._tracingModel = new WebInspector.TracingModel(this._tracingModelBacking Storage); 54 this._tracingModel = new WebInspector.TracingModel(this._tracingModelBacking Storage);
55 this._model = new WebInspector.TimelineModel(this._tracingModel, WebInspecto r.TimelineUIUtils.visibleEventsFilter()); 55 this._model = new WebInspector.TimelineModel(this._tracingModel, WebInspecto r.TimelineUIUtils.visibleEventsFilter());
56 this._frameModel = new WebInspector.TracingTimelineFrameModel(); 56 this._frameModel = new WebInspector.TracingTimelineFrameModel();
57 57
58 this._model.addEventListener(WebInspector.TimelineModel.Events.RecordingStar ted, this._onRecordingStarted, this); 58 this._model.addEventListener(WebInspector.TimelineModel.Events.RecordingStar ted, this._onRecordingStarted, this);
59 this._model.addEventListener(WebInspector.TimelineModel.Events.RecordingStop ped, this._onRecordingStopped, this); 59 this._model.addEventListener(WebInspector.TimelineModel.Events.RecordingStop ped, this._onRecordingStopped, this);
60 this._model.addEventListener(WebInspector.TimelineModel.Events.RecordsCleare d, this._onRecordsCleared, this); 60 this._model.addEventListener(WebInspector.TimelineModel.Events.RecordsCleare d, this._onRecordsCleared, this);
61 this._model.addEventListener(WebInspector.TimelineModel.Events.BufferUsage, this._onTracingBufferUsage, this); 61 this._model.addEventListener(WebInspector.TimelineModel.Events.BufferUsage, this._onTracingBufferUsage, this);
62 this._model.addEventListener(WebInspector.TimelineModel.Events.RetrieveEvent sProgress, this._onRetrieveEventsProgress, this); 62 this._model.addEventListener(WebInspector.TimelineModel.Events.RetrieveEvent sProgress, this._onRetrieveEventsProgress, this);
63 63
64 if (Runtime.experiments.isEnabled("cpuThrottling"))
65 this._cpuThrottlingManager = new WebInspector.CPUThrottlingManager();
66
64 this._waterfallFilters = [new WebInspector.TimelineStaticFilter()]; 67 this._waterfallFilters = [new WebInspector.TimelineStaticFilter()];
65 if (!Runtime.experiments.isEnabled("timelineEventsTreeView")) { 68 if (!Runtime.experiments.isEnabled("timelineEventsTreeView")) {
66 this._filtersControl = new WebInspector.TimelineFilters(); 69 this._filtersControl = new WebInspector.TimelineFilters();
67 this._filtersControl.addEventListener(WebInspector.TimelineFilters.Event s.FilterChanged, this._refreshViews, this); 70 this._filtersControl.addEventListener(WebInspector.TimelineFilters.Event s.FilterChanged, this._refreshViews, this);
68 this._waterfallFilters = this._waterfallFilters.concat(this._filtersCont rol.filters()); 71 this._waterfallFilters = this._waterfallFilters.concat(this._filtersCont rol.filters());
69 } 72 }
70 73
71 /** @type {!Array.<!WebInspector.TimelineModeView>} */ 74 /** @type {!Array.<!WebInspector.TimelineModeView>} */
72 this._currentViews = []; 75 this._currentViews = [];
73 76
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 this._panelToolbar.appendToolbarItem(this._createSettingCheckbox(WebInsp ector.UIString("Paint"), 389 this._panelToolbar.appendToolbarItem(this._createSettingCheckbox(WebInsp ector.UIString("Paint"),
387 this._c aptureLayersAndPicturesSetting, 390 this._c aptureLayersAndPicturesSetting,
388 WebInsp ector.UIString("Capture graphics layer positions and painted pictures. (Has perf ormance overhead)"))); 391 WebInsp ector.UIString("Capture graphics layer positions and painted pictures. (Has perf ormance overhead)")));
389 392
390 this._captureFilmStripSetting = WebInspector.settings.createSetting("tim elineCaptureFilmStrip", false); 393 this._captureFilmStripSetting = WebInspector.settings.createSetting("tim elineCaptureFilmStrip", false);
391 this._captureFilmStripSetting.addChangeListener(this._onModeChanged, thi s); 394 this._captureFilmStripSetting.addChangeListener(this._onModeChanged, thi s);
392 this._panelToolbar.appendToolbarItem(this._createSettingCheckbox(WebInsp ector.UIString("Screenshots"), 395 this._panelToolbar.appendToolbarItem(this._createSettingCheckbox(WebInsp ector.UIString("Screenshots"),
393 this._c aptureFilmStripSetting, 396 this._c aptureFilmStripSetting,
394 WebInsp ector.UIString("Capture screenshots while recording. (Has performance overhead)" ))); 397 WebInsp ector.UIString("Capture screenshots while recording. (Has performance overhead)" )));
395 398
399 if (Runtime.experiments.isEnabled("cpuThrottling")) {
400 this._panelToolbar.appendSeparator();
401 this._cpuThrottlingCombobox = new WebInspector.ToolbarComboBox(this. _onCPUThrottlingChanged.bind(this));
402 /**
403 * @param {string} name
404 * @param {number} value
405 * @this {WebInspector.TimelinePanel}
406 */
407 function addGroupingOption(name, value)
408 {
409 var option = this._cpuThrottlingCombobox.createOption(name, "", String(value));
410 this._cpuThrottlingCombobox.addOption(option);
411 if (value === this._cpuThrottlingManager.rate())
412 this._cpuThrottlingCombobox.select(option);
413 }
414 addGroupingOption.call(this, WebInspector.UIString("No CPU throttlin g"), 1);
415 for (var rate of [1.2, 1.5, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 15, 20, 30, 50])
416 addGroupingOption.call(this, WebInspector.UIString("%fx slowdown ", rate), rate);
417 this._panelToolbar.appendToolbarItem(this._cpuThrottlingCombobox);
418 }
419
396 this._progressToolbarItem = new WebInspector.ToolbarItem(createElement(" div")); 420 this._progressToolbarItem = new WebInspector.ToolbarItem(createElement(" div"));
397 this._progressToolbarItem.setVisible(false); 421 this._progressToolbarItem.setVisible(false);
398 this._panelToolbar.appendToolbarItem(this._progressToolbarItem); 422 this._panelToolbar.appendToolbarItem(this._progressToolbarItem);
399 423
400 if (this._filtersControl) 424 if (this._filtersControl)
401 this._filtersControl.filtersWidget().show(this.element); 425 this._filtersControl.filtersWidget().show(this.element);
402 }, 426 },
403 427
404 /** 428 /**
405 * @return {!WebInspector.Progress} 429 * @return {!WebInspector.Progress}
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 this.doResize(); 584 this.doResize();
561 this.select(null); 585 this.select(null);
562 }, 586 },
563 587
564 _onNetworkChanged: function() 588 _onNetworkChanged: function()
565 { 589 {
566 if (this._flameChart) 590 if (this._flameChart)
567 this._flameChart.enableNetworkPane(this._captureNetworkSetting.get() , true); 591 this._flameChart.enableNetworkPane(this._captureNetworkSetting.get() , true);
568 }, 592 },
569 593
594 _onCPUThrottlingChanged: function()
595 {
596 if (!this._cpuThrottlingManager)
597 return;
598 var value = Number.parseFloat(this._cpuThrottlingCombobox.selectedOption ().value);
599 this._cpuThrottlingManager.setRate(value);
600 },
601
570 /** 602 /**
571 * @param {boolean} enabled 603 * @param {boolean} enabled
572 */ 604 */
573 _setUIControlsEnabled: function(enabled) 605 _setUIControlsEnabled: function(enabled)
574 { 606 {
575 /** 607 /**
576 * @param {!WebInspector.ToolbarButton} toolbarButton 608 * @param {!WebInspector.ToolbarButton} toolbarButton
577 */ 609 */
578 function handler(toolbarButton) 610 function handler(toolbarButton)
579 { 611 {
(...skipping 1450 matching lines...) Expand 10 before | Expand all | Expand 10 after
2030 } 2062 }
2031 }, 2063 },
2032 2064
2033 _notifyFiltersChanged: function() 2065 _notifyFiltersChanged: function()
2034 { 2066 {
2035 this.dispatchEventToListeners(WebInspector.TimelineFilters.Events.Filter Changed); 2067 this.dispatchEventToListeners(WebInspector.TimelineFilters.Events.Filter Changed);
2036 }, 2068 },
2037 2069
2038 __proto__: WebInspector.Object.prototype 2070 __proto__: WebInspector.Object.prototype
2039 }; 2071 };
2072
2073 /**
2074 * @constructor
2075 * @extends {WebInspector.Object}
2076 * @implements {WebInspector.TargetManager.Observer}
2077 */
2078 WebInspector.CPUThrottlingManager = function()
2079 {
2080 this._targets = [];
2081 this._throttlingRate = 1.; // No throttling
2082 WebInspector.targetManager.observeTargets(this);
2083 }
2084
2085 WebInspector.CPUThrottlingManager.prototype = {
2086 /**
2087 * @param {number} value
2088 */
2089 setRate: function(value)
2090 {
2091 this._throttlingRate = value;
2092 this._targets.forEach(target => target.emulationAgent().setCPUThrottling Rate(value));
2093 },
2094
2095 /**
2096 * @return {number}
2097 */
2098 rate: function()
2099 {
2100 return this._throttlingRate;
2101 },
2102
2103 /**
2104 * @override
2105 * @param {!WebInspector.Target} target
2106 */
2107 targetAdded: function(target)
2108 {
2109 this._targets.push(target);
2110 target.emulationAgent().setCPUThrottlingRate(this._throttlingRate);
2111 },
2112
2113 /**
2114 * @override
2115 * @param {!WebInspector.Target} target
2116 */
2117 targetRemoved: function(target)
2118 {
2119 this._targets.remove(target, true);
2120 },
2121
2122 __proto__: WebInspector.Object.prototype
2123 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/main/Main.js ('k') | third_party/WebKit/Source/devtools/protocol.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698