Commit e7a8dba5 authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

Fix sequencing in PrintDialogGtk.

In https://crrev.com/751341, the DCHECK for which sequence
PrintDialogGtk::PrintDocument() runs on accidentally got negated.
As a result, it also posted a task for SendDocumentToPrinter() on the
wrong sequence.

Fix the DCHECK in PrintDocument() to match the comment right above it,
and post the SendDocumentToPrinter() task to the right sequence. To do
so, take advantage of the fact that PrintDialogGtk inherits from
base::RefCountedDeleteOnSequence(), so it already knows what sequence it
lives on. Thus it does not need a separate base::SequenceChecker.

Bug: 1082740
Change-Id: I632527fe7ae63c5ecb2bb954c50f3df62d398684
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2228113Reviewed-by: default avatarThomas Anderson <thomasanderson@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#774735}
parent 1cc358b6
......@@ -184,7 +184,7 @@ PrintDialogGtk::PrintDialogGtk(PrintingContextLinux* context)
context_(context) {}
PrintDialogGtk::~PrintDialogGtk() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(owning_task_runner()->RunsTasksInCurrentSequence());
if (dialog_) {
aura::Window* parent = gtk::GetAuraTransientParent(dialog_);
......@@ -363,7 +363,7 @@ void PrintDialogGtk::ShowDialog(
void PrintDialogGtk::PrintDocument(const printing::MetafilePlayer& metafile,
const base::string16& document_name) {
// This runs on the print worker thread, does not block the UI thread.
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(!owning_task_runner()->RunsTasksInCurrentSequence());
// The document printing tasks can outlive the PrintingContext that created
// this dialog.
......@@ -389,7 +389,7 @@ void PrintDialogGtk::PrintDocument(const printing::MetafilePlayer& metafile,
}
// No errors, continue printing.
base::SequencedTaskRunnerHandle::Get()->PostTask(
owning_task_runner()->PostTask(
FROM_HERE, base::BindOnce(&PrintDialogGtk::SendDocumentToPrinter, this,
document_name));
}
......@@ -487,7 +487,7 @@ static void OnJobCompletedThunk(GtkPrintJob* print_job,
}
void PrintDialogGtk::SendDocumentToPrinter(
const base::string16& document_name) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(owning_task_runner()->RunsTasksInCurrentSequence());
// If |printer_| is nullptr then somehow the GTK printer list changed out
// under us. In which case, just bail out.
......
......@@ -13,7 +13,6 @@
#include "base/files/file_path.h"
#include "base/macros.h"
#include "base/memory/ref_counted_delete_on_sequence.h"
#include "base/sequenced_task_runner_helpers.h"
#include "printing/print_dialog_gtk_interface.h"
#include "printing/printing_context_linux.h"
#include "ui/aura/window_observer.h"
......@@ -84,8 +83,6 @@ class PrintDialogGtk : public printing::PrintDialogGtkInterface,
base::FilePath path_to_pdf_;
SEQUENCE_CHECKER(sequence_checker_);
DISALLOW_COPY_AND_ASSIGN(PrintDialogGtk);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment