Skip to content

Commit

Permalink
Better expose PDFiumEngine::plugin_size() callers that fail DCHECK
Browse files Browse the repository at this point in the history
Use DUMP_WILL_BE_NOTREACHED() in PDFiumEngine::plugin_size() instead of
a DCHECK(), so that the DCHECK() failures consistently generate
non-fatal dumped in all builds. Temporarily un-inline plugin_size() to
avoid putting more code into the header.

Bug: 40193305
Change-Id: I92459e6d36fe33d296404486dd4b93615113a719
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5618930
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Alan Screen <awscreen@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1313170}
  • Loading branch information
leizleiz authored and pull[bot] committed Jun 13, 2024
1 parent 7368844 commit 1330244
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
9 changes: 9 additions & 0 deletions pdf/pdfium/pdfium_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2719,6 +2719,15 @@ void PDFiumEngine::AppendBlankPages(size_t num_pages) {
LoadPageInfo();
}

gfx::Size PDFiumEngine::plugin_size() const {
if (plugin_size_.has_value()) {
return plugin_size_.value();
}
// TODO(crbug.com/40193305): Fix call sites and inline this getter again.
DUMP_WILL_BE_NOTREACHED();
return gfx::Size();
}

void PDFiumEngine::LoadDocument() {
// Check if the document is ready for loading. If it isn't just bail for now,
// we will call LoadDocument() again later.
Expand Down
7 changes: 1 addition & 6 deletions pdf/pdfium/pdfium_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include <string>
#include <vector>

#include "base/check.h"
#include "base/containers/flat_map.h"
#include "base/containers/span.h"
#include "base/memory/raw_ptr.h"
Expand Down Expand Up @@ -279,11 +278,7 @@ class PDFiumEngine : public PDFEngine,
friend class PDFiumTestBase;
friend class SelectionChangeInvalidator;

gfx::Size plugin_size() const {
// TODO(crbug.com/40193305): Just use .value() after fixing call sites.
DCHECK(plugin_size_.has_value());
return plugin_size_.value_or(gfx::Size());
}
gfx::Size plugin_size() const;

// We finished getting the pdf file, so load it. This will complete
// asynchronously (due to password fetching) and may be run multiple times.
Expand Down

0 comments on commit 1330244

Please sign in to comment.