electron/shell/common/gin_helper/cleaned_up_at_exit.cc
trop[bot] a7459bc93b
refactor: move impl functions into private namespace (#43410)
* refactor: move into unnamed namespace: IsKillURL()

refactor: move into unnamed namespace: ResolvePossiblyRelativeURL()

refactor: move into unnamed namespace: AllowFileAccess()

refactor: move into unnamed namespace: PrepareURLForNavigation()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: move into unnamed namespace: GetMonitors()

refactor: move into unnamed namespace: GetEDIDProperty()

refactor: move into unnamed namespace: MonitorAtomIdToDisplayId()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: move into unnamed namespace: GetPermissionInfos() } refactor: move into unnamed namespace: GetPermissionAliases()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: move into unnamed namespace: OnOpenExternal()

refactor: move into unnamed namespace: HandleExternalProtocolInUI()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: move into unnamed namespace: BindMimeHandlerService()

refactor: move into unnamed namespace: BindBeforeUnloadControl()

refactor: move into unnamed namespace: BindBadgeServiceForServiceWorker()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: move into unnamed namespace: GetClientIdPath()

refactor: move into unnamed namespace: ReadClientId()

refactor: move into unnamed namespace: WriteClientId()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: move into unnamed namespace: HasExplicitLogFile()

refactor: move into unnamed namespace: DetermineLoggingDestination()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: move into unnamed namespace: GetArchiveCache()

refactor: move into unnamed namespace: GetArchiveCacheLock()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: move into unnamed namespace: GetParameters()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: move into unnamed namespace: GetDoomed()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: move into unnamed namespace: EncodeToken()

refactor: move into unnamed namespace: PortInfoToValue()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2024-08-21 21:29:25 -05:00

40 lines
886 B
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/gin_helper/cleaned_up_at_exit.h"
#include <algorithm>
#include <vector>
#include "base/no_destructor.h"
namespace gin_helper {
namespace {
std::vector<CleanedUpAtExit*>& GetDoomed() {
static base::NoDestructor<std::vector<CleanedUpAtExit*>> doomed;
return *doomed;
}
} // namespace
CleanedUpAtExit::CleanedUpAtExit() {
GetDoomed().emplace_back(this);
}
CleanedUpAtExit::~CleanedUpAtExit() {
auto& doomed = GetDoomed();
doomed.erase(std::remove(doomed.begin(), doomed.end(), this), doomed.end());
}
// static
void CleanedUpAtExit::DoCleanup() {
auto& doomed = GetDoomed();
while (!doomed.empty()) {
CleanedUpAtExit* next = doomed.back();
delete next;
}
}
} // namespace gin_helper