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

Unified Diff: blimp/common/mandatory_callback.h

Issue 2382533002: Helium: Initial proto and Syncable interface definition (Closed)
Patch Set: test changes Created 4 years, 2 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 | « no previous file | blimp/common/proto/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: blimp/common/mandatory_callback.h
diff --git a/blimp/common/mandatory_callback.h b/blimp/common/mandatory_callback.h
index d1871ce48665a7f48aa783d817e32281248805a4..022830936d28b9b215b65adc9c7e7e3499568627 100644
--- a/blimp/common/mandatory_callback.h
+++ b/blimp/common/mandatory_callback.h
@@ -68,6 +68,19 @@ class MandatoryCallback<ReturnType(ArgTypes...)> {
#endif
}
+ // This a overload that handles the case where there are no arguments provided
+ template <typename...>
+ ReturnType Run() {
+ DCHECK(cb_); // Can't be run following std::move.
+
+#if DCHECK_IS_ON()
+ DCHECK(!was_run_);
+ was_run_ = true;
+#endif
+
+ cb_.Run();
+ }
+
template <typename... RunArgs>
ReturnType Run(RunArgs... args) {
DCHECK(cb_); // Can't be run following std::move.
@@ -98,6 +111,8 @@ MandatoryCallback<SignatureType> CreateMandatoryCallback(
return MandatoryCallback<SignatureType>(callback);
}
+using MandatoryClosure = MandatoryCallback<void()>;
+
} // namespace blimp
#endif // BLIMP_COMMON_MANDATORY_CALLBACK_H_
« no previous file with comments | « no previous file | blimp/common/proto/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698