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

Unified Diff: components/arc/instance_holder.h

Issue 2347293002: arc: Add InstanceHelper::GetInstanceForMethod() (Closed)
Patch Set: No more DCHECK Created 4 years, 3 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
« no previous file with comments | « components/arc/ime/arc_ime_bridge_impl.cc ('k') | components/arc/net/arc_net_host_impl.cc » ('j') | no next file with comments »
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 4fb5b37023eac07e6303f0c9928c0e8752c8f547..06e581a8140d594edfcac129e6ddd38cbbef6ab6 100644
--- a/components/arc/instance_holder.h
+++ b/components/arc/instance_holder.h
@@ -42,6 +42,31 @@ class InstanceHolder {
T* instance() const { return instance_; }
uint32_t version() const { return version_; }
+ // Gets the Mojo interface that's intended to call for
+ // |method_name_for_logging|, but only if its reported version is at least
+ // |min_version|. Returns nullptr if the instance is either not ready or does
+ // not have the requested version, and logs appropriately.
+ T* GetInstanceForMethod(const char* method_name_for_logging,
+ uint32_t min_version) {
+ if (!instance_) {
+ VLOG(1) << "Instance for " << T::Name_ << "::" << method_name_for_logging
+ << " not available.";
+ return nullptr;
+ }
+ if (version_ < min_version) {
+ VLOG(1) << "Instance for " << T::Name_ << "::" << method_name_for_logging
+ << " version mismatch. Expected " << min_version << " got "
+ << version_;
+ return nullptr;
+ }
+ return instance_;
+ }
+
+ // Same as the above, but for the version zero.
+ T* GetInstanceForMethod(const char* method_name_for_logging) {
+ return GetInstanceForMethod(method_name_for_logging, 0u);
+ }
+
// Adds or removes observers. This can only be called on the thread that this
// class was created on. RemoveObserver does nothing if |observer| is not in
// the list.
« no previous file with comments | « components/arc/ime/arc_ime_bridge_impl.cc ('k') | components/arc/net/arc_net_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698