| Index: third_party/WebKit/public/platform/InterfaceRegistry.h
|
| diff --git a/third_party/WebKit/public/platform/InterfaceRegistry.h b/third_party/WebKit/public/platform/InterfaceRegistry.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..d0a2bf43e5ecd7bbbc438818cbec01e26d69094d
|
| --- /dev/null
|
| +++ b/third_party/WebKit/public/platform/InterfaceRegistry.h
|
| @@ -0,0 +1,51 @@
|
| +// Copyright 2016 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 InterfaceRegistry_h
|
| +#define InterfaceRegistry_h
|
| +
|
| +#include "base/callback_forward.h"
|
| +#include "mojo/public/cpp/system/message_pipe.h"
|
| +#include "public/platform/WebCommon.h"
|
| +
|
| +#if INSIDE_BLINK
|
| +#include "mojo/public/cpp/bindings/interface_request.h"
|
| +#include "wtf/Functional.h"
|
| +#endif
|
| +
|
| +namespace blink {
|
| +
|
| +using InterfaceFactory = base::Callback<void(mojo::ScopedMessagePipeHandle)>;
|
| +
|
| +class BLINK_PLATFORM_EXPORT InterfaceRegistry {
|
| + public:
|
| + virtual void addInterface(const char* name, const InterfaceFactory&) = 0;
|
| +
|
| +#if INSIDE_BLINK
|
| + static InterfaceRegistry* getEmptyInterfaceRegistry();
|
| +
|
| + template <typename Interface>
|
| + void addInterface(
|
| + std::unique_ptr<WTF::Function<void(mojo::InterfaceRequest<Interface>)>>
|
| + factory) {
|
| + addInterface(Interface::Name_,
|
| + convertToBaseCallback(WTF::bind(
|
| + &InterfaceRegistry::forwardToInterfaceFactory<Interface>,
|
| + std::move(factory))));
|
| + }
|
| +
|
| + private:
|
| + template <typename Interface>
|
| + static void forwardToInterfaceFactory(
|
| + const std::unique_ptr<
|
| + WTF::Function<void(mojo::InterfaceRequest<Interface>)>>& factory,
|
| + mojo::ScopedMessagePipeHandle handle) {
|
| + (*factory)(mojo::MakeRequest<Interface>(std::move(handle)));
|
| + }
|
| +#endif // INSIDE_BLINK
|
| +};
|
| +
|
| +} // namespace blink
|
| +
|
| +#endif
|
|
|