OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 by browser). | 6 * Dictionary of constants (initialized by browser). |
7 */ | 7 */ |
8 var LogEventType = null; | 8 var LogEventType = null; |
9 var LogEventPhase = null; | 9 var LogEventPhase = null; |
10 var LogSourceType = null; | 10 var LogSourceType = null; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 | 59 |
60 // Create a view which will display import/export options to control the | 60 // Create a view which will display import/export options to control the |
61 // captured data. | 61 // captured data. |
62 var dataView = new DataView("dataTabContent", "exportToJson", "exportToText"); | 62 var dataView = new DataView("dataTabContent", "exportToJson", "exportToText"); |
63 | 63 |
64 // Create a view which will display the results and controls for connection | 64 // Create a view which will display the results and controls for connection |
65 // tests. | 65 // tests. |
66 var testView = new TestView("testTabContent", "testUrlInput", "testStart", | 66 var testView = new TestView("testTabContent", "testUrlInput", "testStart", |
67 "testSummary"); | 67 "testSummary"); |
68 | 68 |
| 69 var httpCacheView = new HttpCacheView("httpCacheTabContent", |
| 70 "reloadHttpCacheListing", |
| 71 "httpCacheStats", |
| 72 "httpCacheListing"); |
| 73 |
69 // Create a view which lets you tab between the different sub-views. | 74 // Create a view which lets you tab between the different sub-views. |
70 var categoryTabSwitcher = | 75 var categoryTabSwitcher = |
71 new TabSwitcherView(new DivView('categoryTabHandles')); | 76 new TabSwitcherView(new DivView('categoryTabHandles')); |
72 | 77 |
73 // Populate the main tabs. | 78 // Populate the main tabs. |
74 categoryTabSwitcher.addTab('requestsTab', requestsView, false); | 79 categoryTabSwitcher.addTab('requestsTab', requestsView, false); |
75 categoryTabSwitcher.addTab('proxyTab', proxyView, false); | 80 categoryTabSwitcher.addTab('proxyTab', proxyView, false); |
76 categoryTabSwitcher.addTab('dnsTab', dnsView, false); | 81 categoryTabSwitcher.addTab('dnsTab', dnsView, false); |
77 categoryTabSwitcher.addTab('socketsTab', new DivView('socketsTabContent'), | 82 categoryTabSwitcher.addTab('socketsTab', new DivView('socketsTabContent'), |
78 false); | 83 false); |
79 categoryTabSwitcher.addTab('httpCacheTab', | 84 categoryTabSwitcher.addTab('httpCacheTab', httpCacheView, false); |
80 new DivView('httpCacheTabContent'), false); | |
81 categoryTabSwitcher.addTab('dataTab', dataView, false); | 85 categoryTabSwitcher.addTab('dataTab', dataView, false); |
82 categoryTabSwitcher.addTab('testTab', testView, false); | 86 categoryTabSwitcher.addTab('testTab', testView, false); |
83 | 87 |
84 // Build a map from the anchor name of each tab handle to its "tab ID". | 88 // Build a map from the anchor name of each tab handle to its "tab ID". |
85 // We will consider navigations to the #hash as a switch tab request. | 89 // We will consider navigations to the #hash as a switch tab request. |
86 var anchorMap = {}; | 90 var anchorMap = {}; |
87 var tabIds = categoryTabSwitcher.getAllTabIds(); | 91 var tabIds = categoryTabSwitcher.getAllTabIds(); |
88 for (var i = 0; i < tabIds.length; ++i) { | 92 for (var i = 0; i < tabIds.length; ++i) { |
89 var aNode = document.getElementById(tabIds[i]); | 93 var aNode = document.getElementById(tabIds[i]); |
90 anchorMap[aNode.hash] = tabIds[i]; | 94 anchorMap[aNode.hash] = tabIds[i]; |
(...skipping 23 matching lines...) Expand all Loading... |
114 /** | 118 /** |
115 * This class provides a "bridge" for communicating between the javascript and | 119 * This class provides a "bridge" for communicating between the javascript and |
116 * the browser. | 120 * the browser. |
117 * | 121 * |
118 * @constructor | 122 * @constructor |
119 */ | 123 */ |
120 function BrowserBridge() { | 124 function BrowserBridge() { |
121 // List of observers for various bits of browser state. | 125 // List of observers for various bits of browser state. |
122 this.logObservers_ = []; | 126 this.logObservers_ = []; |
123 this.connectionTestsObservers_ = []; | 127 this.connectionTestsObservers_ = []; |
| 128 this.httpCacheInfoObservers_ = []; |
124 this.proxySettings_ = new PollableDataHelper('onProxySettingsChanged'); | 129 this.proxySettings_ = new PollableDataHelper('onProxySettingsChanged'); |
125 this.badProxies_ = new PollableDataHelper('onBadProxiesChanged'); | 130 this.badProxies_ = new PollableDataHelper('onBadProxiesChanged'); |
126 this.hostResolverCache_ = | 131 this.hostResolverCache_ = |
127 new PollableDataHelper('onHostResolverCacheChanged'); | 132 new PollableDataHelper('onHostResolverCacheChanged'); |
128 | 133 |
129 // Cache of the data received. | 134 // Cache of the data received. |
130 // TODO(eroman): the controls to clear data in the "Requests" tab should be | 135 // TODO(eroman): the controls to clear data in the "Requests" tab should be |
131 // affecting this as well. | 136 // affecting this as well. |
132 this.passivelyCapturedEvents_ = []; | 137 this.passivelyCapturedEvents_ = []; |
133 this.activelyCapturedEvents_ = []; | 138 this.activelyCapturedEvents_ = []; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 }; | 181 }; |
177 | 182 |
178 BrowserBridge.prototype.sendClearHostResolverCache = function() { | 183 BrowserBridge.prototype.sendClearHostResolverCache = function() { |
179 chrome.send('clearHostResolverCache'); | 184 chrome.send('clearHostResolverCache'); |
180 }; | 185 }; |
181 | 186 |
182 BrowserBridge.prototype.sendStartConnectionTests = function(url) { | 187 BrowserBridge.prototype.sendStartConnectionTests = function(url) { |
183 chrome.send('startConnectionTests', [url]); | 188 chrome.send('startConnectionTests', [url]); |
184 }; | 189 }; |
185 | 190 |
| 191 BrowserBridge.prototype.sendGetHttpCacheInfo = function() { |
| 192 chrome.send('getHttpCacheInfo'); |
| 193 }; |
| 194 |
186 //------------------------------------------------------------------------------ | 195 //------------------------------------------------------------------------------ |
187 // Messages received from the browser | 196 // Messages received from the browser |
188 //------------------------------------------------------------------------------ | 197 //------------------------------------------------------------------------------ |
189 | 198 |
190 BrowserBridge.prototype.receivedLogEntry = function(logEntry, | 199 BrowserBridge.prototype.receivedLogEntry = function(logEntry, |
191 wasCapturedPassively) { | 200 wasCapturedPassively) { |
192 if (!wasCapturedPassively) { | 201 if (!wasCapturedPassively) { |
193 this.activelyCapturedEvents_.push(logEntry); | 202 this.activelyCapturedEvents_.push(logEntry); |
194 } | 203 } |
195 for (var i = 0; i < this.logObservers_.length; ++i) | 204 for (var i = 0; i < this.logObservers_.length; ++i) |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 this.connectionTestsObservers_[i].onCompletedConnectionTestExperiment( | 263 this.connectionTestsObservers_[i].onCompletedConnectionTestExperiment( |
255 info.experiment, info.result); | 264 info.experiment, info.result); |
256 } | 265 } |
257 }; | 266 }; |
258 | 267 |
259 BrowserBridge.prototype.receivedCompletedConnectionTestSuite = function() { | 268 BrowserBridge.prototype.receivedCompletedConnectionTestSuite = function() { |
260 for (var i = 0; i < this.connectionTestsObservers_.length; ++i) | 269 for (var i = 0; i < this.connectionTestsObservers_.length; ++i) |
261 this.connectionTestsObservers_[i].onCompletedConnectionTestSuite(); | 270 this.connectionTestsObservers_[i].onCompletedConnectionTestSuite(); |
262 }; | 271 }; |
263 | 272 |
| 273 BrowserBridge.prototype.receivedHttpCacheInfo = function(info) { |
| 274 for (var i = 0; i < this.httpCacheInfoObservers_.length; ++i) |
| 275 this.httpCacheInfoObservers_[i].onHttpCacheInfoReceived(info); |
| 276 }; |
| 277 |
264 //------------------------------------------------------------------------------ | 278 //------------------------------------------------------------------------------ |
265 | 279 |
266 /** | 280 /** |
267 * Adds a listener of log entries. |observer| will be called back when new log | 281 * Adds a listener of log entries. |observer| will be called back when new log |
268 * data arrives, through: | 282 * data arrives, through: |
269 * | 283 * |
270 * observer.onLogEntryAdded(logEntry) | 284 * observer.onLogEntryAdded(logEntry) |
271 */ | 285 */ |
272 BrowserBridge.prototype.addLogObserver = function(observer) { | 286 BrowserBridge.prototype.addLogObserver = function(observer) { |
273 this.logObservers_.push(observer); | 287 this.logObservers_.push(observer); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 * observer.onStartedConnectionTestSuite(); | 332 * observer.onStartedConnectionTestSuite(); |
319 * observer.onStartedConnectionTestExperiment(experiment); | 333 * observer.onStartedConnectionTestExperiment(experiment); |
320 * observer.onCompletedConnectionTestExperiment(experiment, result); | 334 * observer.onCompletedConnectionTestExperiment(experiment, result); |
321 * observer.onCompletedConnectionTestSuite(); | 335 * observer.onCompletedConnectionTestSuite(); |
322 */ | 336 */ |
323 BrowserBridge.prototype.addConnectionTestsObserver = function(observer) { | 337 BrowserBridge.prototype.addConnectionTestsObserver = function(observer) { |
324 this.connectionTestsObservers_.push(observer); | 338 this.connectionTestsObservers_.push(observer); |
325 }; | 339 }; |
326 | 340 |
327 /** | 341 /** |
| 342 * Adds a listener for the http cache info results. |
| 343 * The observer will be called back with: |
| 344 * |
| 345 * observer.onHttpCacheInfoReceived(info); |
| 346 */ |
| 347 BrowserBridge.prototype.addHttpCacheInfoObserver = function(observer) { |
| 348 this.httpCacheInfoObservers_.push(observer); |
| 349 }; |
| 350 |
| 351 /** |
328 * The browser gives us times in terms of "time ticks" in milliseconds. | 352 * The browser gives us times in terms of "time ticks" in milliseconds. |
329 * This function converts the tick count to a Date() object. | 353 * This function converts the tick count to a Date() object. |
330 * | 354 * |
331 * @param {String} timeTicks. | 355 * @param {String} timeTicks. |
332 * @returns {Date} The time that |timeTicks| represents. | 356 * @returns {Date} The time that |timeTicks| represents. |
333 */ | 357 */ |
334 BrowserBridge.prototype.convertTimeTicksToDate = function(timeTicks) { | 358 BrowserBridge.prototype.convertTimeTicksToDate = function(timeTicks) { |
335 // Note that the subtraction by 0 is to cast to a number (probably a float | 359 // Note that the subtraction by 0 is to cast to a number (probably a float |
336 // since the numbers are big). | 360 // since the numbers are big). |
337 var timeStampMs = (this.timeTickOffset_ - 0) + (timeTicks - 0); | 361 var timeStampMs = (this.timeTickOffset_ - 0) + (timeTicks - 0); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 if (prevData && JSON.stringify(prevData) == JSON.stringify(data)) | 417 if (prevData && JSON.stringify(prevData) == JSON.stringify(data)) |
394 return; | 418 return; |
395 | 419 |
396 this.currentData_ = data; | 420 this.currentData_ = data; |
397 | 421 |
398 // Ok, notify the observers of the change. | 422 // Ok, notify the observers of the change. |
399 for (var i = 0; i < this.observers_.length; ++i) | 423 for (var i = 0; i < this.observers_.length; ++i) |
400 var observer = this.observers_[i]; | 424 var observer = this.observers_[i]; |
401 observer[this.observerMethodName_](data); | 425 observer[this.observerMethodName_](data); |
402 }; | 426 }; |
OLD | NEW |