forked from mirrors/gecko-dev
Bug 1321119 - Allow to Sync more tabs and reduce tabs history to 5. r=markh
MozReview-Commit-ID: 7kRg4XQeT4C --HG-- extra : rebase_source : 7558c92cc3fefe1ade2359008df9102f5ba72322
This commit is contained in:
parent
4b7b3d4092
commit
69b317e280
2 changed files with 9 additions and 6 deletions
|
|
@ -7,7 +7,7 @@ this.EXPORTED_SYMBOLS = ["TabEngine", "TabSetRecord"];
|
||||||
var {classes: Cc, interfaces: Ci, utils: Cu} = Components;
|
var {classes: Cc, interfaces: Ci, utils: Cu} = Components;
|
||||||
|
|
||||||
const TABS_TTL = 1814400; // 21 days.
|
const TABS_TTL = 1814400; // 21 days.
|
||||||
const TAB_ENTRIES_LIMIT = 25; // How many URLs to include in tab history.
|
const TAB_ENTRIES_LIMIT = 5; // How many URLs to include in tab history.
|
||||||
|
|
||||||
Cu.import("resource://gre/modules/Preferences.jsm");
|
Cu.import("resource://gre/modules/Preferences.jsm");
|
||||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||||
|
|
@ -209,11 +209,14 @@ TabStore.prototype = {
|
||||||
return b.lastUsed - a.lastUsed;
|
return b.lastUsed - a.lastUsed;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Figure out how many tabs we can pack into a payload. Starting with a 28KB
|
// Figure out how many tabs we can pack into a payload.
|
||||||
// payload, we can estimate various overheads from encryption/JSON/WBO.
|
// See bug 535326 comment 8 for an explanation of the estimation
|
||||||
|
// If the server configuration is absent, we use the old max payload size of 28K
|
||||||
let size = JSON.stringify(tabs).length;
|
let size = JSON.stringify(tabs).length;
|
||||||
let origLength = tabs.length;
|
let origLength = tabs.length;
|
||||||
const MAX_TAB_SIZE = 20000;
|
const MAX_TAB_SIZE = (this.engine.service.serverConfiguration ?
|
||||||
|
this.engine.service.serverConfiguration.max_record_payload_bytes :
|
||||||
|
28672) / 4 * 3 - 1500;
|
||||||
if (size > MAX_TAB_SIZE) {
|
if (size > MAX_TAB_SIZE) {
|
||||||
// Estimate a little more than the direct fraction to maximize packing
|
// Estimate a little more than the direct fraction to maximize packing
|
||||||
let cutoff = Math.ceil(tabs.length * MAX_TAB_SIZE / size);
|
let cutoff = Math.ceil(tabs.length * MAX_TAB_SIZE / size);
|
||||||
|
|
|
||||||
|
|
@ -80,9 +80,9 @@ function test_getAllTabs() {
|
||||||
|
|
||||||
_("Sliced: " + JSON.stringify(tabs));
|
_("Sliced: " + JSON.stringify(tabs));
|
||||||
equal(tabs.length, 1);
|
equal(tabs.length, 1);
|
||||||
equal(tabs[0].urlHistory.length, 25);
|
equal(tabs[0].urlHistory.length, 5);
|
||||||
equal(tabs[0].urlHistory[0], "http://foo40.bar");
|
equal(tabs[0].urlHistory[0], "http://foo40.bar");
|
||||||
equal(tabs[0].urlHistory[24], "http://foo16.bar");
|
equal(tabs[0].urlHistory[4], "http://foo36.bar");
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_createRecord() {
|
function test_createRecord() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue