Chromium Code Reviews| 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) { |