feat: add shell.trashItem() to replace shell.moveItemToTrash() (#25114)
This commit is contained in:
parent
e9e7eee25e
commit
1b6534b326
11 changed files with 212 additions and 21 deletions
37
shell/common/platform_util.cc
Normal file
37
shell/common/platform_util.cc
Normal file
|
@ -0,0 +1,37 @@
|
|||
// Copyright (c) 2020 Slack Technologies, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "shell/common/platform_util.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/task/thread_pool.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "shell/common/platform_util_internal.h"
|
||||
|
||||
namespace platform_util {
|
||||
|
||||
void TrashItemOnBlockingThread(
|
||||
const base::FilePath& full_path,
|
||||
base::OnceCallback<void(bool, const std::string&)> callback) {
|
||||
std::string error;
|
||||
bool success = internal::PlatformTrashItem(full_path, &error);
|
||||
content::GetUIThreadTaskRunner({})->PostTask(
|
||||
FROM_HERE, base::BindOnce(std::move(callback), success, error));
|
||||
}
|
||||
|
||||
void TrashItem(const base::FilePath& full_path,
|
||||
base::OnceCallback<void(bool, const std::string&)> callback) {
|
||||
// XXX: is continue_on_shutdown right?
|
||||
base::ThreadPool::PostTask(FROM_HERE,
|
||||
{base::MayBlock(), base::WithBaseSyncPrimitives(),
|
||||
base::TaskPriority::USER_BLOCKING,
|
||||
base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN},
|
||||
base::BindOnce(&TrashItemOnBlockingThread,
|
||||
full_path, std::move(callback)));
|
||||
}
|
||||
|
||||
} // namespace platform_util
|
Loading…
Add table
Add a link
Reference in a new issue