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

Side by Side Diff: Source/core/inspector/InspectorWorkerAgent.cpp

Issue 1253293002: Oilpan: Remove raw pointer to ExecutionContext from WorkerInspectorProxy (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 4 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #include "wtf/text/WTFString.h" 44 #include "wtf/text/WTFString.h"
45 45
46 namespace blink { 46 namespace blink {
47 47
48 namespace WorkerAgentState { 48 namespace WorkerAgentState {
49 static const char workerInspectionEnabled[] = "workerInspectionEnabled"; 49 static const char workerInspectionEnabled[] = "workerInspectionEnabled";
50 static const char autoconnectToWorkers[] = "autoconnectToWorkers"; 50 static const char autoconnectToWorkers[] = "autoconnectToWorkers";
51 }; 51 };
52 52
53 class InspectorWorkerAgent::WorkerAgentClient final : public WorkerInspectorProx y::PageInspector { 53 class InspectorWorkerAgent::WorkerAgentClient final : public WorkerInspectorProx y::PageInspector {
54 WTF_MAKE_FAST_ALLOCATED(InspectorWorkerAgent::WorkerAgentClient); 54 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED(InspectorWorkerAgent::WorkerAgentCli ent);
55 public: 55 public:
56 static PassOwnPtrWillBeRawPtr<WorkerAgentClient> create(InspectorFrontend::W orker* frontend, WorkerInspectorProxy* proxy, const String& id, PageConsoleAgent * consoleAgent)
57 {
58 return adoptPtrWillBeNoop(new WorkerAgentClient(frontend, proxy, id, con soleAgent));
59 }
60
56 WorkerAgentClient(InspectorFrontend::Worker* frontend, WorkerInspectorProxy* proxy, const String& id, PageConsoleAgent* consoleAgent) 61 WorkerAgentClient(InspectorFrontend::Worker* frontend, WorkerInspectorProxy* proxy, const String& id, PageConsoleAgent* consoleAgent)
57 : m_frontend(frontend) 62 : m_frontend(frontend)
58 , m_proxy(proxy) 63 , m_proxy(proxy)
59 , m_id(id) 64 , m_id(id)
60 , m_connected(false) 65 , m_connected(false)
61 , m_consoleAgent(consoleAgent) 66 , m_consoleAgent(consoleAgent)
62 { 67 {
63 ASSERT(!proxy->pageInspector()); 68 ASSERT(!proxy->pageInspector());
64 } 69 }
65 ~WorkerAgentClient() override 70 ~WorkerAgentClient() override
66 { 71 {
67 disconnectFromWorker(); 72 }
73 DEFINE_INLINE_VIRTUAL_TRACE()
74 {
75 visitor->trace(m_proxy);
76 visitor->trace(m_consoleAgent);
77 WorkerInspectorProxy::PageInspector::trace(visitor);
68 } 78 }
69 79
70 String id() const { return m_id; } 80 String id() const { return m_id; }
71 WorkerInspectorProxy* proxy() const { return m_proxy; } 81 WorkerInspectorProxy* proxy() const { return m_proxy; }
72 82
73 void connectToWorker() 83 void connectToWorker()
74 { 84 {
75 if (m_connected) 85 if (m_connected)
76 return; 86 return;
77 m_connected = true; 87 m_connected = true;
78 m_proxy->connectToInspector(this); 88 m_proxy->connectToInspector(this);
79 } 89 }
80 90
81 void disconnectFromWorker() 91 void disconnectFromWorker()
haraken 2015/07/30 07:47:31 Shall we: - Rename disconnectFromWorker to dispos
keishi 2015/08/03 09:35:56 Done.
82 { 92 {
83 if (!m_connected) 93 if (!m_connected)
84 return; 94 return;
85 m_connected = false; 95 m_connected = false;
86 m_proxy->disconnectFromInspector(); 96 m_proxy->disconnectFromInspector();
87 } 97 }
88 98
89 private: 99 private:
90 // WorkerInspectorProxy::PageInspector implementation 100 // WorkerInspectorProxy::PageInspector implementation
91 void dispatchMessageFromWorker(const String& message) override 101 void dispatchMessageFromWorker(const String& message) override
92 { 102 {
93 m_frontend->dispatchMessageFromWorker(m_id, message); 103 m_frontend->dispatchMessageFromWorker(m_id, message);
94 } 104 }
95 // WorkerInspectorProxy::PageInspector implementation 105 // WorkerInspectorProxy::PageInspector implementation
96 void workerConsoleAgentEnabled(WorkerGlobalScopeProxy* proxy) override 106 void workerConsoleAgentEnabled(WorkerGlobalScopeProxy* proxy) override
97 { 107 {
98 m_consoleAgent->workerConsoleAgentEnabled(proxy); 108 m_consoleAgent->workerConsoleAgentEnabled(proxy);
99 } 109 }
100 110
101 InspectorFrontend::Worker* m_frontend; 111 InspectorFrontend::Worker* m_frontend;
haraken 2015/07/30 07:47:31 Are you sure that this pointer doesn't become stal
keishi 2015/08/03 09:35:56 When FrontEnd is destroyed InspectorBaseAgent::cle
102 WorkerInspectorProxy* m_proxy; 112 RawPtrWillBeMember<WorkerInspectorProxy> m_proxy;
103 String m_id; 113 String m_id;
104 bool m_connected; 114 bool m_connected;
105 PageConsoleAgent* m_consoleAgent; 115 RawPtrWillBeMember<PageConsoleAgent> m_consoleAgent;
106 }; 116 };
107 117
108 PassOwnPtrWillBeRawPtr<InspectorWorkerAgent> InspectorWorkerAgent::create(PageCo nsoleAgent* consoleAgent) 118 PassOwnPtrWillBeRawPtr<InspectorWorkerAgent> InspectorWorkerAgent::create(PageCo nsoleAgent* consoleAgent)
109 { 119 {
110 return adoptPtrWillBeNoop(new InspectorWorkerAgent(consoleAgent)); 120 return adoptPtrWillBeNoop(new InspectorWorkerAgent(consoleAgent));
111 } 121 }
112 122
113 InspectorWorkerAgent::InspectorWorkerAgent(PageConsoleAgent* consoleAgent) 123 InspectorWorkerAgent::InspectorWorkerAgent(PageConsoleAgent* consoleAgent)
114 : InspectorBaseAgent<InspectorWorkerAgent, InspectorFrontend::Worker>("Worke r") 124 : InspectorBaseAgent<InspectorWorkerAgent, InspectorFrontend::Worker>("Worke r")
115 , m_consoleAgent(consoleAgent) 125 , m_consoleAgent(consoleAgent)
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 if (!m_tracingSessionId.isEmpty()) 212 if (!m_tracingSessionId.isEmpty())
203 workerInspectorProxy->writeTimelineStartedEvent(m_tracingSessionId, id); 213 workerInspectorProxy->writeTimelineStartedEvent(m_tracingSessionId, id);
204 } 214 }
205 215
206 void InspectorWorkerAgent::workerTerminated(WorkerInspectorProxy* proxy) 216 void InspectorWorkerAgent::workerTerminated(WorkerInspectorProxy* proxy)
207 { 217 {
208 m_workerInfos.remove(proxy); 218 m_workerInfos.remove(proxy);
209 for (WorkerClients::iterator it = m_idToClient.begin(); it != m_idToClient.e nd(); ++it) { 219 for (WorkerClients::iterator it = m_idToClient.begin(); it != m_idToClient.e nd(); ++it) {
210 if (proxy == it->value->proxy()) { 220 if (proxy == it->value->proxy()) {
211 frontend()->workerTerminated(it->key); 221 frontend()->workerTerminated(it->key);
212 delete it->value; 222 it->value->disconnectFromWorker();
213 m_idToClient.remove(it); 223 m_idToClient.remove(it);
214 return; 224 return;
215 } 225 }
216 } 226 }
217 } 227 }
218 228
219 void InspectorWorkerAgent::createWorkerAgentClientsForExistingWorkers() 229 void InspectorWorkerAgent::createWorkerAgentClientsForExistingWorkers()
220 { 230 {
221 for (auto& info : m_workerInfos) 231 for (auto& info : m_workerInfos)
222 createWorkerAgentClient(info.key, info.value.url, info.value.id); 232 createWorkerAgentClient(info.key, info.value.url, info.value.id);
223 } 233 }
224 234
225 void InspectorWorkerAgent::destroyWorkerAgentClients() 235 void InspectorWorkerAgent::destroyWorkerAgentClients()
226 { 236 {
227 for (auto& client : m_idToClient) { 237 for (auto& client : m_idToClient) {
yurys 2015/07/30 09:01:39 style nit: drop {}
keishi 2015/08/03 09:35:56 Done.
228 client.value->disconnectFromWorker(); 238 client.value->disconnectFromWorker();
229 delete client.value;
230 } 239 }
231 m_idToClient.clear(); 240 m_idToClient.clear();
232 } 241 }
233 242
234 void InspectorWorkerAgent::createWorkerAgentClient(WorkerInspectorProxy* workerI nspectorProxy, const String& url, const String& id) 243 void InspectorWorkerAgent::createWorkerAgentClient(WorkerInspectorProxy* workerI nspectorProxy, const String& url, const String& id)
235 { 244 {
236 WorkerAgentClient* client = new WorkerAgentClient(frontend(), workerInspecto rProxy, id, m_consoleAgent); 245 WorkerAgentClient* client = m_idToClient.set(id, WorkerAgentClient::create(f rontend(), workerInspectorProxy, id, m_consoleAgent)).storedValue->value.get();
yurys 2015/07/30 09:01:39 Please extract client creation on a separate line
keishi 2015/08/03 09:35:56 Done.
237 m_idToClient.set(id, client);
238 246
239 ASSERT(frontend()); 247 ASSERT(frontend());
240 bool autoconnectToWorkers = m_state->getBoolean(WorkerAgentState::autoconnec tToWorkers); 248 bool autoconnectToWorkers = m_state->getBoolean(WorkerAgentState::autoconnec tToWorkers);
241 if (autoconnectToWorkers) 249 if (autoconnectToWorkers)
242 client->connectToWorker(); 250 client->connectToWorker();
243 frontend()->workerCreated(id, url, autoconnectToWorkers); 251 frontend()->workerCreated(id, url, autoconnectToWorkers);
244 } 252 }
245 253
254 DEFINE_TRACE(InspectorWorkerAgent)
255 {
256 #if ENABLE(OILPAN)
257 visitor->trace(m_idToClient);
258 #endif
259 InspectorBaseAgent<InspectorWorkerAgent, InspectorFrontend::Worker>::trace(v isitor);
260 }
261
246 } // namespace blink 262 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698