blob: e3b41382c581d3b8f1abe43c6eecd006f0a52cca [file] [log] [blame]
// Copyright 2022 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "iioservice/iioservice_simpleclient/common.h"
#include <utility>
#include "iioservice/include/common.h"
namespace iioservice {
std::string GetDeviceTypesInString() {
std::stringstream ss;
for (int i = 0; i <= static_cast<int32_t>(cros::mojom::DeviceType::kMaxValue);
++i) {
if (i != 0)
ss << ", ";
auto type = static_cast<cros::mojom::DeviceType>(i);
ss << type << ": " << i;
}
return ss.str();
}
TimeoutDelegate::TimeoutDelegate(int timeout_in_milliseconds,
std::string timeout_log,
base::OnceCallback<void()> quit_closure) {
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE,
base::BindOnce(&TimeoutDelegate::TimeoutTask, weak_factory_.GetWeakPtr(),
timeout_log, std::move(quit_closure)),
base::Milliseconds(timeout_in_milliseconds));
}
void TimeoutDelegate::TimeoutTask(std::string timeout_log,
base::OnceCallback<void()> quit_closure) {
LOGF(ERROR) << "Timeout: " << timeout_log;
std::move(quit_closure).Run();
}
} // namespace iioservice