Fix WorkerPool and IPC send inside print job/manager

This commit is contained in:
Samuel Attard 2017-12-19 11:06:42 +11:00 committed by Aleksei Kuzmin
parent 0b6293e2f5
commit a21e0c652c
2 changed files with 6 additions and 5 deletions

View file

@ -13,11 +13,11 @@
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/task_scheduler/post_task.h"
#include "base/single_thread_task_runner.h" #include "base/single_thread_task_runner.h"
#include "base/threading/sequenced_worker_pool.h" #include "base/threading/sequenced_worker_pool.h"
#include "base/threading/thread_restrictions.h" #include "base/threading/thread_restrictions.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "base/threading/worker_pool.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/printing/print_job_worker.h" #include "chrome/browser/printing/print_job_worker.h"
@ -435,11 +435,10 @@ void PrintJob::ControlledWorkerShutdown() {
// Now make sure the thread object is cleaned up. Do this on a worker // Now make sure the thread object is cleaned up. Do this on a worker
// thread because it may block. // thread because it may block.
base::WorkerPool::PostTaskAndReply( base::PostTaskAndReply(
FROM_HERE, FROM_HERE,
base::Bind(&PrintJobWorker::Stop, base::Unretained(worker_.get())), base::Bind(&PrintJobWorker::Stop, base::Unretained(worker_.get())),
base::Bind(&PrintJob::HoldUntilStopIsCalled, this), base::Bind(&PrintJob::HoldUntilStopIsCalled, this));
false);
is_job_pending_ = false; is_job_pending_ = false;
registrar_.RemoveAll(); registrar_.RemoveAll();

View file

@ -378,8 +378,10 @@ void PrintViewManagerBase::DisconnectFromCurrentPrintJob() {
} }
void PrintViewManagerBase::PrintingDone(bool success) { void PrintViewManagerBase::PrintingDone(bool success) {
auto host = web_contents()->GetRenderViewHost();
if (print_job_.get()) { if (print_job_.get()) {
Send(new PrintMsg_PrintingDone(routing_id(), success)); if (host)
host->Send(new PrintMsg_PrintingDone(host->GetRoutingID(), success));
} }
if (!callback.is_null()) { if (!callback.is_null()) {
callback.Run(success && print_job_); callback.Run(success && print_job_);