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

Unified Diff: extensions/renderer/bindings/api_binding.cc

Issue 2962093002: [Extensions Bindings] Add activity logging of custom handling (Closed)
Patch Set: nit Created 3 years, 5 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/bindings/api_binding.h ('k') | extensions/renderer/bindings/api_binding_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/bindings/api_binding.cc
diff --git a/extensions/renderer/bindings/api_binding.cc b/extensions/renderer/bindings/api_binding.cc
index d5ee62f9c6a8a96aad011e315b1d69bb75a2cc5e..e05b3c4160921a5eadaa77826c8696be8ffce6c6 100644
--- a/extensions/renderer/bindings/api_binding.cc
+++ b/extensions/renderer/bindings/api_binding.cc
@@ -193,6 +193,7 @@ APIBinding::APIBinding(const std::string& api_name,
const base::ListValue* event_definitions,
const base::DictionaryValue* property_definitions,
const CreateCustomType& create_custom_type,
+ const OnSilentRequest& on_silent_request,
std::unique_ptr<APIBindingHooks> binding_hooks,
APITypeReferenceMap* type_refs,
APIRequestHandler* request_handler,
@@ -201,6 +202,7 @@ APIBinding::APIBinding(const std::string& api_name,
: api_name_(api_name),
property_definitions_(property_definitions),
create_custom_type_(create_custom_type),
+ on_silent_request_(on_silent_request),
binding_hooks_(std::move(binding_hooks)),
type_refs_(type_refs),
request_handler_(request_handler),
@@ -584,6 +586,7 @@ void APIBinding::HandleCall(const std::string& name,
bool invalid_invocation = false;
v8::Local<v8::Function> custom_callback;
bool updated_args = false;
+ int old_request_id = request_handler_->last_sent_request_id();
{
v8::TryCatch try_catch(isolate);
APIBindingHooks::RequestResult hooks_result = binding_hooks_->RunHooks(
@@ -602,6 +605,14 @@ void APIBinding::HandleCall(const std::string& name,
case APIBindingHooks::RequestResult::HANDLED:
if (!hooks_result.return_value.IsEmpty())
arguments->Return(hooks_result.return_value);
+
+ // TODO(devlin): This is a pretty simplistic implementation of this,
+ // but it's similar to the current JS logic. If we wanted to be more
+ // correct, we could create a RequestScope object that watches outgoing
+ // requests.
+ if (old_request_id == request_handler_->last_sent_request_id())
+ on_silent_request_.Run(context, name, argument_list);
+
return; // Our work here is done.
case APIBindingHooks::RequestResult::ARGUMENTS_UPDATED:
updated_args = true; // Intentional fall-through.
« no previous file with comments | « extensions/renderer/bindings/api_binding.h ('k') | extensions/renderer/bindings/api_binding_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698