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

Unified Diff: headless/lib/browser/domain_h.template

Issue 1907533002: headless: Implement DevTools events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add parameters to all events Created 4 years, 8 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 | « headless/lib/browser/domain_cc.template ('k') | headless/lib/browser/headless_devtools_client_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: headless/lib/browser/domain_h.template
diff --git a/headless/lib/browser/domain_h.template b/headless/lib/browser/domain_h.template
index 0cd03c3bc5380328c4766933f1345c5a27034542..edb87100303a6e5418eb8c400e6892ce0197173b 100644
--- a/headless/lib/browser/domain_h.template
+++ b/headless/lib/browser/domain_h.template
@@ -8,6 +8,7 @@
#define HEADLESS_PUBLIC_DOMAINS_{{domain.domain | camelcase_to_hacker_style | upper}}_H_
#include "base/callback.h"
+#include "base/observer_list.h"
#include "base/values.h"
#include "headless/public/domains/types.h"
#include "headless/public/headless_export.h"
@@ -15,6 +16,15 @@
namespace headless {
namespace {{domain.domain | camelcase_to_hacker_style}} {
+{% if "events" in domain %}
+class Observer {
+ public:
+ virtual ~Observer() {}
+ {% for event in domain.events %}
+ virtual void On{{event.name | to_title_case}}(const {{event.name | to_title_case}}Params& params) {}
+ {% endfor %}
+};
+{% endif %}
{% if domain.description %}
// {{domain.description}}
@@ -24,6 +34,13 @@ class HEADLESS_EXPORT Domain {
Domain(internal::MessageDispatcher* dispatcher);
~Domain();
+ {% if "events" in domain %}
+ // Add or remove an observer. |observer| must be removed before being
+ // destroyed.
+ void AddObserver(Observer* observer);
+ void RemoveObserver(Observer* observer);
+ {% endif %}
+
{# Generate methods for each command. #}
{% for command in domain.commands %}
{# Skip redirected commands. #}
@@ -66,7 +83,15 @@ class HEADLESS_EXPORT Domain {
static void Handle{{method_name}}Response(base::Callback<void(std::unique_ptr<{{method_name}}Result>)> callback, const base::Value& response);
{% endfor %}
+ {# Generate event dispatchers. #}
+ {% for event in domain.events %}
+ void Dispatch{{event.name | to_title_case}}Event(const base::Value& params);
+ {% endfor %}
+
internal::MessageDispatcher* dispatcher_; // Not owned.
+ {% if "events" in domain %}
+ base::ObserverList<Observer> observers_;
+ {% endif %}
DISALLOW_COPY_AND_ASSIGN(Domain);
};
« no previous file with comments | « headless/lib/browser/domain_cc.template ('k') | headless/lib/browser/headless_devtools_client_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698