0

[pdf] Reset defer_page_unload to original value.

In the PdfiumEngine::GetMostVisiblePage() we force the system to defer page
unloading because it can be called during a callback. That callback can be
triggered from a ::HandleEvent() call. Currently we will always reset the
defer_page_unload_ to false in ::GetMostVisiblePage().

This Cl updates the code to reset defer_page_unload_ to the value it contained
prior to the call to ::GetMostVisiblePage().

Review-Url: https://codereview.chromium.org/2554563002
Cr-Commit-Position: refs/heads/master@{#436590}
This commit is contained in:
dsinclair
2016-12-06 06:33:18 -08:00
committed by Commit bot
parent 1827c4378b
commit 8e36ea8099

@ -12,6 +12,7 @@
#include <memory>
#include <set>
#include "base/auto_reset.h"
#include "base/i18n/encoding_detection.h"
#include "base/i18n/icu_string_conversions.h"
#include "base/lazy_instance.h"
@ -2470,9 +2471,8 @@ int PDFiumEngine::GetMostVisiblePage() {
// to defer the page deletion otherwise we could potentially delete the page
// that originated the calling JS request and destroy the objects that are
// currently being used.
defer_page_unload_ = true;
base::AutoReset<bool> defer_page_unload_guard(&defer_page_unload_, true);
CalculateVisiblePages();
defer_page_unload_ = false;
return most_visible_page_;
}