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

Unified Diff: components/arc/instance_holder.h

Issue 2594203002: [mojo] Expose interface method min_versions (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « no previous file | components/arc/net/arc_net_host_impl.cc » ('j') | mojo/public/cpp/bindings/interface_traits.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/arc/instance_holder.h
diff --git a/components/arc/instance_holder.h b/components/arc/instance_holder.h
index 8455814581c61997f4d4ec602c6373cdbd9bb41b..4387da5c6ae1f82a1f7529ad75ade7f82df76f53 100644
--- a/components/arc/instance_holder.h
+++ b/components/arc/instance_holder.h
@@ -12,6 +12,7 @@
#include "base/macros.h"
#include "base/observer_list.h"
#include "base/threading/thread_checker.h"
+#include "mojo/public/cpp/bindings/interface_traits.h"
namespace arc {
@@ -63,6 +64,23 @@ class InstanceHolder {
return instance_;
}
+ template <uint32_t MethodIndex>
+ T* GetInstanceForMethod() {
+ using Method = mojo::MethodTraits<T, MethodIndex>;
yzshen1 2016/12/22 18:53:28 I feel that mojo::MethodTraits is not needed, we c
yzshen1 2016/12/22 19:01:09 But please see my comments in the other file. If w
+ if (!instance_) {
+ VLOG(1) << "Instance for " << T::Name_ << "::" << Method::Name()
+ << " not available.";
+ return nullptr;
+ }
+ if (version_ < Method::MinVersion()) {
+ LOG(ERROR) << "Instance for " << T::Name_ << "::" << Method::Name()
+ << " version mismatch. Expected " << Method::MinVersion()
+ << " got " << version_;
+ return nullptr;
+ }
+ return instance_;
+ }
+
// Same as the above, but for the version zero.
T* GetInstanceForMethod(const std::string& method_name_for_logging) {
return GetInstanceForMethod(method_name_for_logging, 0u);
« no previous file with comments | « no previous file | components/arc/net/arc_net_host_impl.cc » ('j') | mojo/public/cpp/bindings/interface_traits.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698