OLD | NEW |
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 16 matching lines...) Expand all Loading... |
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 InspectorWorkerAgent_h | 31 #ifndef InspectorWorkerAgent_h |
32 #define InspectorWorkerAgent_h | 32 #define InspectorWorkerAgent_h |
33 | 33 |
34 #include "core/CoreExport.h" | 34 #include "core/CoreExport.h" |
35 #include "core/InspectorFrontend.h" | 35 #include "core/InspectorFrontend.h" |
36 #include "core/inspector/InspectorBaseAgent.h" | 36 #include "core/inspector/InspectorBaseAgent.h" |
| 37 #include "core/workers/WorkerInspectorProxy.h" |
37 #include "wtf/Forward.h" | 38 #include "wtf/Forward.h" |
38 #include "wtf/HashMap.h" | 39 #include "wtf/HashMap.h" |
39 | 40 |
40 namespace blink { | 41 namespace blink { |
41 class PageConsoleAgent; | 42 class PageConsoleAgent; |
42 class KURL; | 43 class KURL; |
43 class WorkerInspectorProxy; | 44 class WorkerInspectorProxy; |
44 | 45 |
45 typedef String ErrorString; | 46 typedef String ErrorString; |
46 | 47 |
47 class CORE_EXPORT InspectorWorkerAgent final : public InspectorBaseAgent<Inspect
orWorkerAgent, InspectorFrontend::Worker>, public InspectorBackendDispatcher::Wo
rkerCommandHandler { | 48 class CORE_EXPORT InspectorWorkerAgent final : public InspectorBaseAgent<Inspect
orWorkerAgent, InspectorFrontend::Worker>, public InspectorBackendDispatcher::Wo
rkerCommandHandler { |
| 49 WTF_MAKE_NONCOPYABLE(InspectorWorkerAgent); |
48 public: | 50 public: |
49 static PassOwnPtrWillBeRawPtr<InspectorWorkerAgent> create(PageConsoleAgent*
); | 51 static PassOwnPtrWillBeRawPtr<InspectorWorkerAgent> create(PageConsoleAgent*
); |
50 ~InspectorWorkerAgent() override; | 52 ~InspectorWorkerAgent() override; |
51 DECLARE_VIRTUAL_TRACE(); | 53 DECLARE_VIRTUAL_TRACE(); |
52 | 54 |
53 void init() override; | 55 void init() override; |
54 void disable(ErrorString*) override; | 56 void disable(ErrorString*) override; |
55 void restore() override; | 57 void restore() override; |
56 | 58 |
57 // Called from InspectorInstrumentation | 59 // Called from InspectorInstrumentation |
58 bool shouldPauseDedicatedWorkerOnStart(); | 60 bool shouldPauseDedicatedWorkerOnStart(); |
59 void didStartWorker(WorkerInspectorProxy*, const KURL&); | 61 void didStartWorker(WorkerInspectorProxy*, const KURL&); |
60 void workerTerminated(WorkerInspectorProxy*); | 62 void workerTerminated(WorkerInspectorProxy*); |
61 | 63 |
62 // Called from InspectorBackendDispatcher | 64 // Called from InspectorBackendDispatcher |
63 void enable(ErrorString*) override; | 65 void enable(ErrorString*) override; |
64 void connectToWorker(ErrorString*, const String& workerId) override; | 66 void connectToWorker(ErrorString*, const String& workerId) override; |
65 void disconnectFromWorker(ErrorString*, const String& workerId) override; | 67 void disconnectFromWorker(ErrorString*, const String& workerId) override; |
66 void sendMessageToWorker(ErrorString*, const String& workerId, const String&
message) override; | 68 void sendMessageToWorker(ErrorString*, const String& workerId, const String&
message) override; |
67 void setAutoconnectToWorkers(ErrorString*, bool value) override; | 69 void setAutoconnectToWorkers(ErrorString*, bool value) override; |
68 | 70 |
69 void setTracingSessionId(const String&); | 71 void setTracingSessionId(const String&); |
70 | 72 |
| 73 class WorkerAgentClient final : public WorkerInspectorProxy::PageInspector { |
| 74 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED(InspectorWorkerAgent::WorkerAgen
tClient); |
| 75 public: |
| 76 static PassOwnPtrWillBeRawPtr<WorkerAgentClient> create(InspectorFronten
d::Worker*, WorkerInspectorProxy*, const String& id, PageConsoleAgent*); |
| 77 WorkerAgentClient(InspectorFrontend::Worker*, WorkerInspectorProxy*, con
st String& id, PageConsoleAgent*); |
| 78 ~WorkerAgentClient() override; |
| 79 DECLARE_VIRTUAL_TRACE(); |
| 80 |
| 81 String id() const { return m_id; } |
| 82 WorkerInspectorProxy* proxy() const { return m_proxy; } |
| 83 |
| 84 void connectToWorker(); |
| 85 void dispose(); |
| 86 |
| 87 private: |
| 88 // WorkerInspectorProxy::PageInspector implementation |
| 89 void dispatchMessageFromWorker(const String& message) override; |
| 90 void workerConsoleAgentEnabled(WorkerGlobalScopeProxy*) override; |
| 91 |
| 92 InspectorFrontend::Worker* m_frontend; |
| 93 RawPtrWillBeMember<WorkerInspectorProxy> m_proxy; |
| 94 String m_id; |
| 95 bool m_connected; |
| 96 RawPtrWillBeMember<PageConsoleAgent> m_consoleAgent; |
| 97 }; |
| 98 |
71 private: | 99 private: |
72 InspectorWorkerAgent(PageConsoleAgent*); | 100 InspectorWorkerAgent(PageConsoleAgent*); |
73 void createWorkerAgentClientsForExistingWorkers(); | 101 void createWorkerAgentClientsForExistingWorkers(); |
74 void createWorkerAgentClient(WorkerInspectorProxy*, const String& url, const
String& id); | 102 void createWorkerAgentClient(WorkerInspectorProxy*, const String& url, const
String& id); |
75 void destroyWorkerAgentClients(); | 103 void destroyWorkerAgentClients(); |
76 | 104 |
77 class WorkerInfo { | 105 class WorkerInfo { |
78 public: | 106 public: |
79 WorkerInfo() { } | 107 WorkerInfo() { } |
80 WorkerInfo(const String& url, const String& id) : url(url), id(id) { } | 108 WorkerInfo(const String& url, const String& id) : url(url), id(id) { } |
81 String url; | 109 String url; |
82 String id; | 110 String id; |
83 }; | 111 }; |
84 class WorkerAgentClient; | 112 |
85 typedef HashMap<String, WorkerAgentClient*> WorkerClients; | 113 typedef WillBeHeapHashMap<String, OwnPtrWillBeMember<WorkerAgentClient>> Wor
kerClients; |
86 WorkerClients m_idToClient; | 114 WorkerClients m_idToClient; |
87 typedef HashMap<WorkerInspectorProxy*, WorkerInfo> WorkerInfos; | 115 typedef HashMap<WorkerInspectorProxy*, WorkerInfo> WorkerInfos; |
88 WorkerInfos m_workerInfos; | 116 WorkerInfos m_workerInfos; |
89 String m_tracingSessionId; | 117 String m_tracingSessionId; |
90 RawPtrWillBeMember<PageConsoleAgent> m_consoleAgent; | 118 RawPtrWillBeMember<PageConsoleAgent> m_consoleAgent; |
91 }; | 119 }; |
92 | 120 |
93 } // namespace blink | 121 } // namespace blink |
94 | 122 |
95 #endif // !defined(InspectorWorkerAgent_h) | 123 #endif // !defined(InspectorWorkerAgent_h) |
OLD | NEW |