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'); |
55 this.addNetInfoPollableDataHelper('httpCacheInfo', | 56 this.addNetInfoPollableDataHelper('httpCacheInfo', |
56 'onHttpCacheInfoChanged'); | 57 'onHttpCacheInfoChanged'); |
57 | 58 |
58 // Add other PollableDataHelpers. | 59 // Add other PollableDataHelpers. |
59 this.pollableDataHelpers_.sessionNetworkStats = | 60 this.pollableDataHelpers_.sessionNetworkStats = |
60 new PollableDataHelper('onSessionNetworkStatsChanged', | 61 new PollableDataHelper('onSessionNetworkStatsChanged', |
61 this.sendGetSessionNetworkStats.bind(this)); | 62 this.sendGetSessionNetworkStats.bind(this)); |
62 this.pollableDataHelpers_.historicNetworkStats = | 63 this.pollableDataHelpers_.historicNetworkStats = |
63 new PollableDataHelper('onHistoricNetworkStatsChanged', | 64 new PollableDataHelper('onHistoricNetworkStatsChanged', |
64 this.sendGetHistoricNetworkStats.bind(this)); | 65 this.sendGetHistoricNetworkStats.bind(this)); |
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 * observer.onSystemLogChanged(systemLogInfo) | 625 * observer.onSystemLogChanged(systemLogInfo) |
625 */ | 626 */ |
626 addSystemLogObserver: function(observer, ignoreWhenUnchanged) { | 627 addSystemLogObserver: function(observer, ignoreWhenUnchanged) { |
627 if (this.pollableDataHelpers_.systemLog) { | 628 if (this.pollableDataHelpers_.systemLog) { |
628 this.pollableDataHelpers_.systemLog.addObserver( | 629 this.pollableDataHelpers_.systemLog.addObserver( |
629 observer, ignoreWhenUnchanged); | 630 observer, ignoreWhenUnchanged); |
630 } | 631 } |
631 }, | 632 }, |
632 | 633 |
633 /** | 634 /** |
| 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 /** |
634 * If |force| is true, calls all startUpdate functions. Otherwise, just | 646 * If |force| is true, calls all startUpdate functions. Otherwise, just |
635 * runs updates with active observers. | 647 * runs updates with active observers. |
636 */ | 648 */ |
637 checkForUpdatedInfo: function(force) { | 649 checkForUpdatedInfo: function(force) { |
638 for (var name in this.pollableDataHelpers_) { | 650 for (var name in this.pollableDataHelpers_) { |
639 var helper = this.pollableDataHelpers_[name]; | 651 var helper = this.pollableDataHelpers_[name]; |
640 if (force || helper.hasActiveObserver()) | 652 if (force || helper.hasActiveObserver()) |
641 helper.startUpdate(); | 653 helper.startUpdate(); |
642 } | 654 } |
643 }, | 655 }, |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
791 helper.removeObserver(this); | 803 helper.removeObserver(this); |
792 --this.observingCount_; | 804 --this.observingCount_; |
793 this.updatedData_[name] = data; | 805 this.updatedData_[name] = data; |
794 if (this.observingCount_ == 0) | 806 if (this.observingCount_ == 0) |
795 this.callback_(this.updatedData_); | 807 this.callback_(this.updatedData_); |
796 } | 808 } |
797 }; | 809 }; |
798 | 810 |
799 return BrowserBridge; | 811 return BrowserBridge; |
800 })(); | 812 })(); |
OLD | NEW |