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

Side by Side Diff: third_party/WebKit/Source/core/inspector/InspectorBaseAgent.h

Issue 2760363002: [instrumentation] Generalize instrumentation to be used beyond the core layer (Closed)
Patch Set: Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 14 matching lines...) Expand all
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #ifndef InspectorBaseAgent_h 31 #ifndef InspectorBaseAgent_h
32 #define InspectorBaseAgent_h 32 #define InspectorBaseAgent_h
33 33
34 #include "core/CoreExport.h" 34 #include "core/CoreExport.h"
35 #include "core/InstrumentingAgents.h" 35 #include "core/InspectorInstrumentationAgents.h"
36 #include "core/inspector/protocol/Protocol.h" 36 #include "core/inspector/protocol/Protocol.h"
37 #include "platform/heap/Handle.h" 37 #include "platform/heap/Handle.h"
38 #include "wtf/Forward.h" 38 #include "wtf/Forward.h"
39 #include "wtf/text/WTFString.h" 39 #include "wtf/text/WTFString.h"
40 40
41 namespace blink { 41 namespace blink {
42 42
43 class LocalFrame; 43 class LocalFrame;
44 44
45 class CORE_EXPORT InspectorAgent 45 class CORE_EXPORT InspectorAgent
46 : public GarbageCollectedFinalized<InspectorAgent> { 46 : public GarbageCollectedFinalized<InspectorAgent> {
47 public: 47 public:
48 InspectorAgent() {} 48 InspectorAgent() {}
49 virtual ~InspectorAgent() {} 49 virtual ~InspectorAgent() {}
50 DEFINE_INLINE_VIRTUAL_TRACE() {} 50 DEFINE_INLINE_VIRTUAL_TRACE() {}
51 51
52 virtual void restore() {} 52 virtual void restore() {}
53 virtual void didCommitLoadForLocalFrame(LocalFrame*) {} 53 virtual void didCommitLoadForLocalFrame(LocalFrame*) {}
54 virtual void flushPendingProtocolNotifications() {} 54 virtual void flushPendingProtocolNotifications() {}
55 55
56 virtual void init(InstrumentingAgents*, 56 virtual void init(InspectorInstrumentationAgents*,
57 protocol::UberDispatcher*, 57 protocol::UberDispatcher*,
58 protocol::DictionaryValue*) = 0; 58 protocol::DictionaryValue*) = 0;
59 virtual void dispose() = 0; 59 virtual void dispose() = 0;
60 }; 60 };
61 61
62 template <typename DomainMetainfo> 62 template <typename DomainMetainfo>
63 class InspectorBaseAgent : public InspectorAgent, 63 class InspectorBaseAgent : public InspectorAgent,
64 public DomainMetainfo::BackendClass { 64 public DomainMetainfo::BackendClass {
65 public: 65 public:
66 ~InspectorBaseAgent() override {} 66 ~InspectorBaseAgent() override {}
67 67
68 void init(InstrumentingAgents* instrumentingAgents, 68 void init(InspectorInstrumentationAgents* instrumentingAgents,
69 protocol::UberDispatcher* dispatcher, 69 protocol::UberDispatcher* dispatcher,
70 protocol::DictionaryValue* state) override { 70 protocol::DictionaryValue* state) override {
71 m_instrumentingAgents = instrumentingAgents; 71 m_instrumentingAgents = instrumentingAgents;
72 m_frontend.reset( 72 m_frontend.reset(
73 new typename DomainMetainfo::FrontendClass(dispatcher->channel())); 73 new typename DomainMetainfo::FrontendClass(dispatcher->channel()));
74 DomainMetainfo::DispatcherClass::wire(dispatcher, this); 74 DomainMetainfo::DispatcherClass::wire(dispatcher, this);
75 75
76 m_state = state->getObject(DomainMetainfo::domainName); 76 m_state = state->getObject(DomainMetainfo::domainName);
77 if (!m_state) { 77 if (!m_state) {
78 std::unique_ptr<protocol::DictionaryValue> newState = 78 std::unique_ptr<protocol::DictionaryValue> newState =
(...skipping 16 matching lines...) Expand all
95 visitor->trace(m_instrumentingAgents); 95 visitor->trace(m_instrumentingAgents);
96 InspectorAgent::trace(visitor); 96 InspectorAgent::trace(visitor);
97 } 97 }
98 98
99 protected: 99 protected:
100 InspectorBaseAgent() {} 100 InspectorBaseAgent() {}
101 101
102 typename DomainMetainfo::FrontendClass* frontend() const { 102 typename DomainMetainfo::FrontendClass* frontend() const {
103 return m_frontend.get(); 103 return m_frontend.get();
104 } 104 }
105 Member<InstrumentingAgents> m_instrumentingAgents; 105 Member<InspectorInstrumentationAgents> m_instrumentingAgents;
106 protocol::DictionaryValue* m_state; 106 protocol::DictionaryValue* m_state;
107 107
108 private: 108 private:
109 std::unique_ptr<typename DomainMetainfo::FrontendClass> m_frontend; 109 std::unique_ptr<typename DomainMetainfo::FrontendClass> m_frontend;
110 }; 110 };
111 111
112 } // namespace blink 112 } // namespace blink
113 113
114 #endif // !defined(InspectorBaseAgent_h) 114 #endif // !defined(InspectorBaseAgent_h)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698