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

Unified Diff: extensions/browser/extension_function.h

Issue 950023005: [Extensions] Apply WARN_UNUSED_RESULT and final keyword to ExtensionFunctions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix chromeos api Created 5 years, 10 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 | « extensions/browser/api/networking_config/networking_config_api.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/extension_function.h
diff --git a/extensions/browser/extension_function.h b/extensions/browser/extension_function.h
index 2e367d33be8597b8c88442b1ea5aedbc966f1806..30906299ffffc4863c83b9fa4108bcb147708ee4 100644
--- a/extensions/browser/extension_function.h
+++ b/extensions/browser/extension_function.h
@@ -321,18 +321,26 @@ class ExtensionFunction
// ResponseActions.
//
+ // These are exclusively used as return values from Run(). Call Respond(...)
+ // to respond at any other time - but as described below, only after Run()
+ // has already executed, and only if it returned RespondLater().
+ //
// Respond to the extension immediately with |result|.
- ResponseAction RespondNow(ResponseValue result);
+ ResponseAction RespondNow(ResponseValue result) WARN_UNUSED_RESULT;
// Don't respond now, but promise to call Respond(...) later.
- ResponseAction RespondLater();
+ ResponseAction RespondLater() WARN_UNUSED_RESULT;
// This is the return value of the EXTENSION_FUNCTION_VALIDATE macro, which
// needs to work from Run(), RunAsync(), and RunSync(). The former of those
// has a different return type (ResponseAction) than the latter two (bool).
- static ResponseAction ValidationFailure(ExtensionFunction* function);
+ static ResponseAction ValidationFailure(ExtensionFunction* function)
+ WARN_UNUSED_RESULT;
- // If RespondLater() was used, functions must at some point call Respond()
- // with |result| as their result.
+ // If RespondLater() was returned from Run(), functions must at some point
+ // call Respond() with |result| as their result.
+ //
+ // More specifically: call this iff Run() has already executed, it returned
+ // RespondLater(), and Respond(...) hasn't already been called.
void Respond(ResponseValue result);
virtual ~ExtensionFunction();
@@ -588,7 +596,10 @@ class AsyncExtensionFunction : public UIThreadExtensionFunction {
static bool ValidationFailure(AsyncExtensionFunction* function);
private:
- ResponseAction Run() override;
+ // If you're hitting a compile error here due to "final" - great! You're
+ // doing the right thing, you just need to extend UIThreadExtensionFunction
+ // instead of AsyncExtensionFunction.
+ ResponseAction Run() final;
};
// A SyncExtensionFunction is an ExtensionFunction that runs synchronously
@@ -615,7 +626,10 @@ class SyncExtensionFunction : public UIThreadExtensionFunction {
static bool ValidationFailure(SyncExtensionFunction* function);
private:
- ResponseAction Run() override;
+ // If you're hitting a compile error here due to "final" - great! You're
+ // doing the right thing, you just need to extend UIThreadExtensionFunction
+ // instead of SyncExtensionFunction.
+ ResponseAction Run() final;
};
class SyncIOThreadExtensionFunction : public IOThreadExtensionFunction {
@@ -636,7 +650,10 @@ class SyncIOThreadExtensionFunction : public IOThreadExtensionFunction {
static bool ValidationFailure(SyncIOThreadExtensionFunction* function);
private:
- ResponseAction Run() override;
+ // If you're hitting a compile error here due to "final" - great! You're
+ // doing the right thing, you just need to extend IOThreadExtensionFunction
+ // instead of SyncIOExtensionFunction.
+ ResponseAction Run() final;
};
#endif // EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_
« no previous file with comments | « extensions/browser/api/networking_config/networking_config_api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698