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

Side by Side Diff: components/ui_devtools/devtools_base_agent.h

Issue 2470933002: Disable agents when client disconnects (Closed)
Patch Set: fix nit Created 4 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « no previous file | components/ui_devtools/devtools_client.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_UI_DEVTOOLS_DEVTOOLS_BASE_AGENT_H_ 5 #ifndef COMPONENTS_UI_DEVTOOLS_DEVTOOLS_BASE_AGENT_H_
6 #define COMPONENTS_UI_DEVTOOLS_DEVTOOLS_BASE_AGENT_H_ 6 #define COMPONENTS_UI_DEVTOOLS_DEVTOOLS_BASE_AGENT_H_
7 7
8 #include "components/ui_devtools/Protocol.h" 8 #include "components/ui_devtools/Protocol.h"
9 9
10 namespace ui { 10 namespace ui {
11 namespace devtools { 11 namespace devtools {
12 12
13 class UiDevToolsAgent { 13 class UiDevToolsAgent {
14 public: 14 public:
15 UiDevToolsAgent() {} 15 UiDevToolsAgent() {}
16 virtual ~UiDevToolsAgent() {} 16 virtual ~UiDevToolsAgent() {}
17 17
18 virtual void Init(protocol::UberDispatcher*) = 0; 18 virtual void Init(protocol::UberDispatcher*) = 0;
19 virtual void Disable() = 0;
19 }; 20 };
20 21
21 // A base agent so that any Backend implementation has access to the 22 // A base agent so that any Backend implementation has access to the
22 // corresponding frontend instance. This also wires the backend with 23 // corresponding frontend instance. This also wires the backend with
23 // the dispatcher. When initializing an instance of this class, 24 // the dispatcher. When initializing an instance of this class,
24 // the template argument is simply the generated Metainfo class of 25 // the template argument is simply the generated Metainfo class of
25 // any domain type such as DOM or CSS. 26 // any domain type such as DOM or CSS.
26 template <typename DomainMetainfo> 27 template <typename DomainMetainfo>
27 class UiDevToolsBaseAgent : public UiDevToolsAgent, 28 class UiDevToolsBaseAgent : public UiDevToolsAgent,
28 public DomainMetainfo::BackendClass { 29 public DomainMetainfo::BackendClass {
29 public: 30 public:
30 void Init(protocol::UberDispatcher* dispatcher) { 31 // UiDevToolsAgent:
32 void Init(protocol::UberDispatcher* dispatcher) override {
31 frontend_.reset( 33 frontend_.reset(
32 new typename DomainMetainfo::FrontendClass(dispatcher->channel())); 34 new typename DomainMetainfo::FrontendClass(dispatcher->channel()));
33 DomainMetainfo::DispatcherClass::wire(dispatcher, this); 35 DomainMetainfo::DispatcherClass::wire(dispatcher, this);
34 } 36 }
35 37
38 void Disable() override { disable(); }
39
40 // Common methods between all generated Backends, subclasses may
41 // choose to override them (but not necessary).
42 ui::devtools::protocol::Response enable() override {
43 return ui::devtools::protocol::Response::OK();
44 };
45
46 ui::devtools::protocol::Response disable() override {
47 return ui::devtools::protocol::Response::OK();
48 };
49
36 protected: 50 protected:
37 UiDevToolsBaseAgent() {} 51 UiDevToolsBaseAgent() {}
38 typename DomainMetainfo::FrontendClass* frontend() const { 52 typename DomainMetainfo::FrontendClass* frontend() const {
39 return frontend_.get(); 53 return frontend_.get();
40 } 54 }
41 55
42 private: 56 private:
43 std::unique_ptr<typename DomainMetainfo::FrontendClass> frontend_; 57 std::unique_ptr<typename DomainMetainfo::FrontendClass> frontend_;
44 58
45 DISALLOW_COPY_AND_ASSIGN(UiDevToolsBaseAgent); 59 DISALLOW_COPY_AND_ASSIGN(UiDevToolsBaseAgent);
46 }; 60 };
47 61
48 } // namespace devtools 62 } // namespace devtools
49 } // namespace ui 63 } // namespace ui
50 64
51 #endif // COMPONENTS_UI_DEVTOOLS_DEVTOOLS_BASE_AGENT_H_ 65 #endif // COMPONENTS_UI_DEVTOOLS_DEVTOOLS_BASE_AGENT_H_
OLDNEW
« 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