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

Side by Side Diff: chrome/browser/resources/net_internals/main.js

Issue 8474001: Add a timeline view to about:net-internals. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Update comments Created 9 years, 1 month 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 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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 * Dictionary of constants (Initialized soon after loading by data from browser, 6 * Dictionary of constants (Initialized soon after loading by data from browser,
7 * updated on load log). 7 * updated on load log).
8 */ 8 */
9 var LogEventType = null; 9 var LogEventType = null;
10 var LogEventPhase = null; 10 var LogEventPhase = null;
(...skipping 26 matching lines...) Expand all
37 // We inherit from ResizableVerticalSplitView. 37 // We inherit from ResizableVerticalSplitView.
38 var superClass = ResizableVerticalSplitView; 38 var superClass = ResizableVerticalSplitView;
39 39
40 /** 40 /**
41 * Main entry point. Called once the page has loaded. 41 * Main entry point. Called once the page has loaded.
42 * @constructor 42 * @constructor
43 */ 43 */
44 function MainView() { 44 function MainView() {
45 assertFirstConstructorCall(MainView); 45 assertFirstConstructorCall(MainView);
46 46
47 // Tracks if we're viewing a loaded log file, so views can behave
48 // appropriately.
49 this.isViewingLoadedLog_ = false;
50
51 // This must be initialized before the tabs, so they can register as 47 // This must be initialized before the tabs, so they can register as
52 // observers. 48 // observers.
53 g_browser = BrowserBridge.getInstance(); 49 g_browser = BrowserBridge.getInstance();
54 50
51 // This must be the first constants observer, so other constants observers
52 // can safely use the globals, rather than depending on walking through
53 // the constants themselves.
54 g_browser.addConstantsObserver(new ConstantsObserver());
55
55 // This view is a left (resizable) navigation bar. 56 // This view is a left (resizable) navigation bar.
56 this.categoryTabSwitcher_ = new TabSwitcherView(); 57 this.categoryTabSwitcher_ = new TabSwitcherView();
57 var tabs = this.categoryTabSwitcher_; 58 var tabs = this.categoryTabSwitcher_;
58 59
59 // Call superclass's constructor, initializing the view which lets you tab 60 // Call superclass's constructor, initializing the view which lets you tab
60 // between the different sub-views. 61 // between the different sub-views.
61 superClass.call(this, 62 superClass.call(this,
62 new DivView(MainView.CATEGORY_TAB_HANDLES_ID), 63 new DivView(MainView.CATEGORY_TAB_HANDLES_ID),
63 tabs, 64 tabs,
64 new DivView(MainView.SPLITTER_BOX_FOR_MAIN_TABS_ID)); 65 new DivView(MainView.SPLITTER_BOX_FOR_MAIN_TABS_ID));
(...skipping 10 matching lines...) Expand all
75 tabs.addTab(CaptureView.TAB_HANDLE_ID, CaptureView.getInstance(), 76 tabs.addTab(CaptureView.TAB_HANDLE_ID, CaptureView.getInstance(),
76 false, true); 77 false, true);
77 tabs.addTab(ExportView.TAB_HANDLE_ID, ExportView.getInstance(), 78 tabs.addTab(ExportView.TAB_HANDLE_ID, ExportView.getInstance(),
78 false, true); 79 false, true);
79 tabs.addTab(ImportView.TAB_HANDLE_ID, ImportView.getInstance(), 80 tabs.addTab(ImportView.TAB_HANDLE_ID, ImportView.getInstance(),
80 false, true); 81 false, true);
81 tabs.addTab(ProxyView.TAB_HANDLE_ID, ProxyView.getInstance(), 82 tabs.addTab(ProxyView.TAB_HANDLE_ID, ProxyView.getInstance(),
82 false, true); 83 false, true);
83 tabs.addTab(EventsView.TAB_HANDLE_ID, EventsView.getInstance(), 84 tabs.addTab(EventsView.TAB_HANDLE_ID, EventsView.getInstance(),
84 false, true); 85 false, true);
86 tabs.addTab(TimelineView.TAB_HANDLE_ID, TimelineView.getInstance(),
87 false, true);
85 tabs.addTab(DnsView.TAB_HANDLE_ID, DnsView.getInstance(), 88 tabs.addTab(DnsView.TAB_HANDLE_ID, DnsView.getInstance(),
86 false, true); 89 false, true);
87 tabs.addTab(SocketsView.TAB_HANDLE_ID, SocketsView.getInstance(), 90 tabs.addTab(SocketsView.TAB_HANDLE_ID, SocketsView.getInstance(),
88 false, true); 91 false, true);
89 tabs.addTab(SpdyView.TAB_HANDLE_ID, SpdyView.getInstance(), false, true); 92 tabs.addTab(SpdyView.TAB_HANDLE_ID, SpdyView.getInstance(), false, true);
90 tabs.addTab(HttpCacheView.TAB_HANDLE_ID, HttpCacheView.getInstance(), 93 tabs.addTab(HttpCacheView.TAB_HANDLE_ID, HttpCacheView.getInstance(),
91 false, true); 94 false, true);
92 tabs.addTab(HttpThrottlingView.TAB_HANDLE_ID, 95 tabs.addTab(HttpThrottlingView.TAB_HANDLE_ID,
93 HttpThrottlingView.getInstance(), false, true); 96 HttpThrottlingView.getInstance(), false, true);
94 tabs.addTab(ServiceProvidersView.TAB_HANDLE_ID, 97 tabs.addTab(ServiceProvidersView.TAB_HANDLE_ID,
(...skipping 25 matching lines...) Expand all
120 var statusView = new DivView(MainView.STATUS_VIEW_ID); 123 var statusView = new DivView(MainView.STATUS_VIEW_ID);
121 var verticalSplitView = new VerticalSplitView(statusView, this); 124 var verticalSplitView = new VerticalSplitView(statusView, this);
122 var windowView = new WindowView(verticalSplitView); 125 var windowView = new WindowView(verticalSplitView);
123 126
124 // Trigger initial layout. 127 // Trigger initial layout.
125 windowView.resetGeometry(); 128 windowView.resetGeometry();
126 129
127 // Select the initial view based on the current URL. 130 // Select the initial view based on the current URL.
128 window.onhashchange(); 131 window.onhashchange();
129 132
130 g_browser.addConstantsObserver(new ConstantsObserver());
131
132 // Tell the browser that we are ready to start receiving log events. 133 // Tell the browser that we are ready to start receiving log events.
133 g_browser.sendReady(); 134 g_browser.sendReady();
134 } 135 }
135 136
136 // IDs for special HTML elements in index.html 137 // IDs for special HTML elements in index.html
137 MainView.CATEGORY_TAB_HANDLES_ID = 'category-tab-handles'; 138 MainView.CATEGORY_TAB_HANDLES_ID = 'category-tab-handles';
138 MainView.SPLITTER_BOX_FOR_MAIN_TABS_ID = 'splitter-box-for-main-tabs'; 139 MainView.SPLITTER_BOX_FOR_MAIN_TABS_ID = 'splitter-box-for-main-tabs';
139 MainView.STATUS_VIEW_ID = 'status-view'; 140 MainView.STATUS_VIEW_ID = 'status-view';
140 MainView.STATUS_VIEW_FOR_CAPTURE_ID = 'status-view-for-capture'; 141 MainView.STATUS_VIEW_FOR_CAPTURE_ID = 'status-view-for-capture';
141 MainView.STATUS_VIEW_FOR_FILE_ID = 'status-view-for-file'; 142 MainView.STATUS_VIEW_FOR_FILE_ID = 'status-view-for-file';
142 MainView.STATUS_VIEW_DUMP_FILE_NAME_ID = 'status-view-dump-file-name'; 143 MainView.STATUS_VIEW_DUMP_FILE_NAME_ID = 'status-view-dump-file-name';
143 144
144 cr.addSingletonGetter(MainView); 145 cr.addSingletonGetter(MainView);
145 146
147 // Tracks if we're viewing a loaded log file, so views can behave
148 // appropriately. Global so safe to call during construction.
149 var isViewingLoadedLog = false;
150
151 MainView.isViewingLoadedLog = function() {
152 return isViewingLoadedLog;
153 }
eroman 2011/11/16 04:03:46 nit: add a semicolon.
mmenke 2011/11/16 18:39:35 Done.
154
146 MainView.prototype = { 155 MainView.prototype = {
147 // Inherit the superclass's methods. 156 // Inherit the superclass's methods.
148 __proto__: superClass.prototype, 157 __proto__: superClass.prototype,
149 158
150 // This is exposed both so the log import/export code can enumerate all the 159 // This is exposed both so the log import/export code can enumerate all the
151 // tabs, and for testing. 160 // tabs, and for testing.
152 categoryTabSwitcher: function() { 161 categoryTabSwitcher: function() {
153 return this.categoryTabSwitcher_; 162 return this.categoryTabSwitcher_;
154 }, 163 },
155 164
156 /** 165 /**
157 * Prevents receiving/sending events to/from the browser, so loaded data 166 * Prevents receiving/sending events to/from the browser, so loaded data
158 * will not be mixed with current Chrome state. Also hides any interactive 167 * will not be mixed with current Chrome state. Also hides any interactive
159 * HTML elements that send messages to the browser. Cannot be undone 168 * HTML elements that send messages to the browser. Cannot be undone
160 * without reloading the page. Must be called before passing loaded data 169 * without reloading the page. Must be called before passing loaded data
161 * to the individual views. 170 * to the individual views.
162 * 171 *
163 * @param {String} fileName The name of the log file that has been loaded. 172 * @param {String} fileName The name of the log file that has been loaded.
164 */ 173 */
165 onLoadLogFile: function(fileName) { 174 onLoadLogFile: function(fileName) {
166 this.isViewingLoadedLog_ = true; 175 isViewingLoadedLog = true;
167 176
168 // Swap out the status bar to indicate we have loaded from a file. 177 // Swap out the status bar to indicate we have loaded from a file.
169 setNodeDisplay($(MainView.STATUS_VIEW_FOR_CAPTURE_ID), false); 178 setNodeDisplay($(MainView.STATUS_VIEW_FOR_CAPTURE_ID), false);
170 setNodeDisplay($(MainView.STATUS_VIEW_FOR_FILE_ID), true); 179 setNodeDisplay($(MainView.STATUS_VIEW_FOR_FILE_ID), true);
171 180
172 // Indicate which file is being displayed. 181 // Indicate which file is being displayed.
173 $(MainView.STATUS_VIEW_DUMP_FILE_NAME_ID).innerText = fileName; 182 $(MainView.STATUS_VIEW_DUMP_FILE_NAME_ID).innerText = fileName;
174 183
175 document.styleSheets[0].insertRule('.hideOnLoadLog { display: none; }'); 184 document.styleSheets[0].insertRule('.hideOnLoadLog { display: none; }');
176 185
177 g_browser.sourceTracker.setSecurityStripping(false); 186 g_browser.sourceTracker.setSecurityStripping(false);
178 g_browser.disable(); 187 g_browser.disable();
179 }, 188 },
180
181 /**
182 * Returns true if we're viewing a loaded log file.
183 */
184 isViewingLoadedLog: function() {
185 return this.isViewingLoadedLog_;
186 }
187 }; 189 };
188 190
189
190 /* 191 /*
191 * Takes the current hash in form of "#tab&param1=value1&param2=value2&...". 192 * Takes the current hash in form of "#tab&param1=value1&param2=value2&...".
192 * Puts the parameters in an object, and passes the resulting object to 193 * Puts the parameters in an object, and passes the resulting object to
193 * |categoryTabSwitcher|. Uses tab and |anchorMap| to find a tab ID, 194 * |categoryTabSwitcher|. Uses tab and |anchorMap| to find a tab ID,
194 * which it also passes to the tab switcher. 195 * which it also passes to the tab switcher.
195 * 196 *
196 * Parameters and values are decoded with decodeURIComponent(). 197 * Parameters and values are decoded with decodeURIComponent().
197 */ 198 */
198 function onUrlHashChange(categoryTabSwitcher, anchorMap) { 199 function onUrlHashChange(categoryTabSwitcher, anchorMap) {
199 var parameters = window.location.hash.split('&'); 200 var parameters = window.location.hash.split('&');
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 typeof(receivedConstants.clientInfo) == 'object' && 257 typeof(receivedConstants.clientInfo) == 'object' &&
257 typeof(receivedConstants.logEventPhase) == 'object' && 258 typeof(receivedConstants.logEventPhase) == 'object' &&
258 typeof(receivedConstants.logSourceType) == 'object' && 259 typeof(receivedConstants.logSourceType) == 'object' &&
259 typeof(receivedConstants.logLevelType) == 'object' && 260 typeof(receivedConstants.logLevelType) == 'object' &&
260 typeof(receivedConstants.loadFlag) == 'object' && 261 typeof(receivedConstants.loadFlag) == 'object' &&
261 typeof(receivedConstants.netError) == 'object' && 262 typeof(receivedConstants.netError) == 'object' &&
262 typeof(receivedConstants.addressFamily) == 'object' && 263 typeof(receivedConstants.addressFamily) == 'object' &&
263 typeof(receivedConstants.timeTickOffset) == 'string' && 264 typeof(receivedConstants.timeTickOffset) == 'string' &&
264 typeof(receivedConstants.logFormatVersion) == 'number'; 265 typeof(receivedConstants.logFormatVersion) == 'number';
265 } 266 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698