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

Unified Diff: extensions/renderer/api_bindings_system.h

Issue 2469593002: [Extensions Bindings] Add Events support (Closed)
Patch Set: . Created 4 years, 1 month 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/renderer/api_bindings_system.h
diff --git a/extensions/renderer/api_bindings_system.h b/extensions/renderer/api_bindings_system.h
index de4e09ad8ef9bf26eaef1124da045cab55bdc721..ae098a952388832641bd06263ddbd7c9137a17b5 100644
--- a/extensions/renderer/api_bindings_system.h
+++ b/extensions/renderer/api_bindings_system.h
@@ -11,6 +11,8 @@
#include "base/callback.h"
#include "base/macros.h"
+#include "extensions/renderer/api_binding_types.h"
+#include "extensions/renderer/api_event_handler.h"
#include "extensions/renderer/api_request_handler.h"
#include "extensions/renderer/argument_spec.h"
@@ -43,7 +45,7 @@ class APIBindingsSystem {
base::Callback<const base::DictionaryValue&(const std::string&)>;
using SendRequestMethod = base::Callback<void(std::unique_ptr<Request>)>;
- APIBindingsSystem(const APIRequestHandler::CallJSFunction& call_js,
+ APIBindingsSystem(const binding::RunJSFunction& call_js,
const GetAPISchemaMethod& get_api_schema,
const SendRequestMethod& send_request);
~APIBindingsSystem();
@@ -58,6 +60,12 @@ class APIBindingsSystem {
void CompleteRequest(const std::string& request_id,
const base::ListValue& response);
+ // Notifies the APIEventHandler to fire the corresponding event, notifying
+ // listeners.
+ void FireEventInContext(const std::string& event_name,
+ v8::Local<v8::Context> context,
+ const base::ListValue& response);
+
private:
// Creates a new APIBinding for the given |api_name|.
std::unique_ptr<APIBinding> CreateNewAPIBinding(const std::string& api_name);
@@ -76,6 +84,9 @@ class APIBindingsSystem {
// The request handler associated with the system.
APIRequestHandler request_handler_;
+ // The event handler associated with the system.
+ APIEventHandler event_handler_;
+
// A map from api_name -> APIBinding for constructed APIs. APIBindings are
// created lazily.
std::map<std::string, std::unique_ptr<APIBinding>> api_bindings_;

Powered by Google App Engine
This is Rietveld 408576698