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

Unified Diff: components/ui_devtools/devtools_base_agent.h

Issue 2456643002: Create a base agent class for ui_devtools (Closed)
Patch Set: Add comments and fix header 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 | « no previous file | 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..87523c397d200b7d63d7b9a3157bc51bc97b5e89
--- /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_
sadrul 2016/10/28 02:06:16 Add this file in BUILD.gn as well?
Sarmad Hashmi 2016/10/28 18:52:01 Done.
+
+#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) {
+ m_frontend.reset(
+ new typename DomainMetainfo::FrontendClass(dispatcher->channel()));
+ DomainMetainfo::DispatcherClass::wire(dispatcher, this);
+ }
+
+ protected:
+ UiDevToolsBaseAgent() {}
+ typename DomainMetainfo::FrontendClass* frontend() const {
+ return m_frontend.get();
+ }
+
+ private:
+ std::unique_ptr<typename DomainMetainfo::FrontendClass> m_frontend;
sadrul 2016/10/28 02:06:16 frontend_
Sarmad Hashmi 2016/10/28 18:52:01 Done.
+
+ DISALLOW_COPY_AND_ASSIGN(UiDevToolsBaseAgent);
+};
+
+} // namespace devtools
+} // namespace ui
+
+#endif // COMPONENTS_UI_DEVTOOLS_DEVTOOLS_BASE_AGENT_H_
« no previous file with comments | « no previous file | components/ui_devtools/devtools_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698