Commit f93a0962 authored by Gabriel Charette's avatar Gabriel Charette Committed by Commit Bot

Use modern base APIs to avoid base::MessageLoop::current() calls in /chrome/browser/printing

This is a precusor cleanup extracted from
https://chromium-review.googlesource.com/c/chromium/src/+/957760/7
in the broader effort to restrict usage of MessageLoop::current().

This CL was uploaded by git cl split.

R=dpapad@chromium.org

Bug: 825327
Change-Id: Ibbd7b8f1c59f8e1022b9d77dfcc4cf6e8490a24e
Reviewed-on: https://chromium-review.googlesource.com/986747
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548332}
parent f4132695
...@@ -41,11 +41,7 @@ void HoldRefCallback(scoped_refptr<PrintJobWorkerOwner> owner, ...@@ -41,11 +41,7 @@ void HoldRefCallback(scoped_refptr<PrintJobWorkerOwner> owner,
PrintJob::PrintJob() PrintJob::PrintJob()
: is_job_pending_(false), is_canceling_(false), quit_factory_(this) { : is_job_pending_(false), is_canceling_(false), quit_factory_(this) {
// This is normally a UI message loop, but in unit tests, the message loop is DCHECK(base::MessageLoopForUI::IsCurrent());
// of the 'default' type.
DCHECK(base::MessageLoopForUI::IsCurrent() ||
base::MessageLoop::current()->type() ==
base::MessageLoop::TYPE_DEFAULT);
} }
PrintJob::~PrintJob() { PrintJob::~PrintJob() {
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include <vector> #include <vector>
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "build/build_config.h" #include "build/build_config.h"
...@@ -91,12 +90,11 @@ TEST(PrintJobTest, SimplePrint) { ...@@ -91,12 +90,11 @@ TEST(PrintJobTest, SimplePrint) {
// Test the multi-threaded nature of PrintJob to make sure we can use it with // Test the multi-threaded nature of PrintJob to make sure we can use it with
// known lifetime. // known lifetime.
content::TestBrowserThreadBundle thread_bundle_; content::TestBrowserThreadBundle thread_bundle;
content::NotificationRegistrar registrar_; content::NotificationRegistrar registrar;
TestPrintNotificationObserver observer; TestPrintNotificationObserver observer;
registrar_.Add(&observer, registrar.Add(&observer, content::NOTIFICATION_ALL,
content::NOTIFICATION_ALL, content::NotificationService::AllSources());
content::NotificationService::AllSources());
volatile bool check = false; volatile bool check = false;
scoped_refptr<PrintJob> job(new TestPrintJob(&check)); scoped_refptr<PrintJob> job(new TestPrintJob(&check));
EXPECT_TRUE(job->RunsTasksInCurrentSequence()); EXPECT_TRUE(job->RunsTasksInCurrentSequence());
...@@ -116,7 +114,7 @@ TEST(PrintJobTest, SimplePrint) { ...@@ -116,7 +114,7 @@ TEST(PrintJobTest, SimplePrint) {
TEST(PrintJobTest, SimplePrintLateInit) { TEST(PrintJobTest, SimplePrintLateInit) {
volatile bool check = false; volatile bool check = false;
base::MessageLoop current; content::TestBrowserThreadBundle thread_bundle;
scoped_refptr<PrintJob> job(new TestPrintJob(&check)); scoped_refptr<PrintJob> job(new TestPrintJob(&check));
job = nullptr; job = nullptr;
EXPECT_TRUE(check); EXPECT_TRUE(check);
......
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