Chromium Code Reviews| Index: mojo/public/cpp/bindings/lib/interface_ptr_state.h |
| diff --git a/mojo/public/cpp/bindings/lib/interface_ptr_state.h b/mojo/public/cpp/bindings/lib/interface_ptr_state.h |
| index 37d5b876608f62dc2495bf414a6b8fd861f9550f..94d13ede76c2ac54450b1dbf3b9bbfb63022e7db 100644 |
| --- a/mojo/public/cpp/bindings/lib/interface_ptr_state.h |
| +++ b/mojo/public/cpp/bindings/lib/interface_ptr_state.h |
| @@ -23,6 +23,7 @@ |
| #include "mojo/public/cpp/bindings/interface_endpoint_client.h" |
| #include "mojo/public/cpp/bindings/interface_id.h" |
| #include "mojo/public/cpp/bindings/interface_ptr_info.h" |
| +#include "mojo/public/cpp/bindings/lib/control_message_handler.h" |
| #include "mojo/public/cpp/bindings/lib/control_message_proxy.h" |
| #include "mojo/public/cpp/bindings/lib/multiplex_router.h" |
| #include "mojo/public/cpp/bindings/lib/router.h" |
| @@ -64,12 +65,10 @@ class InterfacePtrState<Interface, false> { |
| void QueryVersion(const base::Callback<void(uint32_t)>& callback) { |
| ConfigureProxyIfNecessary(); |
| - // Do a static cast in case the interface contains methods with the same |
| - // name. It is safe to capture |this| because the callback won't be run |
| - // after this object goes away. |
| - static_cast<ControlMessageProxy*>(proxy_)->QueryVersion( |
| - base::Bind(&InterfacePtrState::OnQueryVersion, base::Unretained(this), |
| - callback)); |
| + // It is safe to capture |this| because the callback won't be run after this |
| + // object goes away. |
| + router_->control_message_proxy()->QueryVersion(base::Bind( |
| + &InterfacePtrState::OnQueryVersion, base::Unretained(this), callback)); |
| } |
| void RequireVersion(uint32_t version) { |
| @@ -79,9 +78,12 @@ class InterfacePtrState<Interface, false> { |
| return; |
| version_ = version; |
| - // Do a static cast in case the interface contains methods with the same |
| - // name. |
| - static_cast<ControlMessageProxy*>(proxy_)->RequireVersion(version); |
| + router_->control_message_proxy()->RequireVersion(version); |
| + } |
| + |
| + void FlushForTesting() { |
| + ConfigureProxyIfNecessary(); |
| + router_->control_message_proxy()->FlushForTesting(); |
| } |
| void Swap(InterfacePtrState* other) { |
| @@ -157,8 +159,11 @@ class InterfacePtrState<Interface, false> { |
| filters.Append<MessageHeaderValidator>(Interface::Name_); |
| filters.Append<typename Interface::ResponseValidator_>(); |
| - router_ = new Router(std::move(handle_), std::move(filters), false, |
| - std::move(runner_)); |
| + router_ = new Router( |
| + std::move(handle_), std::move(filters), false, std::move(runner_), |
| + // The version is only queried from the client so the value passed here |
|
yzshen1
2016/08/31 17:06:47
style nit: please move it out of the statement. (a
Sam McNally
2016/09/01 00:44:37
Done.
|
| + // will not be used. |
| + 0u); |
| proxy_ = new Proxy(router_); |
| } |
| @@ -209,13 +214,10 @@ class InterfacePtrState<Interface, true> { |
| void QueryVersion(const base::Callback<void(uint32_t)>& callback) { |
| ConfigureProxyIfNecessary(); |
| - |
| - // Do a static cast in case the interface contains methods with the same |
| - // name. It is safe to capture |this| because the callback won't be run |
| - // after this object goes away. |
| - static_cast<ControlMessageProxy*>(proxy_.get())->QueryVersion( |
| - base::Bind(&InterfacePtrState::OnQueryVersion, base::Unretained(this), |
| - callback)); |
| + // It is safe to capture |this| because the callback won't be run after this |
| + // object goes away. |
| + endpoint_client_->control_message_proxy()->QueryVersion(base::Bind( |
| + &InterfacePtrState::OnQueryVersion, base::Unretained(this), callback)); |
| } |
| void RequireVersion(uint32_t version) { |
| @@ -225,9 +227,12 @@ class InterfacePtrState<Interface, true> { |
| return; |
| version_ = version; |
| - // Do a static cast in case the interface contains methods with the same |
| - // name. |
| - static_cast<ControlMessageProxy*>(proxy_.get())->RequireVersion(version); |
| + endpoint_client_->control_message_proxy()->RequireVersion(version); |
| + } |
| + |
| + void FlushForTesting() { |
| + ConfigureProxyIfNecessary(); |
| + endpoint_client_->control_message_proxy()->FlushForTesting(); |
| } |
| void Swap(InterfacePtrState* other) { |
| @@ -314,7 +319,10 @@ class InterfacePtrState<Interface, true> { |
| endpoint_client_.reset(new InterfaceEndpointClient( |
| router_->CreateLocalEndpointHandle(kMasterInterfaceId), nullptr, |
| base::WrapUnique(new typename Interface::ResponseValidator_()), false, |
| - std::move(runner_))); |
| + std::move(runner_), |
| + // The version is only queried from the client so the value passed here |
| + // will not be used. |
| + 0u)); |
| proxy_.reset(new Proxy(endpoint_client_.get())); |
| proxy_->serialization_context()->group_controller = |
| endpoint_client_->group_controller(); |