Add a ctor for InterfaceRequest<I> that takes a ScopedMessagePipeHandle, and remove MakeRequest<I>().
InterfaceRequest is basically analogous to InterfaceHandle (and vice
versa), and the latter has such a ctor. Moreover, MakeRequest doesn't
really add anything and is mostly just confusing.
R=vardhan@google.com
Review URL: https://codereview.chromium.org/1926123002 .
diff --git a/mojo/application/application_runner_chromium.cc b/mojo/application/application_runner_chromium.cc
index bfe9d49..b528034 100644
--- a/mojo/application/application_runner_chromium.cc
+++ b/mojo/application/application_runner_chromium.cc
@@ -58,7 +58,7 @@
loop.reset(new base::MessageLoop(message_loop_type_));
ApplicationImpl impl(delegate_.get(),
- MakeRequest<Application>(MakeScopedHandle(
+ InterfaceRequest<Application>(MakeScopedHandle(
MessagePipeHandle(application_request_handle))));
loop->Run();
}
diff --git a/mojo/public/cpp/application/lib/application_runner.cc b/mojo/public/cpp/application/lib/application_runner.cc
index 3654715..4ef544b 100644
--- a/mojo/public/cpp/application/lib/application_runner.cc
+++ b/mojo/public/cpp/application/lib/application_runner.cc
@@ -49,7 +49,7 @@
{
RunLoop loop;
ApplicationImpl app(delegate_.get(),
- MakeRequest<Application>(MakeScopedHandle(
+ InterfaceRequest<Application>(MakeScopedHandle(
MessagePipeHandle(app_request_handle))));
loop.Run();
}
diff --git a/mojo/public/cpp/application/lib/application_test_base.cc b/mojo/public/cpp/application/lib/application_test_base.cc
index 0c57925..42519a2 100644
--- a/mojo/public/cpp/application/lib/application_test_base.cc
+++ b/mojo/public/cpp/application/lib/application_test_base.cc
@@ -91,7 +91,7 @@
// --args-for='mojo:example_apptests arg1 --gtest_filter=foo arg2'
Array<String> args;
ShellAndArgumentGrabber grabber(
- &args, MakeRequest<Application>(MakeScopedHandle(
+ &args, InterfaceRequest<Application>(MakeScopedHandle(
MessagePipeHandle(application_request_handle))));
grabber.WaitForInitialize();
MOJO_CHECK(g_shell);
diff --git a/mojo/public/cpp/application/lib/interface_factory_connector.h b/mojo/public/cpp/application/lib/interface_factory_connector.h
index 9b8f4ba..30bc8c5 100644
--- a/mojo/public/cpp/application/lib/interface_factory_connector.h
+++ b/mojo/public/cpp/application/lib/interface_factory_connector.h
@@ -23,7 +23,7 @@
const std::string& interface_name,
ScopedMessagePipeHandle client_handle) override {
factory_->Create(application_connection,
- MakeRequest<Interface>(client_handle.Pass()));
+ InterfaceRequest<Interface>(client_handle.Pass()));
}
private:
diff --git a/mojo/public/cpp/bindings/binding.h b/mojo/public/cpp/bindings/binding.h
index 3d9658c..5f33a61 100644
--- a/mojo/public/cpp/bindings/binding.h
+++ b/mojo/public/cpp/bindings/binding.h
@@ -172,7 +172,8 @@
// implementation. Put this object into a state where it can be rebound to a
// new pipe.
InterfaceRequest<Interface> Unbind() {
- auto request = MakeRequest<Interface>(internal_router_->PassMessagePipe());
+ auto request =
+ InterfaceRequest<Interface>(internal_router_->PassMessagePipe());
internal_router_.reset();
return request;
}
diff --git a/mojo/public/cpp/bindings/interface_request.h b/mojo/public/cpp/bindings/interface_request.h
index 5542a37..a16f5da 100644
--- a/mojo/public/cpp/bindings/interface_request.h
+++ b/mojo/public/cpp/bindings/interface_request.h
@@ -27,11 +27,16 @@
template <typename Interface>
class InterfaceRequest {
public:
- // Constructs an empty InterfaceRequest, representing that the client is not
+ // Constructs an "empty" InterfaceRequest, representing that the client is not
// requesting an implementation of Interface.
InterfaceRequest() {}
InterfaceRequest(std::nullptr_t) {}
+ // Constructs an InterfaceRequest from a message pipe handle (if |handle| is
+ // not set, then this constructs an "empty" InterfaceRequest).
+ explicit InterfaceRequest(ScopedMessagePipeHandle handle)
+ : handle_(handle.Pass()) {}
+
// Takes the message pipe from another InterfaceRequest.
InterfaceRequest(InterfaceRequest&& other) { handle_ = other.handle_.Pass(); }
InterfaceRequest& operator=(InterfaceRequest&& other) {
@@ -63,16 +68,6 @@
MOJO_MOVE_ONLY_TYPE(InterfaceRequest);
};
-// Makes an InterfaceRequest bound to the specified message pipe. If |handle|
-// is empty or invalid, the resulting InterfaceRequest will represent the
-// absence of a request.
-template <typename Interface>
-InterfaceRequest<Interface> MakeRequest(ScopedMessagePipeHandle handle) {
- InterfaceRequest<Interface> request;
- request.Bind(handle.Pass());
- return request;
-}
-
// Creates a new message pipe over which Interface is to be served, and one end
// into the supplied |handle| and the returns the other inside an
// InterfaceRequest<>. The InterfaceHandle<> can be used to create a client
@@ -85,7 +80,7 @@
InterfaceRequest<Interface> GetProxy(InterfaceHandle<Interface>* handle) {
MessagePipe pipe;
*handle = InterfaceHandle<Interface>(pipe.handle0.Pass(), 0u);
- return MakeRequest<Interface>(pipe.handle1.Pass());
+ return InterfaceRequest<Interface>(pipe.handle1.Pass());
}
// Creates a new message pipe over which Interface is to be served. Binds the
diff --git a/mojo/public/cpp/bindings/lib/array_serialization.h b/mojo/public/cpp/bindings/lib/array_serialization.h
index 7119baa..7c8f515 100644
--- a/mojo/public/cpp/bindings/lib/array_serialization.h
+++ b/mojo/public/cpp/bindings/lib/array_serialization.h
@@ -27,9 +27,6 @@
namespace mojo {
-template <typename Interface>
-InterfaceRequest<Interface> MakeRequest(ScopedMessagePipeHandle handle);
-
namespace internal {
// The ArraySerializer template contains static methods for serializing |Array|s
@@ -235,7 +232,8 @@
auto result = Array<InterfaceRequest<I>>::New(input->size());
for (size_t i = 0; i < input->size(); ++i)
result.at(i) =
- MakeRequest<I>(MakeScopedHandle(FetchAndReset(&input->at(i)))).Pass();
+ InterfaceRequest<I>(MakeScopedHandle(FetchAndReset(&input->at(i))))
+ .Pass();
output->Swap(&result);
}
};
diff --git a/mojo/public/cpp/bindings/tests/validation_unittest.cc b/mojo/public/cpp/bindings/tests/validation_unittest.cc
index f2cba62..70bd75b 100644
--- a/mojo/public/cpp/bindings/tests/validation_unittest.cc
+++ b/mojo/public/cpp/bindings/tests/validation_unittest.cc
@@ -459,7 +459,7 @@
IntegrationTestInterfaceImpl interface_impl;
Binding<IntegrationTestInterface> binding(
&interface_impl,
- MakeRequest<IntegrationTestInterface>(testee_endpoint().Pass()));
+ InterfaceRequest<IntegrationTestInterface>(testee_endpoint().Pass()));
binding.internal_router()->EnableTestingMode();
mojo::internal::MessageValidatorList validators;
diff --git a/services/ui/input_manager/input_associate.cc b/services/ui/input_manager/input_associate.cc
index ad34f1b..bbe21ee 100644
--- a/services/ui/input_manager/input_associate.cc
+++ b/services/ui/input_manager/input_associate.cc
@@ -49,9 +49,9 @@
DCHECK(view_token); // checked by mojom
if (service_name == mojo::ui::InputConnection::Name_) {
- CreateInputConnection(
- view_token.Pass(),
- mojo::MakeRequest<mojo::ui::InputConnection>(client_handle.Pass()));
+ CreateInputConnection(view_token.Pass(),
+ mojo::InterfaceRequest<mojo::ui::InputConnection>(
+ client_handle.Pass()));
}
}
@@ -62,9 +62,9 @@
DCHECK(view_tree_token); // checked by mojom
if (service_name == mojo::ui::InputDispatcher::Name_) {
- CreateInputDispatcher(
- view_tree_token.Pass(),
- mojo::MakeRequest<mojo::ui::InputDispatcher>(client_handle.Pass()));
+ CreateInputDispatcher(view_tree_token.Pass(),
+ mojo::InterfaceRequest<mojo::ui::InputDispatcher>(
+ client_handle.Pass()));
}
}
diff --git a/shell/android/android_handler.cc b/shell/android/android_handler.cc
index b2c1118..c52b340 100644
--- a/shell/android/android_handler.cc
+++ b/shell/android/android_handler.cc
@@ -44,7 +44,7 @@
const base::FilePath& app_path,
jint j_handle) {
mojo::InterfaceRequest<mojo::Application> application_request =
- mojo::MakeRequest<mojo::Application>(
+ mojo::InterfaceRequest<mojo::Application>(
mojo::MakeScopedHandle(mojo::MessagePipeHandle(j_handle)));
// Load the library, so that we can set the application context there if
diff --git a/shell/context.cc b/shell/context.cc
index 101ea61..8052e1b 100644
--- a/shell/context.cc
+++ b/shell/context.cc
@@ -204,7 +204,7 @@
mojo::ScopedMessagePipeHandle client_handle) override {
if (tracer_ && service_name == tracing::TraceProvider::Name_) {
tracer_->ConnectToProvider(
- mojo::MakeRequest<tracing::TraceProvider>(client_handle.Pass()));
+ mojo::InterfaceRequest<tracing::TraceProvider>(client_handle.Pass()));
}
}