OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 /** |
| 6 * |
| 7 * @fileoverview Displays the traced data in raw format. Its primarily |
| 8 * usefulness is to allow users to copy-paste their data in an easy to |
| 9 * read format for bug reports. |
| 10 * |
| 11 */ |
| 12 cr.define('gpu', function() { |
| 13 /** |
| 14 * Provides information on the GPU process and underlying graphics hardware. |
| 15 * @constructor |
| 16 * @extends {gpu.Tab} |
| 17 */ |
| 18 var RawEventsView = cr.ui.define(gpu.Tab); |
| 19 |
| 20 RawEventsView.prototype = { |
| 21 __proto__: gpu.Tab.prototype, |
| 22 |
| 23 decorate: function() { |
| 24 tracingController.addEventListener('traceBegun', this.refresh.bind(this)); |
| 25 tracingController.addEventListener('traceEnded', this.refresh.bind(this)); |
| 26 this.addEventListener('selectedChange', this.onSelectedChange_); |
| 27 this.refresh(); |
| 28 }, |
| 29 |
| 30 onSelectedChange_: function() { |
| 31 if (this.selected) { |
| 32 if (!tracingController.traceEvents.length) { |
| 33 tracingController.beginTracing(); |
| 34 } |
| 35 if (this.needsRefreshOnShow_) { |
| 36 this.needsRefreshOnShow_ = false; |
| 37 this.refresh(); |
| 38 } |
| 39 } |
| 40 }, |
| 41 |
| 42 /** |
| 43 * Updates the view based on its currently known data |
| 44 */ |
| 45 refresh: function() { |
| 46 if (this.parentNode.selectedTab != this) { |
| 47 this.needsRefreshOnShow_ = true; |
| 48 } |
| 49 |
| 50 var dataElement = this.querySelector('.raw-events-view-data'); |
| 51 if (tracingController.isTracingEnabled) { |
| 52 var tmp = 'Still tracing. ' + |
| 53 'Uncheck the enable tracing button to see traced data.'; |
| 54 dataElement.textContent = tmp; |
| 55 } else if (!tracingController.traceEvents.length) { |
| 56 dataElement.textContent = |
| 57 'No trace data collected. Collect data first.'; |
| 58 } else { |
| 59 var events = tracingController.traceEvents; |
| 60 var text = JSON.stringify(events); |
| 61 dataElement.textContent = text; |
| 62 |
| 63 var selection = window.getSelection(); |
| 64 selection.removeAllRanges(); |
| 65 var range = document.createRange(); |
| 66 range.selectNodeContents(dataElement); |
| 67 selection.addRange(range); |
| 68 } |
| 69 } |
| 70 |
| 71 }; |
| 72 |
| 73 return { |
| 74 RawEventsView: RawEventsView |
| 75 }; |
| 76 }); |
OLD | NEW |