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

Unified Diff: extensions/browser/extension_function.cc

Issue 2612873004: Remove some usages of AsyncExtensionFunction::results_. (Closed)
Patch Set: add DCHECK message Created 3 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 side-by-side diff with in-line comments
Download patch
Index: extensions/browser/extension_function.cc
diff --git a/extensions/browser/extension_function.cc b/extensions/browser/extension_function.cc
index c9a76ac5a8361b5e4c50501406d41b37dd27669e..52f647de5a2c9c3f2e09f6e3b6a4c390b5750cea 100644
--- a/extensions/browser/extension_function.cc
+++ b/extensions/browser/extension_function.cc
@@ -153,6 +153,22 @@ class RespondLaterAction : public ExtensionFunction::ResponseActionObject {
void Execute() override {}
};
+class AlreadyRespondedAction : public ExtensionFunction::ResponseActionObject {
+ public:
+ using DidRespondCallback = base::Callback<bool(void)>;
+ AlreadyRespondedAction(const DidRespondCallback& did_respond)
+ : did_respond_(did_respond) {}
+ ~AlreadyRespondedAction() override {}
+
+ void Execute() override {
+ DCHECK(did_respond_.Run()) << "ExtensionFunction did not call Respond(),"
+ " but Run() returned AlreadyResponded()";
+ }
+
+ private:
+ DidRespondCallback did_respond_;
+};
+
// Used in implementation of ScopedUserGestureForTests.
class UserGestureForTests {
public:
@@ -393,6 +409,11 @@ ExtensionFunction::ResponseAction ExtensionFunction::RespondLater() {
return ResponseAction(new RespondLaterAction());
}
+ExtensionFunction::ResponseAction ExtensionFunction::AlreadyResponded() {
+ return ResponseAction(new AlreadyRespondedAction(
+ base::Bind(&ExtensionFunction::did_respond, this)));
Devlin 2017/01/20 00:16:02 Why not just DCHECK() here instead, and have Execu
lazyboy 2017/01/20 00:54:47 Right, thanks. Done.
+}
+
// static
ExtensionFunction::ResponseAction ExtensionFunction::ValidationFailure(
ExtensionFunction* function) {

Powered by Google App Engine
This is Rietveld 408576698