#include "components/policy/core/common/remote_commands/remote_commands_service.h"
#include <algorithm>
#include <memory>
#include <string>
#include <utility>
#include "base/check_is_test.h"
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/metrics/histogram_functions.h"
#include "base/strings/stringprintf.h"
#include "base/syslog_logging.h"
#include "build/chromeos_buildflags.h"
#include "components/policy/core/common/cloud/cloud_policy_client.h"
#include "components/policy/core/common/cloud/cloud_policy_constants.h"
#include "components/policy/core/common/cloud/cloud_policy_store.h"
#include "components/policy/core/common/cloud/cloud_policy_validator.h"
#include "components/policy/core/common/cloud/enterprise_metrics.h"
#include "components/policy/core/common/remote_commands/remote_commands_factory.h"
#include "components/policy/proto/device_management_backend.pb.h"
namespace policy {
em;
namespace {
RemoteCommandsService::MetricReceivedRemoteCommand RemoteCommandMetricFromType(
em::RemoteCommand_Type type) { … }
const char* RemoteCommandTypeToString(em::RemoteCommand_Type type) { … }
std::string ToString(
enterprise_management::RemoteCommandResult::ResultType type) { … }
}
const char* RemoteCommandsService::GetMetricNameReceivedRemoteCommand(
PolicyInvalidationScope scope) { … }
std::string RemoteCommandsService::GetMetricNameExecutedRemoteCommand(
PolicyInvalidationScope scope,
em::RemoteCommand_Type command_type) { … }
std::string RemoteCommandsService::GetRequestType(
PolicyInvalidationScope scope) { … }
RemoteCommandsService::RemoteCommandsService(
std::unique_ptr<RemoteCommandsFactory> factory,
CloudPolicyClient* client,
CloudPolicyStore* store,
PolicyInvalidationScope scope)
: … { … }
RemoteCommandsService::~RemoteCommandsService() = default;
bool RemoteCommandsService::FetchRemoteCommands() { … }
void RemoteCommandsService::SetClocksForTesting(
const base::Clock* clock,
const base::TickClock* tick_clock) { … }
void RemoteCommandsService::SetOnCommandAckedCallback(
base::OnceClosure callback) { … }
void RemoteCommandsService::VerifyAndEnqueueSignedCommand(
const em::SignedData& signed_command) { … }
void RemoteCommandsService::EnqueueCommand(
const em::RemoteCommand& command,
const em::SignedData& signed_command) { … }
void RemoteCommandsService::OnJobStarted(RemoteCommandJob* command) { … }
void RemoteCommandsService::OnJobFinished(RemoteCommandJob* command) { … }
void RemoteCommandsService::OnRemoteCommandsFetched(
DeviceManagementStatus status,
const std::vector<enterprise_management::SignedData>& commands) { … }
void RemoteCommandsService::RecordReceivedRemoteCommand(
RemoteCommandsService::MetricReceivedRemoteCommand metric) const { … }
void RemoteCommandsService::RecordExecutedRemoteCommand(
const RemoteCommandJob& command) const { … }
}