Commit 85330724 authored by Jesse Schettler's avatar Jesse Schettler Committed by Commit Bot

arc: Delete print document on non-UI thread

Ensure the print document is being deleted on a non-UI thread when the
print session ends.

Bug: b:139551164
Test: Close print preview and verify print document is deleted
Change-Id: I4e0afbaf2942b7a2fb89b319a3885855243963d7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1787558
Commit-Queue: Jesse Schettler <jschettler@chromium.org>
Reviewed-by: default avatarYusuke Sato <yusukes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#694236}
parent 323726c6
...@@ -15,6 +15,11 @@ ...@@ -15,6 +15,11 @@
namespace arc { namespace arc {
void DeletePrintDocument(const base::FilePath& file_path) {
if (!base::DeleteFile(file_path, false))
LOG(ERROR) << "Failed to delete print document.";
}
base::FilePath SavePrintDocument(mojo::ScopedHandle scoped_handle) { base::FilePath SavePrintDocument(mojo::ScopedHandle scoped_handle) {
base::PlatformFile platform_file = base::kInvalidPlatformFile; base::PlatformFile platform_file = base::kInvalidPlatformFile;
if (mojo::UnwrapPlatformFile(std::move(scoped_handle), &platform_file) != if (mojo::UnwrapPlatformFile(std::move(scoped_handle), &platform_file) !=
......
...@@ -15,6 +15,9 @@ class FilePath; ...@@ -15,6 +15,9 @@ class FilePath;
namespace arc { namespace arc {
// Deletes a print document and logs any errors.
void DeletePrintDocument(const base::FilePath& file_path);
// Uses the provided scoped handle to save a print document from ARC and returns // Uses the provided scoped handle to save a print document from ARC and returns
// the document's file path. // the document's file path.
base::FilePath SavePrintDocument(mojo::ScopedHandle scoped_handle); base::FilePath SavePrintDocument(mojo::ScopedHandle scoped_handle);
......
...@@ -9,11 +9,13 @@ ...@@ -9,11 +9,13 @@
#include "ash/public/cpp/arc_custom_tab.h" #include "ash/public/cpp/arc_custom_tab.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/location.h" #include "base/location.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/task/post_task.h"
#include "base/task/task_traits.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "chrome/browser/chromeos/arc/print_spooler/arc_print_spooler_util.h"
#include "chrome/browser/printing/print_view_manager_common.h" #include "chrome/browser/printing/print_view_manager_common.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "mojo/public/cpp/bindings/interface_request.h" #include "mojo/public/cpp/bindings/interface_request.h"
...@@ -71,8 +73,8 @@ PrintSessionImpl::~PrintSessionImpl() { ...@@ -71,8 +73,8 @@ PrintSessionImpl::~PrintSessionImpl() {
return; return;
} }
if (!base::DeleteFile(file_path, false)) base::PostTask(FROM_HERE, {base::ThreadPool(), base::MayBlock()},
LOG(ERROR) << "Failed to delete print document."; base::BindOnce(&DeletePrintDocument, file_path));
} }
void PrintSessionImpl::Close() { void PrintSessionImpl::Close() {
......
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