mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-21 07:38:07 +02:00
Make the view history cache size configurable during initialization
This commit is contained in:
parent
7681def0de
commit
55870788e5
1 changed files with 4 additions and 3 deletions
|
@ -18,7 +18,7 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
var VIEW_HISTORY_MEMORY = 20;
|
||||
var DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20;
|
||||
|
||||
/**
|
||||
* View History - This is a utility for saving various view parameters for
|
||||
|
@ -30,8 +30,9 @@ var VIEW_HISTORY_MEMORY = 20;
|
|||
* - GENERIC or CHROME - uses localStorage, if it is available.
|
||||
*/
|
||||
var ViewHistory = (function ViewHistoryClosure() {
|
||||
function ViewHistory(fingerprint) {
|
||||
function ViewHistory(fingerprint, cacheSize) {
|
||||
this.fingerprint = fingerprint;
|
||||
this.cacheSize = cacheSize || DEFAULT_VIEW_HISTORY_CACHE_SIZE;
|
||||
this.isInitializedPromiseResolved = false;
|
||||
this.initializedPromise =
|
||||
this._readFromStorage().then(function (databaseStr) {
|
||||
|
@ -41,7 +42,7 @@ var ViewHistory = (function ViewHistoryClosure() {
|
|||
if (!('files' in database)) {
|
||||
database.files = [];
|
||||
}
|
||||
if (database.files.length >= VIEW_HISTORY_MEMORY) {
|
||||
if (database.files.length >= this.cacheSize) {
|
||||
database.files.shift();
|
||||
}
|
||||
var index;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue