Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(821)

Unified Diff: mojo/public/cpp/bindings/lib/interface_ptr_state.h

Issue 2062333002: mojo::Callback -> base::Callback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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_;
« no previous file with comments | « mojo/public/cpp/bindings/lib/interface_endpoint_client.cc ('k') | mojo/public/cpp/bindings/lib/multiplex_router.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698