| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef COMPONENTS_UI_DEVTOOLS_DEVTOOLS_BASE_AGENT_H_ |
| 6 #define COMPONENTS_UI_DEVTOOLS_DEVTOOLS_BASE_AGENT_H_ |
| 7 |
| 8 #include "components/ui_devtools/Protocol.h" |
| 9 |
| 10 namespace ui { |
| 11 namespace devtools { |
| 12 |
| 13 class UiDevToolsAgent { |
| 14 public: |
| 15 UiDevToolsAgent() {} |
| 16 virtual ~UiDevToolsAgent() {} |
| 17 |
| 18 virtual void Init(protocol::UberDispatcher*) = 0; |
| 19 }; |
| 20 |
| 21 // A base agent so that any Backend implementation has access to the |
| 22 // corresponding frontend instance. This also wires the backend with |
| 23 // the dispatcher. When initializing an instance of this class, |
| 24 // the template argument is simply the generated Metainfo class of |
| 25 // any domain type such as DOM or CSS. |
| 26 template <typename DomainMetainfo> |
| 27 class UiDevToolsBaseAgent : public UiDevToolsAgent, |
| 28 public DomainMetainfo::BackendClass { |
| 29 public: |
| 30 void Init(protocol::UberDispatcher* dispatcher) { |
| 31 frontend_.reset( |
| 32 new typename DomainMetainfo::FrontendClass(dispatcher->channel())); |
| 33 DomainMetainfo::DispatcherClass::wire(dispatcher, this); |
| 34 } |
| 35 |
| 36 protected: |
| 37 UiDevToolsBaseAgent() {} |
| 38 typename DomainMetainfo::FrontendClass* frontend() const { |
| 39 return frontend_.get(); |
| 40 } |
| 41 |
| 42 private: |
| 43 std::unique_ptr<typename DomainMetainfo::FrontendClass> frontend_; |
| 44 |
| 45 DISALLOW_COPY_AND_ASSIGN(UiDevToolsBaseAgent); |
| 46 }; |
| 47 |
| 48 } // namespace devtools |
| 49 } // namespace ui |
| 50 |
| 51 #endif // COMPONENTS_UI_DEVTOOLS_DEVTOOLS_BASE_AGENT_H_ |
| OLD | NEW |