Chromium Code Reviews| Index: extensions/browser/extension_function.h |
| diff --git a/extensions/browser/extension_function.h b/extensions/browser/extension_function.h |
| index e48e8769205242cfe6398e4c75927e0c23cbd8b2..4fc037d108d9542ad3d87dfb525a71355e144f34 100644 |
| --- a/extensions/browser/extension_function.h |
| +++ b/extensions/browser/extension_function.h |
| @@ -397,15 +397,9 @@ class ExtensionFunction |
| // Helper method for ExtensionFunctionDeleteTraits. Deletes this object. |
| virtual void Destruct() const = 0; |
| - // Do not call this function directly, return the appropriate ResponseAction |
| - // from Run() instead. If using RespondLater then call Respond(). |
| - // |
| - // Call with true to indicate success, false to indicate failure, in which |
| - // case please set |error_|. |
| - virtual void SendResponse(bool success) = 0; |
| - |
| - // Common implementation for SendResponse. |
| - void SendResponseImpl(bool success); |
| + // Called after thre response is sent, allowing the function to perform any |
|
lazyboy
2016/09/20 20:21:33
s/thre/the
Devlin
2016/09/20 21:51:04
Done.
|
| + // additional work or cleanup. |
| + virtual void OnResponded() {} |
| // Return true if the argument to this function at |index| was provided and |
| // is non-null. |
| @@ -442,8 +436,9 @@ class ExtensionFunction |
| // The arguments to the API. Only non-null if argument were specified. |
| std::unique_ptr<base::ListValue> args_; |
| - // The results of the API. This should be populated by the derived class |
| - // before SendResponse() is called. |
| + // The results of the API. This should be populated through the Respond()/ |
| + // RespondNow() methods. In legacy implementations, this is set directly, and |
| + // should be set before calling SendResponse(). |
| std::unique_ptr<base::ListValue> results_; |
| // Any detailed error from the API. This should be populated by the derived |
| @@ -475,6 +470,10 @@ class ExtensionFunction |
| bool did_respond_; |
| private: |
| + // Call with true to indicate success, false to indicate failure. If this |
| + // failed, |error_| should be set. |
| + void SendResponseImpl(bool success); |
| + |
| base::ElapsedTimer timer_; |
| // The response type of the function, if the response has been sent. |
| @@ -544,7 +543,7 @@ class UIThreadExtensionFunction : public ExtensionFunction { |
| ~UIThreadExtensionFunction() override; |
| - void SendResponse(bool success) override; |
| + void OnResponded() override; |
| // Sets the Blob UUIDs whose ownership is being transferred to the renderer. |
| void SetTransferredBlobUUIDs(const std::vector<std::string>& blob_uuids); |
| @@ -618,8 +617,6 @@ class IOThreadExtensionFunction : public ExtensionFunction { |
| void Destruct() const override; |
| - void SendResponse(bool success) override; |
| - |
| private: |
| base::WeakPtr<extensions::IOThreadExtensionMessageFilter> ipc_sender_; |
| int routing_id_; |
| @@ -648,6 +645,10 @@ class AsyncExtensionFunction : public UIThreadExtensionFunction { |
| // ValidationFailure override to match RunAsync(). |
| static bool ValidationFailure(AsyncExtensionFunction* function); |
| + // Responds with success/failure. |results_| or |error_| should be set |
| + // accordingly. |
| + void SendResponse(bool success); |
| + |
| private: |
| // If you're hitting a compile error here due to "final" - great! You're |
| // doing the right thing, you just need to extend UIThreadExtensionFunction |