| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * The status view at the top of the page when in capturing mode. | 6 * The status view at the top of the page when in capturing mode. |
| 7 */ | 7 */ |
| 8 var CaptureStatusView = (function() { | 8 var CaptureStatusView = (function() { |
| 9 'use strict'; | 9 'use strict'; |
| 10 | 10 |
| 11 // We inherit from DivView. | 11 // We inherit from DivView. |
| 12 var superClass = DivView; | 12 var superClass = DivView; |
| 13 | 13 |
| 14 function CaptureStatusView() { | 14 function CaptureStatusView() { |
| 15 superClass.call(this, CaptureStatusView.MAIN_BOX_ID); | 15 superClass.call(this, CaptureStatusView.MAIN_BOX_ID); |
| 16 | 16 |
| 17 $(CaptureStatusView.STOP_BUTTON_ID).onclick = switchToViewOnlyMode_; | 17 $(CaptureStatusView.STOP_BUTTON_ID).onclick = switchToViewOnlyMode_; |
| 18 | 18 |
| 19 $(CaptureStatusView.RESET_BUTTON_ID).onclick = | 19 $(CaptureStatusView.RESET_BUTTON_ID).onclick = |
| 20 g_browser.sourceTracker.deleteAllSourceEntries.bind( | 20 EventsTracker.getInstance().deleteAllLogEntries.bind( |
| 21 g_browser.sourceTracker); | 21 EventsTracker.getInstance()); |
| 22 $(CaptureStatusView.CLEAR_CACHE_BUTTON_ID).onclick = | 22 $(CaptureStatusView.CLEAR_CACHE_BUTTON_ID).onclick = |
| 23 g_browser.sendClearAllCache.bind(g_browser); | 23 g_browser.sendClearAllCache.bind(g_browser); |
| 24 $(CaptureStatusView.FLUSH_SOCKETS_BUTTON_ID).onclick = | 24 $(CaptureStatusView.FLUSH_SOCKETS_BUTTON_ID).onclick = |
| 25 g_browser.sendFlushSocketPools.bind(g_browser); | 25 g_browser.sendFlushSocketPools.bind(g_browser); |
| 26 | 26 |
| 27 $(CaptureStatusView.TOGGLE_EXTRAS_ID).onclick = | 27 $(CaptureStatusView.TOGGLE_EXTRAS_ID).onclick = |
| 28 this.toggleExtras_.bind(this); | 28 this.toggleExtras_.bind(this); |
| 29 | 29 |
| 30 this.capturedEventsCountBox_ = | 30 this.capturedEventsCountBox_ = |
| 31 $(CaptureStatusView.CAPTURED_EVENTS_COUNT_ID); | 31 $(CaptureStatusView.CAPTURED_EVENTS_COUNT_ID); |
| 32 this.updateEventCounts_(); | 32 this.updateEventCounts_(); |
| 33 | 33 |
| 34 g_browser.sourceTracker.addSourceEntryObserver(this); | 34 EventsTracker.getInstance().addLogEntryObserver(this); |
| 35 } | 35 } |
| 36 | 36 |
| 37 // IDs for special HTML elements in status_view.html | 37 // IDs for special HTML elements in status_view.html |
| 38 CaptureStatusView.MAIN_BOX_ID = 'capture-status-view'; | 38 CaptureStatusView.MAIN_BOX_ID = 'capture-status-view'; |
| 39 CaptureStatusView.STOP_BUTTON_ID = 'capture-status-view-stop'; | 39 CaptureStatusView.STOP_BUTTON_ID = 'capture-status-view-stop'; |
| 40 CaptureStatusView.RESET_BUTTON_ID = 'capture-status-view-reset'; | 40 CaptureStatusView.RESET_BUTTON_ID = 'capture-status-view-reset'; |
| 41 CaptureStatusView.CLEAR_CACHE_BUTTON_ID = 'capture-status-view-clear-cache'; | 41 CaptureStatusView.CLEAR_CACHE_BUTTON_ID = 'capture-status-view-clear-cache'; |
| 42 CaptureStatusView.FLUSH_SOCKETS_BUTTON_ID = | 42 CaptureStatusView.FLUSH_SOCKETS_BUTTON_ID = |
| 43 'capture-status-view-flush-sockets'; | 43 'capture-status-view-flush-sockets'; |
| 44 CaptureStatusView.CAPTURED_EVENTS_COUNT_ID = | 44 CaptureStatusView.CAPTURED_EVENTS_COUNT_ID = |
| 45 'capture-status-view-captured-events-count'; | 45 'capture-status-view-captured-events-count'; |
| 46 CaptureStatusView.TOGGLE_EXTRAS_ID = 'capture-status-view-toggle-extras'; | 46 CaptureStatusView.TOGGLE_EXTRAS_ID = 'capture-status-view-toggle-extras'; |
| 47 CaptureStatusView.EXTRAS_ID = 'capture-status-view-extras'; | 47 CaptureStatusView.EXTRAS_ID = 'capture-status-view-extras'; |
| 48 | 48 |
| 49 CaptureStatusView.prototype = { | 49 CaptureStatusView.prototype = { |
| 50 // Inherit the superclass's methods. | 50 // Inherit the superclass's methods. |
| 51 __proto__: superClass.prototype, | 51 __proto__: superClass.prototype, |
| 52 | 52 |
| 53 /** | 53 /** |
| 54 * Called whenever a new event is received. | 54 * Called whenever new log entries have been received. |
| 55 */ | 55 */ |
| 56 onSourceEntriesUpdated: function(sourceEntries) { | 56 onReceivedLogEntries: function(logEntries) { |
| 57 this.updateEventCounts_(); | 57 this.updateEventCounts_(); |
| 58 }, | 58 }, |
| 59 | 59 |
| 60 /** | 60 /** |
| 61 * Called whenever all log events are deleted. | 61 * Called whenever all log events are deleted. |
| 62 */ | 62 */ |
| 63 onAllSourceEntriesDeleted: function() { | 63 onAllLogEntriesDeleted: function() { |
| 64 this.updateEventCounts_(); | 64 this.updateEventCounts_(); |
| 65 }, | 65 }, |
| 66 | 66 |
| 67 /** | 67 /** |
| 68 * Updates the counters showing how many events have been captured. | 68 * Updates the counters showing how many events have been captured. |
| 69 */ | 69 */ |
| 70 updateEventCounts_: function() { | 70 updateEventCounts_: function() { |
| 71 this.capturedEventsCountBox_.textContent = | 71 this.capturedEventsCountBox_.textContent = |
| 72 g_browser.sourceTracker.getNumCapturedEvents(); | 72 EventsTracker.getInstance().getNumCapturedEvents(); |
| 73 }, | 73 }, |
| 74 | 74 |
| 75 /** | 75 /** |
| 76 * Toggles the visibility of the "extras" action bar. | 76 * Toggles the visibility of the "extras" action bar. |
| 77 */ | 77 */ |
| 78 toggleExtras_: function() { | 78 toggleExtras_: function() { |
| 79 var toggle = $(CaptureStatusView.TOGGLE_EXTRAS_ID); | 79 var toggle = $(CaptureStatusView.TOGGLE_EXTRAS_ID); |
| 80 var extras = $(CaptureStatusView.EXTRAS_ID); | 80 var extras = $(CaptureStatusView.EXTRAS_ID); |
| 81 | 81 |
| 82 var isVisible = extras.style.display == ''; | 82 var isVisible = extras.style.display == ''; |
| 83 | 83 |
| 84 // Toggle between the left-facing triangle and right-facing triange. | 84 // Toggle between the left-facing triangle and right-facing triange. |
| 85 toggle.className = isVisible ? | 85 toggle.className = isVisible ? |
| 86 'capture-status-view-rotateleft' : 'capture-status-view-rotateright'; | 86 'capture-status-view-rotateleft' : 'capture-status-view-rotateright'; |
| 87 setNodeDisplay(extras, !isVisible); | 87 setNodeDisplay(extras, !isVisible); |
| 88 } | 88 } |
| 89 }; | 89 }; |
| 90 | 90 |
| 91 /** | 91 /** |
| 92 * Calls the corresponding function of MainView. This is needed because we | 92 * Calls the corresponding function of MainView. This is needed because we |
| 93 * can't call MainView.getInstance() in the constructor, as it hasn't been | 93 * can't call MainView.getInstance() in the constructor, as it hasn't been |
| 94 * created yet. | 94 * created yet. |
| 95 */ | 95 */ |
| 96 function switchToViewOnlyMode_() { | 96 function switchToViewOnlyMode_() { |
| 97 MainView.getInstance().switchToViewOnlyMode(); | 97 MainView.getInstance().switchToViewOnlyMode(); |
| 98 } | 98 } |
| 99 | 99 |
| 100 return CaptureStatusView; | 100 return CaptureStatusView; |
| 101 })(); | 101 })(); |
| OLD | NEW |