Commit 526a4801 authored by Jay Civelli's avatar Jay Civelli Committed by Commit Bot

Add a test Unzip service to simulate crashers

Adding a test Unzip service that disconnects when accessed to simulate
crashers. It will be used in a follow up CL to ensure extension
installation deals correctly with the unzip service crashing.

Bug: 799220
Change-Id: I511b591e5740ac4c0e64f63d7b28cd32173a4990
Reviewed-on: https://chromium-review.googlesource.com/955930Reviewed-by: default avatarJoshua Pawlicki <waffles@chromium.org>
Commit-Queue: Jay Civelli <jcivelli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542136}
parent fd67247e
......@@ -16,3 +16,18 @@ source_set("cpp") {
"//services/service_manager/public/cpp",
]
}
static_library("test_support") {
testonly = true
sources = [
"test_unzip_service.cc",
"test_unzip_service.h",
]
deps = [
":cpp",
"//base",
"//components/unzip_service:lib",
"//services/service_manager/public/cpp/test:test_support",
]
}
// Copyright 2018 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 "components/unzip_service/public/cpp/test_unzip_service.h"
namespace unzip {
CrashyUnzipService::CrashyUnzipService() = default;
CrashyUnzipService::~CrashyUnzipService() = default;
// service_manager::Service implmentation:
void CrashyUnzipService::OnStart() {}
void CrashyUnzipService::OnBindInterface(
const service_manager::BindSourceInfo& source_info,
const std::string& interface_name,
mojo::ScopedMessagePipeHandle interface_pipe) {
DCHECK(interface_name == mojom::Unzipper::Name_);
DCHECK(!unzipper_binding_);
unzipper_binding_ = std::make_unique<mojo::Binding<mojom::Unzipper>>(
this, mojom::UnzipperRequest(std::move(interface_pipe)));
}
// unzip::mojom::Unzipper:
void CrashyUnzipService::Unzip(base::File zip_file,
filesystem::mojom::DirectoryPtr output_dir,
UnzipCallback callback) {
unzipper_binding_.reset();
}
void CrashyUnzipService::UnzipWithFilter(
base::File zip_file,
filesystem::mojom::DirectoryPtr output_dir,
mojom::UnzipFilterPtr filter,
UnzipWithFilterCallback callback) {
unzipper_binding_.reset();
}
} // namespace unzip
// Copyright 2018 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.
#ifndef COMPONENTS_UNZIP_SERVICE_PUBLIC_CPP_TEST_UNZIP_SERVICE_H_
#define COMPONENTS_UNZIP_SERVICE_PUBLIC_CPP_TEST_UNZIP_SERVICE_H_
#include <memory>
#include "base/macros.h"
#include "components/unzip_service/public/interfaces/unzipper.mojom.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "services/service_manager/public/cpp/service.h"
namespace unzip {
// An implementation of the UnzipService that closes the connection when
// a call is made on the Unzipper interface.
// Can be used with a TestConnectorFactory to simulate crashes in the service
// while processing a call.
class CrashyUnzipService : public service_manager::Service,
public mojom::Unzipper {
public:
CrashyUnzipService();
~CrashyUnzipService() override;
// service_manager::Service:
void OnStart() override;
void OnBindInterface(const service_manager::BindSourceInfo& source_info,
const std::string& interface_name,
mojo::ScopedMessagePipeHandle interface_pipe) override;
// unzip::mojom::Unzipper:
void Unzip(base::File zip_file,
filesystem::mojom::DirectoryPtr output_dir,
UnzipCallback callback) override;
void UnzipWithFilter(base::File zip_file,
filesystem::mojom::DirectoryPtr output_dir,
mojom::UnzipFilterPtr filter,
UnzipWithFilterCallback callback) override;
private:
std::unique_ptr<mojo::Binding<mojom::Unzipper>> unzipper_binding_;
DISALLOW_COPY_AND_ASSIGN(CrashyUnzipService);
};
} // namespace unzip
#endif // COMPONENTS_UNZIP_SERVICE_PUBLIC_CPP_TEST_UNZIP_SERVICE_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment