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

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

Issue 2470933002: Disable agents when client disconnects (Closed)
Patch Set: 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
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 void Init(protocol::UberDispatcher* dispatcher) override {
sadrul 2016/11/02 01:45:38 Before this line, add: // UiDevToolsAgent:
Sarmad Hashmi 2016/11/02 02:43:53 Done.
31 frontend_.reset( 32 frontend_.reset(
32 new typename DomainMetainfo::FrontendClass(dispatcher->channel())); 33 new typename DomainMetainfo::FrontendClass(dispatcher->channel()));
33 DomainMetainfo::DispatcherClass::wire(dispatcher, this); 34 DomainMetainfo::DispatcherClass::wire(dispatcher, this);
34 } 35 }
35 36
37 void Disable() override {
38 protocol::ErrorString error;
39 disable(&error);
40 }
41
42 // Common methods between all generated Backends, subclasses may
43 // choose to override them (but not necessary).
44 void enable(protocol::ErrorString*) override {}
45 void disable(protocol::ErrorString*) override {}
46
36 protected: 47 protected:
37 UiDevToolsBaseAgent() {} 48 UiDevToolsBaseAgent() {}
38 typename DomainMetainfo::FrontendClass* frontend() const { 49 typename DomainMetainfo::FrontendClass* frontend() const {
39 return frontend_.get(); 50 return frontend_.get();
40 } 51 }
41 52
42 private: 53 private:
43 std::unique_ptr<typename DomainMetainfo::FrontendClass> frontend_; 54 std::unique_ptr<typename DomainMetainfo::FrontendClass> frontend_;
44 55
45 DISALLOW_COPY_AND_ASSIGN(UiDevToolsBaseAgent); 56 DISALLOW_COPY_AND_ASSIGN(UiDevToolsBaseAgent);
46 }; 57 };
47 58
48 } // namespace devtools 59 } // namespace devtools
49 } // namespace ui 60 } // namespace ui
50 61
51 #endif // COMPONENTS_UI_DEVTOOLS_DEVTOOLS_BASE_AGENT_H_ 62 #endif // COMPONENTS_UI_DEVTOOLS_DEVTOOLS_BASE_AGENT_H_
OLDNEW
« no previous file with comments | « no previous file | components/ui_devtools/devtools_client.h » ('j') | components/ui_devtools/devtools_client.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698