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

Unified Diff: components/ui_devtools/devtools_base_agent.h

Issue 2456643002: Create a base agent class for ui_devtools (Closed)
Patch Set: sadruls comments Created 4 years, 2 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 | « components/ui_devtools/BUILD.gn ('k') | components/ui_devtools/devtools_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/ui_devtools/devtools_base_agent.h
diff --git a/components/ui_devtools/devtools_base_agent.h b/components/ui_devtools/devtools_base_agent.h
new file mode 100644
index 0000000000000000000000000000000000000000..0db95a674a377b7409882c79f2d35bcb064f4d30
--- /dev/null
+++ b/components/ui_devtools/devtools_base_agent.h
@@ -0,0 +1,51 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_UI_DEVTOOLS_DEVTOOLS_BASE_AGENT_H_
+#define COMPONENTS_UI_DEVTOOLS_DEVTOOLS_BASE_AGENT_H_
+
+#include "components/ui_devtools/Protocol.h"
+
+namespace ui {
+namespace devtools {
+
+class UiDevToolsAgent {
+ public:
+ UiDevToolsAgent() {}
+ virtual ~UiDevToolsAgent() {}
+
+ virtual void Init(protocol::UberDispatcher*) = 0;
+};
+
+// A base agent so that any Backend implementation has access to the
+// corresponding frontend instance. This also wires the backend with
+// the dispatcher. When initializing an instance of this class,
+// the template argument is simply the generated Metainfo class of
+// any domain type such as DOM or CSS.
+template <typename DomainMetainfo>
+class UiDevToolsBaseAgent : public UiDevToolsAgent,
+ public DomainMetainfo::BackendClass {
+ public:
+ void Init(protocol::UberDispatcher* dispatcher) {
+ frontend_.reset(
+ new typename DomainMetainfo::FrontendClass(dispatcher->channel()));
+ DomainMetainfo::DispatcherClass::wire(dispatcher, this);
+ }
+
+ protected:
+ UiDevToolsBaseAgent() {}
+ typename DomainMetainfo::FrontendClass* frontend() const {
+ return frontend_.get();
+ }
+
+ private:
+ std::unique_ptr<typename DomainMetainfo::FrontendClass> frontend_;
+
+ DISALLOW_COPY_AND_ASSIGN(UiDevToolsBaseAgent);
+};
+
+} // namespace devtools
+} // namespace ui
+
+#endif // COMPONENTS_UI_DEVTOOLS_DEVTOOLS_BASE_AGENT_H_
« no previous file with comments | « components/ui_devtools/BUILD.gn ('k') | components/ui_devtools/devtools_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698