| Index: mojo/public/cpp/bindings/tests/variant_test_util.h
|
| diff --git a/mojo/public/cpp/bindings/tests/variant_test_util.h b/mojo/public/cpp/bindings/tests/variant_test_util.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..3f6b1f1b5f6b5568ea3adae4b3f34657f04221a5
|
| --- /dev/null
|
| +++ b/mojo/public/cpp/bindings/tests/variant_test_util.h
|
| @@ -0,0 +1,32 @@
|
| +// 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 MOJO_PUBLIC_CPP_BINDINGS_TESTS_VARIANT_TEST_UTIL_H_
|
| +#define MOJO_PUBLIC_CPP_BINDINGS_TESTS_VARIANT_TEST_UTIL_H_
|
| +
|
| +#include <string.h>
|
| +
|
| +#include "base/logging.h"
|
| +#include "mojo/public/cpp/bindings/interface_request.h"
|
| +
|
| +namespace mojo {
|
| +namespace test {
|
| +
|
| +// Converts a request of Interface1 to a request of Interface0. Interface0 and
|
| +// Interface1 are expected to be two variants of the same mojom interface.
|
| +// In real-world use cases, users shouldn't need to worry about this. Because it
|
| +// is rare to deal with two variants of the same interface in the same app.
|
| +template <typename Interface0, typename Interface1>
|
| +InterfaceRequest<Interface0> ConvertInterfaceRequest(
|
| + InterfaceRequest<Interface1> request) {
|
| + DCHECK_EQ(0, strcmp(Interface0::Name_, Interface1::Name_));
|
| + InterfaceRequest<Interface0> result;
|
| + result.Bind(request.PassMessagePipe());
|
| + return result;
|
| +}
|
| +
|
| +} // namespace test
|
| +} // namespace mojo
|
| +
|
| +#endif // MOJO_PUBLIC_CPP_BINDINGS_TESTS_VARIANT_TEST_UTIL_H_
|
|
|