| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 // captured data. | 61 // captured data. |
| 62 var dataView = new DataView("dataTabContent", "exportedDataText", | 62 var dataView = new DataView("dataTabContent", "exportedDataText", |
| 63 "exportToText"); | 63 "exportToText"); |
| 64 | 64 |
| 65 // Create a view which will display the results and controls for connection | 65 // Create a view which will display the results and controls for connection |
| 66 // tests. | 66 // tests. |
| 67 var testView = new TestView("testTabContent", "testUrlInput", | 67 var testView = new TestView("testTabContent", "testUrlInput", |
| 68 "connectionTestsForm", "testSummary"); | 68 "connectionTestsForm", "testSummary"); |
| 69 | 69 |
| 70 var httpCacheView = new HttpCacheView("httpCacheTabContent", | 70 var httpCacheView = new HttpCacheView("httpCacheTabContent", |
| 71 "reloadHttpCacheListing", | 71 "httpCacheStats"); |
| 72 "httpCacheStats", | |
| 73 "httpCacheListing"); | |
| 74 | 72 |
| 75 // Create a view which lets you tab between the different sub-views. | 73 // Create a view which lets you tab between the different sub-views. |
| 76 var categoryTabSwitcher = | 74 var categoryTabSwitcher = |
| 77 new TabSwitcherView(new DivView('categoryTabHandles')); | 75 new TabSwitcherView(new DivView('categoryTabHandles')); |
| 78 | 76 |
| 79 // Populate the main tabs. | 77 // Populate the main tabs. |
| 80 categoryTabSwitcher.addTab('requestsTab', requestsView, false); | 78 categoryTabSwitcher.addTab('requestsTab', requestsView, false); |
| 81 categoryTabSwitcher.addTab('proxyTab', proxyView, false); | 79 categoryTabSwitcher.addTab('proxyTab', proxyView, false); |
| 82 categoryTabSwitcher.addTab('dnsTab', dnsView, false); | 80 categoryTabSwitcher.addTab('dnsTab', dnsView, false); |
| 83 categoryTabSwitcher.addTab('socketsTab', new DivView('socketsTabContent'), | 81 categoryTabSwitcher.addTab('socketsTab', new DivView('socketsTabContent'), |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 /** | 117 /** |
| 120 * This class provides a "bridge" for communicating between the javascript and | 118 * This class provides a "bridge" for communicating between the javascript and |
| 121 * the browser. | 119 * the browser. |
| 122 * | 120 * |
| 123 * @constructor | 121 * @constructor |
| 124 */ | 122 */ |
| 125 function BrowserBridge() { | 123 function BrowserBridge() { |
| 126 // List of observers for various bits of browser state. | 124 // List of observers for various bits of browser state. |
| 127 this.logObservers_ = []; | 125 this.logObservers_ = []; |
| 128 this.connectionTestsObservers_ = []; | 126 this.connectionTestsObservers_ = []; |
| 129 this.httpCacheInfoObservers_ = []; | |
| 130 this.proxySettings_ = new PollableDataHelper('onProxySettingsChanged'); | 127 this.proxySettings_ = new PollableDataHelper('onProxySettingsChanged'); |
| 131 this.badProxies_ = new PollableDataHelper('onBadProxiesChanged'); | 128 this.badProxies_ = new PollableDataHelper('onBadProxiesChanged'); |
| 129 this.httpCacheInfo_ = new PollableDataHelper('onHttpCacheInfoChanged'); |
| 132 this.hostResolverCache_ = | 130 this.hostResolverCache_ = |
| 133 new PollableDataHelper('onHostResolverCacheChanged'); | 131 new PollableDataHelper('onHostResolverCacheChanged'); |
| 134 | 132 |
| 135 // Cache of the data received. | 133 // Cache of the data received. |
| 136 // TODO(eroman): the controls to clear data in the "Requests" tab should be | 134 // TODO(eroman): the controls to clear data in the "Requests" tab should be |
| 137 // affecting this as well. | 135 // affecting this as well. |
| 138 this.passivelyCapturedEvents_ = []; | 136 this.passivelyCapturedEvents_ = []; |
| 139 this.activelyCapturedEvents_ = []; | 137 this.activelyCapturedEvents_ = []; |
| 140 } | 138 } |
| 141 | 139 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 info.experiment, info.result); | 263 info.experiment, info.result); |
| 266 } | 264 } |
| 267 }; | 265 }; |
| 268 | 266 |
| 269 BrowserBridge.prototype.receivedCompletedConnectionTestSuite = function() { | 267 BrowserBridge.prototype.receivedCompletedConnectionTestSuite = function() { |
| 270 for (var i = 0; i < this.connectionTestsObservers_.length; ++i) | 268 for (var i = 0; i < this.connectionTestsObservers_.length; ++i) |
| 271 this.connectionTestsObservers_[i].onCompletedConnectionTestSuite(); | 269 this.connectionTestsObservers_[i].onCompletedConnectionTestSuite(); |
| 272 }; | 270 }; |
| 273 | 271 |
| 274 BrowserBridge.prototype.receivedHttpCacheInfo = function(info) { | 272 BrowserBridge.prototype.receivedHttpCacheInfo = function(info) { |
| 275 for (var i = 0; i < this.httpCacheInfoObservers_.length; ++i) | 273 this.httpCacheInfo_.update(info); |
| 276 this.httpCacheInfoObservers_[i].onHttpCacheInfoReceived(info); | |
| 277 }; | 274 }; |
| 278 | 275 |
| 279 //------------------------------------------------------------------------------ | 276 //------------------------------------------------------------------------------ |
| 280 | 277 |
| 281 /** | 278 /** |
| 282 * Adds a listener of log entries. |observer| will be called back when new log | 279 * Adds a listener of log entries. |observer| will be called back when new log |
| 283 * data arrives, through: | 280 * data arrives, through: |
| 284 * | 281 * |
| 285 * observer.onLogEntryAdded(logEntry) | 282 * observer.onLogEntryAdded(logEntry) |
| 286 */ | 283 */ |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 * observer.onCompletedConnectionTestSuite(); | 333 * observer.onCompletedConnectionTestSuite(); |
| 337 */ | 334 */ |
| 338 BrowserBridge.prototype.addConnectionTestsObserver = function(observer) { | 335 BrowserBridge.prototype.addConnectionTestsObserver = function(observer) { |
| 339 this.connectionTestsObservers_.push(observer); | 336 this.connectionTestsObservers_.push(observer); |
| 340 }; | 337 }; |
| 341 | 338 |
| 342 /** | 339 /** |
| 343 * Adds a listener for the http cache info results. | 340 * Adds a listener for the http cache info results. |
| 344 * The observer will be called back with: | 341 * The observer will be called back with: |
| 345 * | 342 * |
| 346 * observer.onHttpCacheInfoReceived(info); | 343 * observer.onHttpCacheInfoChanged(info); |
| 347 */ | 344 */ |
| 348 BrowserBridge.prototype.addHttpCacheInfoObserver = function(observer) { | 345 BrowserBridge.prototype.addHttpCacheInfoObserver = function(observer) { |
| 349 this.httpCacheInfoObservers_.push(observer); | 346 this.httpCacheInfo_.addObserver(observer); |
| 350 }; | 347 }; |
| 351 | 348 |
| 352 /** | 349 /** |
| 353 * The browser gives us times in terms of "time ticks" in milliseconds. | 350 * The browser gives us times in terms of "time ticks" in milliseconds. |
| 354 * This function converts the tick count to a Date() object. | 351 * This function converts the tick count to a Date() object. |
| 355 * | 352 * |
| 356 * @param {String} timeTicks. | 353 * @param {String} timeTicks. |
| 357 * @returns {Date} The time that |timeTicks| represents. | 354 * @returns {Date} The time that |timeTicks| represents. |
| 358 */ | 355 */ |
| 359 BrowserBridge.prototype.convertTimeTicksToDate = function(timeTicks) { | 356 BrowserBridge.prototype.convertTimeTicksToDate = function(timeTicks) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 381 return this.passivelyCapturedEvents_; | 378 return this.passivelyCapturedEvents_; |
| 382 }; | 379 }; |
| 383 | 380 |
| 384 BrowserBridge.prototype.doPolling_ = function() { | 381 BrowserBridge.prototype.doPolling_ = function() { |
| 385 // TODO(eroman): Optimize this by using a separate polling frequency for the | 382 // TODO(eroman): Optimize this by using a separate polling frequency for the |
| 386 // data consumed by the currently active view. Everything else can be on a low | 383 // data consumed by the currently active view. Everything else can be on a low |
| 387 // frequency poll since it won't impact the display. | 384 // frequency poll since it won't impact the display. |
| 388 this.sendGetProxySettings(); | 385 this.sendGetProxySettings(); |
| 389 this.sendGetBadProxies(); | 386 this.sendGetBadProxies(); |
| 390 this.sendGetHostResolverCache(); | 387 this.sendGetHostResolverCache(); |
| 388 this.sendGetHttpCacheInfo(); |
| 391 }; | 389 }; |
| 392 | 390 |
| 393 /** | 391 /** |
| 394 * This is a helper class used by BrowserBridge, to keep track of: | 392 * This is a helper class used by BrowserBridge, to keep track of: |
| 395 * - the list of observers interested in some piece of data. | 393 * - the list of observers interested in some piece of data. |
| 396 * - the last known value of that piece of data. | 394 * - the last known value of that piece of data. |
| 397 * - the name of the callback method to invoke on observers. | 395 * - the name of the callback method to invoke on observers. |
| 398 * @constructor | 396 * @constructor |
| 399 */ | 397 */ |
| 400 function PollableDataHelper(observerMethodName) { | 398 function PollableDataHelper(observerMethodName) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 418 if (prevData && JSON.stringify(prevData) == JSON.stringify(data)) | 416 if (prevData && JSON.stringify(prevData) == JSON.stringify(data)) |
| 419 return; | 417 return; |
| 420 | 418 |
| 421 this.currentData_ = data; | 419 this.currentData_ = data; |
| 422 | 420 |
| 423 // Ok, notify the observers of the change. | 421 // Ok, notify the observers of the change. |
| 424 for (var i = 0; i < this.observers_.length; ++i) | 422 for (var i = 0; i < this.observers_.length; ++i) |
| 425 var observer = this.observers_[i]; | 423 var observer = this.observers_[i]; |
| 426 observer[this.observerMethodName_](data); | 424 observer[this.observerMethodName_](data); |
| 427 }; | 425 }; |
| OLD | NEW |