Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor how the database is read in ViewHistory #4705

Merged
merged 2 commits into from
Apr 29, 2014
Merged

Refactor how the database is read in ViewHistory #4705

merged 2 commits into from
Apr 29, 2014

Conversation

Snuffleupagus
Copy link
Collaborator

This PR re-factors ViewHistory so that reading stored values returns a Promise. It should thus handle any possible errors when either sessionStorage or localStorage fails (e.g. bug 1000777 and #4690).

My goal with this PR was to address #4679 (comment), so the ViewHistory will now fail to initialize when the database cannot be read.
As part of the re-factoring I've also taken the opportunity to simplify the, in my opinion, quite clunky initialization code.
I didn't want to touch too much code, so I refrained from rewriting the entire ViewHistory to be Promise friendly and just settled for the necessary part.

Also fixes #4690 (by courtesy of the first commit).

// // See comment in try-catch block above.
// sessionStorage.setItem('pdfjsHistory', databaseStr);
// } catch (ex) {}
// sessionStorage.setItem('pdfjsHistory', databaseStr);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually removing try-catch here might not have been such a great idea, given that the preference network.cookie.lifetimePolicy could change after the viewer was loaded. (There should probably be a try-catch around the localStorage.setItem call 4 lines down too.)

Another, better (?), solution might be to add a Promise in _writeToStorage as well. Opinions?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

solution might be to add a Promise in _writeToStorage as well

yes we should

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've addressed this, but the question is how far we want to go?
If we want to make ViewHistory completely async that might be better to do in yet another PR, since the diff in this one is becoming quite messy already.

@yurydelendik
Copy link
Contributor

/botio-linux preview

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

Command cmd_preview from @yurydelendik received. Current queue size: 0

Live output at: http://107.21.233.14:8877/c1ea9310a9f399f/output.txt

yurydelendik added a commit that referenced this pull request Apr 29, 2014
Refactor how the database is read in ViewHistory
@yurydelendik yurydelendik merged commit 6a800eb into mozilla:master Apr 29, 2014
@yurydelendik
Copy link
Contributor

Thank you for the patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Firefox] The generic viewer fails when the preference 'network.cookie.lifetimePolicy' is set to 1
3 participants