Changeset 872

Show
Ignore:
Timestamp:
2008-03-12 00:01:22 (2 years ago)
Author:
MaierMan
Message:

#604: Reset connection prefs when no longer needed.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/chrome/content/dta/manager.js

    r867 r872  
    488488        unload: function D_unload() { 
    489489                TimerManager.killAll(); 
     490                Prefs.shutdown(); 
    490491                try { 
    491492                        this._cleanTmpDir(); 
  • trunk/chrome/content/dta/manager/prefs.js

    r827 r872  
    6363        // nsIObserver 
    6464        observe: function(subject, topic, prefName) { 
    65                 this._refreshPrefs(); 
     65                this._refreshPrefs(prefName); 
    6666        }, 
    6767 
     
    7070 
    7171                try { 
     72                        this._resetConnPrefs(); 
    7273                        this._refreshPrefs(); 
    7374                        Preferences.addObserver('extensions.dta.', this); 
     
    7980        }, 
    8081 
    81         _refreshPrefs: function() { 
     82        _refreshPrefs: function(prefName) { 
    8283                Debug.logString("pref reload"); 
    8384                this.mappings.forEach( 
     
    137138                        this.tempLocation = null; 
    138139                } 
    139                 var conns = (this.maxInProgress * this.maxChunks + 2) * 2; 
    140                 ['network.http.max-connections', 'network.http.max-connections-per-server', 'network.http.max-persistent-connections-per-server'].forEach( 
     140                var conns = (this.maxInProgress * this.maxChunks) + 2; 
     141                ['network.http.max-connections', 'network.http.max-connections-per-server'].forEach( 
    141142                        function(e) { 
     143                                if ((!prefName || prefName == e) && conns != Preferences.get(e, conns)) { 
     144                                        Preferences.setDTA(e, Preferences.get(e, conns)); 
     145                                }                                
    142146                                if (conns > Preferences.get(e, conns)) { 
    143147                                        Preferences.set(e, conns); 
    144148                                } 
    145                                 conns /= 2; 
     149                                conns = Math.floor(conns / 1.5); 
     150                        } 
     151                ); 
     152        }, 
     153        shutdown: function() { 
     154                Preferences.removeObserver('network.', this); 
     155                this._resetConnPrefs(); 
     156        }, 
     157        _resetConnPrefs: function() { 
     158                ['network.http.max-connections', 'network.http.max-connections-per-server'].forEach( 
     159                        function(e) { 
     160                                let conn = Preferences.getDTA(e, 0); 
     161                                if (conn) { 
     162                                        Preferences.set(e, conn); 
     163                                        Preferences.setDTA(e, 0); 
     164                                } 
    146165                        } 
    147166                );