Chromium Code Reviews| 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_ |