Chromium Code Reviews| 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 ClientInfo = null; | 10 var ClientInfo = null; |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 182 if (this.isPlatformWindows()) { | 182 if (this.isPlatformWindows()) { |
| 183 this.pollableDataHelpers_.serviceProviders = | 183 this.pollableDataHelpers_.serviceProviders = |
| 184 new PollableDataHelper('onServiceProvidersChanged', | 184 new PollableDataHelper('onServiceProvidersChanged', |
| 185 this.sendGetServiceProviders.bind(this)); | 185 this.sendGetServiceProviders.bind(this)); |
| 186 } | 186 } |
| 187 | 187 |
| 188 // Cache of the data received. | 188 // Cache of the data received. |
| 189 this.numPassivelyCapturedEvents_ = 0; | 189 this.numPassivelyCapturedEvents_ = 0; |
| 190 this.capturedEvents_ = []; | 190 this.capturedEvents_ = []; |
| 191 | 191 |
| 192 // It's possible for a few actively captured events to be received before any | |
| 193 // passively captured events. When this happens, the actively captured | |
| 194 // events aren't processed until after the passively captured events have been | |
| 195 // received. | |
| 196 this.receivedPassivelyCapturedEvents_ = false; | |
| 197 this.delayedActivelyCapturedEvents_ = []; | |
| 198 | |
| 192 // Next unique id to be assigned to a log entry without a source. | 199 // Next unique id to be assigned to a log entry without a source. |
| 193 // Needed to simplify deletion, identify associated GUI elements, etc. | 200 // Needed to simplify deletion, identify associated GUI elements, etc. |
| 194 this.nextSourcelessEventId_ = -1; | 201 this.nextSourcelessEventId_ = -1; |
| 195 } | 202 } |
| 196 | 203 |
| 197 /* | 204 /* |
| 198 * Takes the current hash in form of "#tab¶m1=value1¶m2=value2&...". | 205 * Takes the current hash in form of "#tab¶m1=value1¶m2=value2&...". |
| 199 * Puts the parameters in an object, and passes the resulting object to | 206 * Puts the parameters in an object, and passes the resulting object to |
| 200 * |categoryTabSwitcher|. Uses tab and |anchorMap| to find a tab ID, | 207 * |categoryTabSwitcher|. Uses tab and |anchorMap| to find a tab ID, |
| 201 * which it also passes to the tab switcher. | 208 * which it also passes to the tab switcher. |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 301 | 308 |
| 302 BrowserBridge.prototype.setLogLevel = function(logLevel) { | 309 BrowserBridge.prototype.setLogLevel = function(logLevel) { |
| 303 chrome.send('setLogLevel', ['' + logLevel]); | 310 chrome.send('setLogLevel', ['' + logLevel]); |
| 304 } | 311 } |
| 305 | 312 |
| 306 //------------------------------------------------------------------------------ | 313 //------------------------------------------------------------------------------ |
| 307 // Messages received from the browser | 314 // Messages received from the browser |
| 308 //------------------------------------------------------------------------------ | 315 //------------------------------------------------------------------------------ |
| 309 | 316 |
| 310 BrowserBridge.prototype.receivedLogEntry = function(logEntry) { | 317 BrowserBridge.prototype.receivedLogEntry = function(logEntry) { |
| 311 // Silently drop entries received before ready to receive them. | 318 // Delay processing any active events received before passive events. |
| 312 if (!this.areLogTypesReady_()) | 319 if (!this.receivedPassivelyCapturedEvents_) { |
|
eroman
2010/11/18 18:04:03
What I don't like about this approach, is we pay a
mmenke
2010/11/23 16:48:45
Don't really like the idea of starting to populate
| |
| 320 this.delayedActivelyCapturedEvents_.push(logEntry); | |
| 313 return; | 321 return; |
| 322 } | |
| 314 // Assign unique ID, if needed. | 323 // Assign unique ID, if needed. |
| 315 if (logEntry.source.id == 0) { | 324 if (logEntry.source.id == 0) { |
| 316 logEntry.source.id = this.nextSourcelessEventId_; | 325 logEntry.source.id = this.nextSourcelessEventId_; |
| 317 --this.nextSourcelessEventId_; | 326 --this.nextSourcelessEventId_; |
| 318 } | 327 } |
| 319 this.capturedEvents_.push(logEntry); | 328 this.capturedEvents_.push(logEntry); |
| 320 for (var i = 0; i < this.logObservers_.length; ++i) | 329 for (var i = 0; i < this.logObservers_.length; ++i) |
| 321 this.logObservers_[i].onLogEntryAdded(logEntry); | 330 this.logObservers_[i].onLogEntryAdded(logEntry); |
| 322 }; | 331 }; |
| 323 | 332 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 382 BrowserBridge.prototype.receivedSpdySessionInfo = function(spdySessionInfo) { | 391 BrowserBridge.prototype.receivedSpdySessionInfo = function(spdySessionInfo) { |
| 383 this.pollableDataHelpers_.spdySessionInfo.update(spdySessionInfo); | 392 this.pollableDataHelpers_.spdySessionInfo.update(spdySessionInfo); |
| 384 }; | 393 }; |
| 385 | 394 |
| 386 BrowserBridge.prototype.receivedServiceProviders = function(serviceProviders) { | 395 BrowserBridge.prototype.receivedServiceProviders = function(serviceProviders) { |
| 387 this.pollableDataHelpers_.serviceProviders.update(serviceProviders); | 396 this.pollableDataHelpers_.serviceProviders.update(serviceProviders); |
| 388 }; | 397 }; |
| 389 | 398 |
| 390 BrowserBridge.prototype.receivedPassiveLogEntries = function(entries) { | 399 BrowserBridge.prototype.receivedPassiveLogEntries = function(entries) { |
| 391 this.numPassivelyCapturedEvents_ += entries.length; | 400 this.numPassivelyCapturedEvents_ += entries.length; |
| 401 this.receivedPassivelyCapturedEvents_ = true; | |
| 392 for (var i = 0; i < entries.length; ++i) { | 402 for (var i = 0; i < entries.length; ++i) { |
| 393 var entry = entries[i]; | 403 var entry = entries[i]; |
| 394 entry.wasPassivelyCaptured = true; | 404 entry.wasPassivelyCaptured = true; |
| 395 this.receivedLogEntry(entry); | 405 this.receivedLogEntry(entry); |
| 396 } | 406 } |
| 407 // Handle delayed actively captured events, if any. | |
| 408 for (var i = 0; i < this.delayedActivelyCapturedEvents_.length; ++i) { | |
| 409 this.receivedLogEntry(this.delayedActivelyCapturedEvents_[i]); | |
| 410 } | |
| 411 this.delayedActivelyCapturedEvents_ = []; | |
| 397 }; | 412 }; |
| 398 | 413 |
| 399 | 414 |
| 400 BrowserBridge.prototype.receivedStartConnectionTestSuite = function() { | 415 BrowserBridge.prototype.receivedStartConnectionTestSuite = function() { |
| 401 for (var i = 0; i < this.connectionTestsObservers_.length; ++i) | 416 for (var i = 0; i < this.connectionTestsObservers_.length; ++i) |
| 402 this.connectionTestsObservers_[i].onStartedConnectionTestSuite(); | 417 this.connectionTestsObservers_[i].onStartedConnectionTestSuite(); |
| 403 }; | 418 }; |
| 404 | 419 |
| 405 BrowserBridge.prototype.receivedStartConnectionTestExperiment = function( | 420 BrowserBridge.prototype.receivedStartConnectionTestExperiment = function( |
| 406 experiment) { | 421 experiment) { |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 420 | 435 |
| 421 BrowserBridge.prototype.receivedCompletedConnectionTestSuite = function() { | 436 BrowserBridge.prototype.receivedCompletedConnectionTestSuite = function() { |
| 422 for (var i = 0; i < this.connectionTestsObservers_.length; ++i) | 437 for (var i = 0; i < this.connectionTestsObservers_.length; ++i) |
| 423 this.connectionTestsObservers_[i].onCompletedConnectionTestSuite(); | 438 this.connectionTestsObservers_[i].onCompletedConnectionTestSuite(); |
| 424 }; | 439 }; |
| 425 | 440 |
| 426 BrowserBridge.prototype.receivedHttpCacheInfo = function(info) { | 441 BrowserBridge.prototype.receivedHttpCacheInfo = function(info) { |
| 427 this.pollableDataHelpers_.httpCacheInfo.update(info); | 442 this.pollableDataHelpers_.httpCacheInfo.update(info); |
| 428 }; | 443 }; |
| 429 | 444 |
| 430 BrowserBridge.prototype.areLogTypesReady_ = function() { | |
| 431 return (LogEventType != null && | |
| 432 LogEventPhase != null && | |
| 433 LogSourceType != null); | |
| 434 }; | |
| 435 | |
| 436 //------------------------------------------------------------------------------ | 445 //------------------------------------------------------------------------------ |
| 437 | 446 |
| 438 /** | 447 /** |
| 439 * Adds a listener of log entries. |observer| will be called back when new log | 448 * Adds a listener of log entries. |observer| will be called back when new log |
| 440 * data arrives, through: | 449 * data arrives, through: |
| 441 * | 450 * |
| 442 * observer.onLogEntryAdded(logEntry) | 451 * observer.onLogEntryAdded(logEntry) |
| 443 */ | 452 */ |
| 444 BrowserBridge.prototype.addLogObserver = function(observer) { | 453 BrowserBridge.prototype.addLogObserver = function(observer) { |
| 445 this.logObservers_.push(observer); | 454 this.logObservers_.push(observer); |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 749 return true; | 758 return true; |
| 750 }; | 759 }; |
| 751 | 760 |
| 752 UpdateAllObserver.prototype.onDataReceived_ = function(helper, name, data) { | 761 UpdateAllObserver.prototype.onDataReceived_ = function(helper, name, data) { |
| 753 helper.removeObserver(this); | 762 helper.removeObserver(this); |
| 754 --this.observingCount_; | 763 --this.observingCount_; |
| 755 this.updatedData_[name] = data; | 764 this.updatedData_[name] = data; |
| 756 if (this.observingCount_ == 0) | 765 if (this.observingCount_ == 0) |
| 757 this.callback_(this.updatedData_); | 766 this.callback_(this.updatedData_); |
| 758 }; | 767 }; |
| OLD | NEW |