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

Unified Diff: extensions/browser/extension_function.h

Issue 2612873004: Remove some usages of AsyncExtensionFunction::results_. (Closed)
Patch Set: sync 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.h
diff --git a/extensions/browser/extension_function.h b/extensions/browser/extension_function.h
index f97dc8c5cf7ea7d41ff66ca5c01b5066d5565e27..415391a06396de3654fe9966a8b6e0b0f667a9dc 100644
--- a/extensions/browser/extension_function.h
+++ b/extensions/browser/extension_function.h
@@ -153,7 +153,8 @@ class ExtensionFunction
// The action to use when returning from RunAsync.
//
- // Use RespondNow() or RespondLater() rather than this class directly.
+ // Use RespondNow() or RespondLater() or AlreadyResponded() rather than this
+ // class directly.
class ResponseActionObject {
public:
virtual ~ResponseActionObject() {}
@@ -371,6 +372,28 @@ class ExtensionFunction
ResponseAction RespondNow(ResponseValue result) WARN_UNUSED_RESULT;
// Don't respond now, but promise to call Respond(...) later.
ResponseAction RespondLater() WARN_UNUSED_RESULT;
+ // Respond() was already called before Run() finished executing.
+ //
+ // Assume Run() uses some helper system that accepts callback that Respond()s.
+ // If that helper system calls the synchronously in some cases, then use
+ // this return value in those cases.
+ //
+ // FooExtensionFunction::Run() {
+ // Helper::FetchResults(..., base::Bind(&Success));
+ // if (did_respond()) return AlreadyResponded();
+ // return RespondLater();
+ // }
+ // FooExtensionFunction::Success() {
+ // Respond(...);
+ // }
+ //
+ // Helper::FetchResults(..., callback) {
+ // if (...)
+ // callback.Run(..); // Synchronously call |callback|.
+ // else
+ // // Asynchronously call |callback|.
+ // }
+ ResponseAction AlreadyResponded() 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
« no previous file with comments | « extensions/browser/api/system_storage/system_storage_api.cc ('k') | extensions/browser/extension_function.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698