OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Populated by constants from the browser. Used only by this file. | 5 // Populated by constants from the browser. Used only by this file. |
6 var NetInfoSources = null; | 6 var NetInfoSources = null; |
7 | 7 |
8 /** | 8 /** |
9 * This class provides a "bridge" for communicating between the javascript and | 9 * This class provides a "bridge" for communicating between the javascript and |
10 * the browser. | 10 * the browser. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 this.addNetInfoPollableDataHelper('hostResolverInfo', | 45 this.addNetInfoPollableDataHelper('hostResolverInfo', |
46 'onHostResolverInfoChanged'); | 46 'onHostResolverInfoChanged'); |
47 this.addNetInfoPollableDataHelper('socketPoolInfo', | 47 this.addNetInfoPollableDataHelper('socketPoolInfo', |
48 'onSocketPoolInfoChanged'); | 48 'onSocketPoolInfoChanged'); |
49 this.addNetInfoPollableDataHelper('spdySessionInfo', | 49 this.addNetInfoPollableDataHelper('spdySessionInfo', |
50 'onSpdySessionInfoChanged'); | 50 'onSpdySessionInfoChanged'); |
51 this.addNetInfoPollableDataHelper('spdyStatus', 'onSpdyStatusChanged'); | 51 this.addNetInfoPollableDataHelper('spdyStatus', 'onSpdyStatusChanged'); |
52 this.addNetInfoPollableDataHelper('spdyAlternateProtocolMappings', | 52 this.addNetInfoPollableDataHelper('spdyAlternateProtocolMappings', |
53 'onSpdyAlternateProtocolMappingsChanged'); | 53 'onSpdyAlternateProtocolMappingsChanged'); |
54 this.addNetInfoPollableDataHelper('quicInfo', 'onQuicInfoChanged'); | 54 this.addNetInfoPollableDataHelper('quicInfo', 'onQuicInfoChanged'); |
55 this.addNetInfoPollableDataHelper('sdchInfo', 'onSdchInfoChanged'); | |
56 this.addNetInfoPollableDataHelper('httpCacheInfo', | 55 this.addNetInfoPollableDataHelper('httpCacheInfo', |
57 'onHttpCacheInfoChanged'); | 56 'onHttpCacheInfoChanged'); |
58 | 57 |
59 // Add other PollableDataHelpers. | 58 // Add other PollableDataHelpers. |
60 this.pollableDataHelpers_.sessionNetworkStats = | 59 this.pollableDataHelpers_.sessionNetworkStats = |
61 new PollableDataHelper('onSessionNetworkStatsChanged', | 60 new PollableDataHelper('onSessionNetworkStatsChanged', |
62 this.sendGetSessionNetworkStats.bind(this)); | 61 this.sendGetSessionNetworkStats.bind(this)); |
63 this.pollableDataHelpers_.historicNetworkStats = | 62 this.pollableDataHelpers_.historicNetworkStats = |
64 new PollableDataHelper('onHistoricNetworkStatsChanged', | 63 new PollableDataHelper('onHistoricNetworkStatsChanged', |
65 this.sendGetHistoricNetworkStats.bind(this)); | 64 this.sendGetHistoricNetworkStats.bind(this)); |
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 * observer.onSystemLogChanged(systemLogInfo) | 624 * observer.onSystemLogChanged(systemLogInfo) |
626 */ | 625 */ |
627 addSystemLogObserver: function(observer, ignoreWhenUnchanged) { | 626 addSystemLogObserver: function(observer, ignoreWhenUnchanged) { |
628 if (this.pollableDataHelpers_.systemLog) { | 627 if (this.pollableDataHelpers_.systemLog) { |
629 this.pollableDataHelpers_.systemLog.addObserver( | 628 this.pollableDataHelpers_.systemLog.addObserver( |
630 observer, ignoreWhenUnchanged); | 629 observer, ignoreWhenUnchanged); |
631 } | 630 } |
632 }, | 631 }, |
633 | 632 |
634 /** | 633 /** |
635 * Adds a listener of SDCH information. |observer| will be called | |
636 * back when data is received, through: | |
637 * | |
638 * observer.onSdchInfoChanged(sdchInfo) | |
639 */ | |
640 addSdchInfoObserver: function(observer, ignoreWhenUnchanged) { | |
641 this.pollableDataHelpers_.sdchInfo.addObserver( | |
642 observer, ignoreWhenUnchanged); | |
643 }, | |
644 | |
645 /** | |
646 * If |force| is true, calls all startUpdate functions. Otherwise, just | 634 * If |force| is true, calls all startUpdate functions. Otherwise, just |
647 * runs updates with active observers. | 635 * runs updates with active observers. |
648 */ | 636 */ |
649 checkForUpdatedInfo: function(force) { | 637 checkForUpdatedInfo: function(force) { |
650 for (var name in this.pollableDataHelpers_) { | 638 for (var name in this.pollableDataHelpers_) { |
651 var helper = this.pollableDataHelpers_[name]; | 639 var helper = this.pollableDataHelpers_[name]; |
652 if (force || helper.hasActiveObserver()) | 640 if (force || helper.hasActiveObserver()) |
653 helper.startUpdate(); | 641 helper.startUpdate(); |
654 } | 642 } |
655 }, | 643 }, |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 helper.removeObserver(this); | 791 helper.removeObserver(this); |
804 --this.observingCount_; | 792 --this.observingCount_; |
805 this.updatedData_[name] = data; | 793 this.updatedData_[name] = data; |
806 if (this.observingCount_ == 0) | 794 if (this.observingCount_ == 0) |
807 this.callback_(this.updatedData_); | 795 this.callback_(this.updatedData_); |
808 } | 796 } |
809 }; | 797 }; |
810 | 798 |
811 return BrowserBridge; | 799 return BrowserBridge; |
812 })(); | 800 })(); |
OLD | NEW |