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

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

Issue 4118004: Update NetLog to be thread safe. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Final sync with trunk Created 10 years 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
« no previous file with comments | « chrome/browser/policy/device_management_backend_impl.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 301
302 BrowserBridge.prototype.setLogLevel = function(logLevel) { 302 BrowserBridge.prototype.setLogLevel = function(logLevel) {
303 chrome.send('setLogLevel', ['' + logLevel]); 303 chrome.send('setLogLevel', ['' + logLevel]);
304 } 304 }
305 305
306 //------------------------------------------------------------------------------ 306 //------------------------------------------------------------------------------
307 // Messages received from the browser 307 // Messages received from the browser
308 //------------------------------------------------------------------------------ 308 //------------------------------------------------------------------------------
309 309
310 BrowserBridge.prototype.receivedLogEntry = function(logEntry) { 310 BrowserBridge.prototype.receivedLogEntry = function(logEntry) {
311 // Silently drop entries received before ready to receive them.
312 if (!this.areLogTypesReady_())
313 return;
314 // Assign unique ID, if needed. 311 // Assign unique ID, if needed.
315 if (logEntry.source.id == 0) { 312 if (logEntry.source.id == 0) {
316 logEntry.source.id = this.nextSourcelessEventId_; 313 logEntry.source.id = this.nextSourcelessEventId_;
317 --this.nextSourcelessEventId_; 314 --this.nextSourcelessEventId_;
318 } 315 }
319 this.capturedEvents_.push(logEntry); 316 this.capturedEvents_.push(logEntry);
320 for (var i = 0; i < this.logObservers_.length; ++i) 317 for (var i = 0; i < this.logObservers_.length; ++i)
321 this.logObservers_[i].onLogEntryAdded(logEntry); 318 this.logObservers_[i].onLogEntryAdded(logEntry);
322 }; 319 };
323 320
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 378
382 BrowserBridge.prototype.receivedSpdySessionInfo = function(spdySessionInfo) { 379 BrowserBridge.prototype.receivedSpdySessionInfo = function(spdySessionInfo) {
383 this.pollableDataHelpers_.spdySessionInfo.update(spdySessionInfo); 380 this.pollableDataHelpers_.spdySessionInfo.update(spdySessionInfo);
384 }; 381 };
385 382
386 BrowserBridge.prototype.receivedServiceProviders = function(serviceProviders) { 383 BrowserBridge.prototype.receivedServiceProviders = function(serviceProviders) {
387 this.pollableDataHelpers_.serviceProviders.update(serviceProviders); 384 this.pollableDataHelpers_.serviceProviders.update(serviceProviders);
388 }; 385 };
389 386
390 BrowserBridge.prototype.receivedPassiveLogEntries = function(entries) { 387 BrowserBridge.prototype.receivedPassiveLogEntries = function(entries) {
391 this.numPassivelyCapturedEvents_ += entries.length; 388 // Due to an expected race condition, it is possible to receive actively
389 // captured log entries before the passively logged entries are received.
390 //
391 // When that happens, we create a copy of the actively logged entries, delete
392 // all entries, and, after handling all the passively logged entries, add back
393 // the deleted actively logged entries.
394 var earlyActivelyCapturedEvents = this.capturedEvents_.slice(0);
395 if (earlyActivelyCapturedEvents.length > 0)
396 this.deleteAllEvents();
397
398 this.numPassivelyCapturedEvents_ = entries.length;
392 for (var i = 0; i < entries.length; ++i) { 399 for (var i = 0; i < entries.length; ++i) {
393 var entry = entries[i]; 400 var entry = entries[i];
394 entry.wasPassivelyCaptured = true; 401 entry.wasPassivelyCaptured = true;
395 this.receivedLogEntry(entry); 402 this.receivedLogEntry(entry);
396 } 403 }
404
405 // Add back early actively captured events, if any.
406 for (var i = 0; i < earlyActivelyCapturedEvents.length; ++i) {
407 this.receivedLogEntry(earlyActivelyCapturedEvents[i]);
408 }
397 }; 409 };
398 410
399 411
400 BrowserBridge.prototype.receivedStartConnectionTestSuite = function() { 412 BrowserBridge.prototype.receivedStartConnectionTestSuite = function() {
401 for (var i = 0; i < this.connectionTestsObservers_.length; ++i) 413 for (var i = 0; i < this.connectionTestsObservers_.length; ++i)
402 this.connectionTestsObservers_[i].onStartedConnectionTestSuite(); 414 this.connectionTestsObservers_[i].onStartedConnectionTestSuite();
403 }; 415 };
404 416
405 BrowserBridge.prototype.receivedStartConnectionTestExperiment = function( 417 BrowserBridge.prototype.receivedStartConnectionTestExperiment = function(
406 experiment) { 418 experiment) {
(...skipping 13 matching lines...) Expand all
420 432
421 BrowserBridge.prototype.receivedCompletedConnectionTestSuite = function() { 433 BrowserBridge.prototype.receivedCompletedConnectionTestSuite = function() {
422 for (var i = 0; i < this.connectionTestsObservers_.length; ++i) 434 for (var i = 0; i < this.connectionTestsObservers_.length; ++i)
423 this.connectionTestsObservers_[i].onCompletedConnectionTestSuite(); 435 this.connectionTestsObservers_[i].onCompletedConnectionTestSuite();
424 }; 436 };
425 437
426 BrowserBridge.prototype.receivedHttpCacheInfo = function(info) { 438 BrowserBridge.prototype.receivedHttpCacheInfo = function(info) {
427 this.pollableDataHelpers_.httpCacheInfo.update(info); 439 this.pollableDataHelpers_.httpCacheInfo.update(info);
428 }; 440 };
429 441
430 BrowserBridge.prototype.areLogTypesReady_ = function() {
431 return (LogEventType != null &&
432 LogEventPhase != null &&
433 LogSourceType != null);
434 };
435
436 //------------------------------------------------------------------------------ 442 //------------------------------------------------------------------------------
437 443
438 /** 444 /**
439 * Adds a listener of log entries. |observer| will be called back when new log 445 * Adds a listener of log entries. |observer| will be called back when new log
440 * data arrives, through: 446 * data arrives, through:
441 * 447 *
442 * observer.onLogEntryAdded(logEntry) 448 * observer.onLogEntryAdded(logEntry)
443 */ 449 */
444 BrowserBridge.prototype.addLogObserver = function(observer) { 450 BrowserBridge.prototype.addLogObserver = function(observer) {
445 this.logObservers_.push(observer); 451 this.logObservers_.push(observer);
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 return true; 755 return true;
750 }; 756 };
751 757
752 UpdateAllObserver.prototype.onDataReceived_ = function(helper, name, data) { 758 UpdateAllObserver.prototype.onDataReceived_ = function(helper, name, data) {
753 helper.removeObserver(this); 759 helper.removeObserver(this);
754 --this.observingCount_; 760 --this.observingCount_;
755 this.updatedData_[name] = data; 761 this.updatedData_[name] = data;
756 if (this.observingCount_ == 0) 762 if (this.observingCount_ == 0)
757 this.callback_(this.updatedData_); 763 this.callback_(this.updatedData_);
758 }; 764 };
OLDNEW
« no previous file with comments | « chrome/browser/policy/device_management_backend_impl.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698