| Index: content/test/fake_service_registry.cc
|
| diff --git a/content/test/fake_service_registry.cc b/content/test/fake_service_registry.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..7a9a5f162449947709174b6572707d342d6bae81
|
| --- /dev/null
|
| +++ b/content/test/fake_service_registry.cc
|
| @@ -0,0 +1,37 @@
|
| +// 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/test/fake_service_registry.h"
|
| +
|
| +#include <utility>
|
| +
|
| +#include "base/logging.h"
|
| +#include "base/strings/string_piece.h"
|
| +
|
| +namespace content {
|
| +
|
| +FakeServiceRegistry::FakeServiceRegistry() = default;
|
| +FakeServiceRegistry::~FakeServiceRegistry() = default;
|
| +
|
| +void FakeServiceRegistry::AddService(
|
| + const std::string& service_name,
|
| + const base::Callback<void(mojo::ScopedMessagePipeHandle)> service_factory) {
|
| + DCHECK(service_map_.find(service_name) == service_map_.end());
|
| + service_map_[service_name] = service_factory;
|
| +}
|
| +
|
| +void FakeServiceRegistry::RemoveService(const std::string& service_name) {
|
| + auto it = service_map_.find(service_name);
|
| + DCHECK(it != service_map_.end());
|
| + service_map_.erase(it);
|
| +}
|
| +
|
| +void FakeServiceRegistry::ConnectToRemoteService(
|
| + const base::StringPiece& name, mojo::ScopedMessagePipeHandle handle) {
|
| + auto it = service_map_.find(name.as_string());
|
| + if (it != service_map_.end())
|
| + it->second.Run(std::move(handle));
|
| +}
|
| +
|
| +} // namespace content
|
|
|