blob: 516fda2ce8c13bc0b6662e8c6dbd4dd6811f6d59 [file] [log] [blame]
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/public/test/test_service.h"
#include <utility>
#include "base/bind.h"
#include "base/check.h"
#include "base/notreached.h"
#include "base/run_loop.h"
#include "sandbox/policy/sandbox.h"
namespace content {
const char kTestServiceUrl[] = "system:content_test_service";
TestService::TestService(
mojo::PendingReceiver<service_manager::mojom::Service> receiver)
: service_receiver_(this, std::move(receiver)) {
registry_.AddInterface<mojom::TestService>(
base::BindRepeating(&TestService::Create, base::Unretained(this)));
}
TestService::~TestService() = default;
void TestService::OnBindInterface(
const service_manager::BindSourceInfo& source_info,
const std::string& interface_name,
mojo::ScopedMessagePipeHandle interface_pipe) {
requestor_name_ = source_info.identity.name();
registry_.BindInterface(interface_name, std::move(interface_pipe));
}
void TestService::Create(mojo::PendingReceiver<mojom::TestService> receiver) {
DCHECK(!receiver_.is_bound());
receiver_.Bind(std::move(receiver));
}
void TestService::DoSomething(DoSomethingCallback callback) {
std::move(callback).Run();
base::RunLoop::QuitCurrentWhenIdleDeprecated();
}
void TestService::DoTerminateProcess(DoTerminateProcessCallback callback) {
NOTREACHED();
}
void TestService::DoCrashImmediately(DoCrashImmediatelyCallback callback) {
NOTREACHED();
}
void TestService::CreateFolder(CreateFolderCallback callback) {
NOTREACHED();
}
void TestService::GetRequestorName(GetRequestorNameCallback callback) {
std::move(callback).Run(requestor_name_);
}
void TestService::CreateReadOnlySharedMemoryRegion(
const std::string& message,
CreateReadOnlySharedMemoryRegionCallback callback) {
NOTREACHED();
}
void TestService::CreateWritableSharedMemoryRegion(
const std::string& message,
CreateWritableSharedMemoryRegionCallback callback) {
NOTREACHED();
}
void TestService::CreateUnsafeSharedMemoryRegion(
const std::string& message,
CreateUnsafeSharedMemoryRegionCallback callback) {
NOTREACHED();
}
void TestService::IsProcessSandboxed(IsProcessSandboxedCallback callback) {
std::move(callback).Run(sandbox::policy::Sandbox::IsProcessSandboxed());
}
} // namespace content