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

Unified Diff: extensions/renderer/api_binding_hooks.h

Issue 2609553003: [Extensions Bindings] Allow custom hooks to return values, throw (Closed)
Patch Set: rebase 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
« no previous file with comments | « extensions/renderer/api_binding.cc ('k') | extensions/renderer/api_binding_hooks.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/api_binding_hooks.h
diff --git a/extensions/renderer/api_binding_hooks.h b/extensions/renderer/api_binding_hooks.h
index d6620275017e656fc0182af51f7fdc2d69d78c12..e326d8cfb233d5c8132cbdb533f6b6608ab9e044 100644
--- a/extensions/renderer/api_binding_hooks.h
+++ b/extensions/renderer/api_binding_hooks.h
@@ -30,11 +30,21 @@ class APISignature;
class APIBindingHooks {
public:
// The result of checking for hooks to handle a request.
- enum class RequestResult {
- HANDLED, // A custom hook handled the request.
- THROWN, // An exception was thrown during parsing or handling.
- INVALID_INVOCATION, // The request was called with invalid arguments.
- NOT_HANDLED, // The request was not handled.
+ struct RequestResult {
+ enum ResultCode {
+ HANDLED, // A custom hook handled the request.
+ THROWN, // An exception was thrown during parsing or
+ // handling.
+ INVALID_INVOCATION, // The request was called with invalid arguments.
+ NOT_HANDLED, // The request was not handled.
+ };
+
+ explicit RequestResult(ResultCode code);
+ RequestResult(const RequestResult& other);
+ ~RequestResult();
+
+ ResultCode code;
+ v8::Local<v8::Value> return_value; // Only valid if code == HANDLED.
};
// The callback to handle an API method. We pass in the expected signature
@@ -68,8 +78,7 @@ class APIBindingHooks {
const std::string& api_name);
// Looks for a custom hook to handle the given request and, if one exists,
- // runs it. Returns the result of trying to run the hook, or NOT_HANDLED if no
- // hook was found.
+ // runs it. Returns the result of running the hook, if any.
RequestResult HandleRequest(const std::string& api_name,
const std::string& method_name,
v8::Local<v8::Context> context,
« no previous file with comments | « extensions/renderer/api_binding.cc ('k') | extensions/renderer/api_binding_hooks.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698