Add PrintedDocument::HasDebugDumpPath().
Unlike the current checks for the debug dump path, HasDebugDumpPath()
is truly read only and won't create the base::FilePath when accessing
the |g_debug_dump_info| base::LazyInstance.
Update code to use HasDebugDumpPath() instead of accessing
|g_debug_dump_info| directly, and only do that when getting / setting
the path value.
Change-Id: I200664a9cb70289883627c8dc7f85c6f02edd45b
Reviewed-on: https://chromium-review.googlesource.com/821370
Reviewed-by: Rebekah Potter <[email protected]>
Commit-Queue: Lei Zhang <[email protected]>
Cr-Commit-Position: refs/heads/master@{#523356}
diff --git a/printing/printing_context_win.cc b/printing/printing_context_win.cc
index 402d55f5..a8359e6 100644
--- a/printing/printing_context_win.cc
+++ b/printing/printing_context_win.cc
@@ -263,11 +263,12 @@
di.lpszDocName = document_name.c_str();
// Is there a debug dump directory specified? If so, force to print to a file.
- base::string16 debug_dump_path =
- PrintedDocument::CreateDebugDumpPath(document_name,
- FILE_PATH_LITERAL(".prn")).value();
- if (!debug_dump_path.empty())
- di.lpszOutput = debug_dump_path.c_str();
+ if (PrintedDocument::HasDebugDumpPath()) {
+ base::FilePath debug_dump_path = PrintedDocument::CreateDebugDumpPath(
+ document_name, FILE_PATH_LITERAL(".prn"));
+ if (!debug_dump_path.empty())
+ di.lpszOutput = debug_dump_path.value().c_str();
+ }
// No message loop running in unit tests.
DCHECK(!base::MessageLoop::current() ||