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 95c5c206abaeb2b4120c9c332cd487d6eca027ae..cf04a14ace56e909bd4272fe1f3adabaf68c4fb0 100644 |
--- a/mojo/public/cpp/bindings/lib/interface_ptr_state.h |
+++ b/mojo/public/cpp/bindings/lib/interface_ptr_state.h |
@@ -11,6 +11,7 @@ |
#include <memory> |
#include <utility> |
+#include "base/bind.h" |
#include "base/logging.h" |
#include "base/macros.h" |
#include "base/memory/ptr_util.h" |
@@ -63,16 +64,12 @@ class InterfacePtrState<Interface, false> { |
void QueryVersion(const Callback<void(uint32_t)>& callback) { |
ConfigureProxyIfNecessary(); |
- // It is safe to capture |this| because the callback won't be run after this |
- // object goes away. |
- auto callback_wrapper = [this, callback](uint32_t version) { |
- this->version_ = version; |
- callback.Run(version); |
- }; |
- |
// Do a static cast in case the interface contains methods with the same |
- // name. |
- static_cast<ControlMessageProxy*>(proxy_)->QueryVersion(callback_wrapper); |
+ // 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)); |
} |
void RequireVersion(uint32_t version) { |
@@ -173,6 +170,12 @@ class InterfacePtrState<Interface, false> { |
proxy_ = new Proxy(router_); |
} |
+ void OnQueryVersion(const Callback<void(uint32_t)>& callback, |
+ uint32_t version) { |
+ version_ = version; |
+ callback.Run(version); |
+ } |
+ |
Proxy* proxy_; |
Router* router_; |
@@ -213,17 +216,13 @@ class InterfacePtrState<Interface, true> { |
void QueryVersion(const Callback<void(uint32_t)>& callback) { |
ConfigureProxyIfNecessary(); |
- // It is safe to capture |this| because the callback won't be run after this |
- // object goes away. |
- auto callback_wrapper = [this, callback](uint32_t version) { |
- this->version_ = version; |
- callback.Run(version); |
- }; |
// Do a static cast in case the interface contains methods with the same |
- // name. |
- static_cast<ControlMessageProxy*>(proxy_.get()) |
- ->QueryVersion(callback_wrapper); |
+ // 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)); |
} |
void RequireVersion(uint32_t version) { |
@@ -334,6 +333,12 @@ class InterfacePtrState<Interface, true> { |
proxy_->serialization_context()->router = endpoint_client_->router(); |
} |
+ void OnQueryVersion(const Callback<void(uint32_t)>& callback, |
+ uint32_t version) { |
+ version_ = version; |
+ callback.Run(version); |
+ } |
+ |
scoped_refptr<MultiplexRouter> router_; |
std::unique_ptr<InterfaceEndpointClient> endpoint_client_; |