| Index: extensions/browser/extension_function.h
|
| diff --git a/extensions/browser/extension_function.h b/extensions/browser/extension_function.h
|
| index 3428ee7ddc0fdfbb96639e3535d75e27abc61bf3..0f9b1ef9d8258c12fa01681c3a15656bf4532b38 100644
|
| --- a/extensions/browser/extension_function.h
|
| +++ b/extensions/browser/extension_function.h
|
| @@ -65,6 +65,18 @@ class Sender;
|
| #define EXTENSION_FUNCTION_VALIDATE(test) CHECK(test)
|
| #endif // NDEBUG
|
|
|
| +#ifdef NDEBUG
|
| +#define EXTENSION_FUNCTION_PRERUN_VALIDATE(test) \
|
| + do { \
|
| + if (!(test)) { \
|
| + this->bad_message_ = true; \
|
| + return false; \
|
| + } \
|
| + } while (0)
|
| +#else // NDEBUG
|
| +#define EXTENSION_FUNCTION_PRERUN_VALIDATE(test) CHECK(test)
|
| +#endif // NDEBUG
|
| +
|
| #define EXTENSION_FUNCTION_ERROR(error) \
|
| do { \
|
| error_ = error; \
|
| @@ -157,6 +169,16 @@ class ExtensionFunction
|
| ~ScopedUserGestureForTests();
|
| };
|
|
|
| + // Called before Run() in order to perform a common verification check so that
|
| + // APIs subclassing this don't have to roll their own RunSafe() variants.
|
| + // If this returns false, then Run() is never called, and the function
|
| + // responds immediately with an error (note that error must be non-empty in
|
| + // this case). If this returns true, execution continues on to Run().
|
| + virtual bool PreRunValidation(std::string* error);
|
| +
|
| + // Runs the extension function if PreRunValidation() succeeds.
|
| + ResponseAction RunWithValidation();
|
| +
|
| // Runs the function and returns the action to take when the caller is ready
|
| // to respond.
|
| //
|
| @@ -288,6 +310,14 @@ class ExtensionFunction
|
| return source_process_id_;
|
| }
|
|
|
| + // Sets did_respond_ to true so that the function won't DCHECK if it never
|
| + // sends a response. Typically, this shouldn't be used, even in testing. It's
|
| + // only for when you want to test functionality that doesn't exercise the
|
| + // Run() aspect of an extension function.
|
| + void ignore_did_respond_for_testing() { did_respond_ = true; }
|
| + // Same as above, but global. Yuck. Do not add any more uses of this.
|
| + static bool ignore_all_did_respond_for_testing_do_not_use;
|
| +
|
| protected:
|
| friend struct ExtensionFunctionDeleteTraits;
|
|
|
| @@ -439,6 +469,9 @@ class ExtensionFunction
|
| // if unknown.
|
| int source_process_id_;
|
|
|
| + // Whether this function has responded.
|
| + bool did_respond_;
|
| +
|
| private:
|
| base::ElapsedTimer timer_;
|
|
|
|
|