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

Side by Side Diff: mojo/public/cpp/bindings/callback.h

Issue 864123002: Declient calculator test mojom. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Remove extraneous typedef Created 5 years, 11 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 unified diff | Download patch
« no previous file with comments | « no previous file | mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_CALLBACK_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_CALLBACK_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_CALLBACK_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_CALLBACK_H_
7 7
8 #include "mojo/public/cpp/bindings/lib/callback_internal.h" 8 #include "mojo/public/cpp/bindings/lib/callback_internal.h"
9 #include "mojo/public/cpp/bindings/lib/shared_ptr.h" 9 #include "mojo/public/cpp/bindings/lib/shared_ptr.h"
10 #include "mojo/public/cpp/bindings/lib/template_util.h" 10 #include "mojo/public/cpp/bindings/lib/template_util.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 sink.Run(internal::Forward(args)...); 55 sink.Run(internal::Forward(args)...);
56 } 56 }
57 Sink sink; 57 Sink sink;
58 }; 58 };
59 59
60 internal::SharedPtr<Runnable> sink_; 60 internal::SharedPtr<Runnable> sink_;
61 }; 61 };
62 62
63 typedef Callback<void()> Closure; 63 typedef Callback<void()> Closure;
64 64
65 namespace {
jamesr 2015/01/22 22:45:24 anonymous namespace inside a header is almost neve
Aaron Boodman 2015/01/22 22:49:08 You're right, thanks.
66
67 template <typename Method, typename Class>
68 class RunnableImpl {
jamesr 2015/01/22 22:45:24 don't put this in public. If you want it in your t
Aaron Boodman 2015/01/22 22:49:08 done.
69 public:
70 RunnableImpl(Method method, Class instance)
71 : method_(method), instance_(instance) {}
72 template <typename... Args>
73 void Run(Args... args) const {
74 (instance_->*method_)(args...);
75 }
76
77 private:
78 Method method_;
79 Class instance_;
80 };
81
82 } // namespace
83
84 // Convenience to create a create a runnable for any method.
85 // |Class| can be any copyable type with an -> operator.
86 template <typename Method, typename Class>
87 RunnableImpl<Method, Class> MakeRunnable(Method method, Class object) {
88 return RunnableImpl<Method, Class>(method, object);
89 }
90
65 } // namespace mojo 91 } // namespace mojo
66 92
67 #endif // MOJO_PUBLIC_CPP_BINDINGS_CALLBACK_H_ 93 #endif // MOJO_PUBLIC_CPP_BINDINGS_CALLBACK_H_
OLDNEW
« no previous file with comments | « no previous file | mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698