electron/shell/common/platform_util.cc
Charles Kerr 4a695d07c6
fix: misc-use-internal-linkage warnings (#44843)
* refactor: misc-use-internal-linkage warnings in context bridge

move impl functions into anonymous namespace so that they're not visible
to other compilation units:

- ExposeAPIInWorld()
- IsCalledFromMainWorld()
- OverrideGlobalPropertyFromIsolatedWorld()
- OverrideGlobalValueFromIsolatedWorld()
- TraceKeyPath()

* refactor: misc-use-internal-linkage warnings in skia util

move impl details into anonymous namespace so that they're not visible
to other compilation units:

- struct ScaleFactorPair
- kScaleFactorPairs[]
- GetScaleFactorFromPath()
- AddImageSkiaRepFromPath()

* refactor: misc-use-internal-linkage warnings in printing util

move impl details into anonymous namespace so that they're not visible
to other compilation units:

- GetFullPagePlugin()

* refactor: misc-use-internal-linkage warnings in blijnk converter

move impl details into anonymous namespace so that they're not visible
to other compilation units:

- GetKeyLocationCode()
- ModifiersToArray()

* refactor: misc-use-internal-linkage warnings in extrension system

move impl details into anonymous namespace so that they're not visible
to other compilation units:

- ParseManifest()

* refactor: misc-use-internal-linkage warnings in skia util

move impl details into anonymous namespace so that they're not visible
to other compilation units:

- GetFrameTokenMap()
- GetFrameTreeNodeIdMap()

* refactor: misc-use-internal-linkage warnings in electron_api_utility_process.cc

move impl details into anonymous namespace so that they're not visible
to other compilation units:

- GetAllUtilityProcessWrappers()

* refactor: misc-use-internal-linkage warnings in electron_api_menu

move impl details into anonymous namespace so that they're not visible
to other compilation units:

- InvokeBoolMethod()

* refactor: misc-use-internal-linkage warnings in platform util

move impl details into anonymous namespace so that they're not visible
to other compilation units:

- struct TrashItemResult
- TrashItemOnBlockingThread()
2024-11-27 10:40:39 -06:00

48 lines
1.4 KiB
C++

// 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/functional/bind.h"
#include "base/task/thread_pool.h"
#include "content/public/browser/browser_task_traits.h"
#include "shell/common/platform_util_internal.h"
namespace platform_util {
namespace {
struct TrashItemResult {
bool success;
std::string error;
};
TrashItemResult TrashItemOnBlockingThread(const base::FilePath& full_path) {
std::string error;
bool success = internal::PlatformTrashItem(full_path, &error);
return {success, error};
}
} // namespace
void TrashItem(const base::FilePath& full_path,
base::OnceCallback<void(bool, const std::string&)> callback) {
// XXX: is continue_on_shutdown right?
base::ThreadPool::PostTaskAndReplyWithResult(
FROM_HERE,
{base::MayBlock(), base::WithBaseSyncPrimitives(),
base::TaskPriority::USER_BLOCKING,
base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN},
base::BindOnce(&TrashItemOnBlockingThread, full_path),
base::BindOnce(
[](base::OnceCallback<void(bool, const std::string&)> callback,
TrashItemResult result) {
std::move(callback).Run(result.success, result.error);
},
std::move(callback)));
}
} // namespace platform_util