| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
| 3 * Copyright (C) 2009 Google Inc. All Rights Reserved. | 3 * Copyright (C) 2009 Google Inc. All Rights Reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 #include "core/inspector/WorkerInspectorController.h" | 41 #include "core/inspector/WorkerInspectorController.h" |
| 42 #include "core/loader/DocumentLoadTiming.h" | 42 #include "core/loader/DocumentLoadTiming.h" |
| 43 #include "core/loader/DocumentLoader.h" | 43 #include "core/loader/DocumentLoader.h" |
| 44 #include "core/workers/DedicatedWorkerGlobalScope.h" | 44 #include "core/workers/DedicatedWorkerGlobalScope.h" |
| 45 #include "core/workers/DedicatedWorkerThread.h" | 45 #include "core/workers/DedicatedWorkerThread.h" |
| 46 #include "core/workers/Worker.h" | 46 #include "core/workers/Worker.h" |
| 47 #include "core/workers/WorkerClients.h" | 47 #include "core/workers/WorkerClients.h" |
| 48 #include "core/workers/WorkerObjectProxy.h" | 48 #include "core/workers/WorkerObjectProxy.h" |
| 49 #include "core/workers/WorkerThreadStartupData.h" | 49 #include "core/workers/WorkerThreadStartupData.h" |
| 50 #include "platform/NotImplemented.h" | 50 #include "platform/NotImplemented.h" |
| 51 #include "platform/TraceEvent.h" |
| 51 #include "platform/heap/Handle.h" | 52 #include "platform/heap/Handle.h" |
| 52 #include "wtf/Functional.h" | 53 #include "wtf/Functional.h" |
| 53 #include "wtf/MainThread.h" | 54 #include "wtf/MainThread.h" |
| 54 | 55 |
| 55 namespace blink { | 56 namespace blink { |
| 56 | 57 |
| 57 class MessageWorkerGlobalScopeTask : public ExecutionContextTask { | 58 class MessageWorkerGlobalScopeTask : public ExecutionContextTask { |
| 58 public: | 59 public: |
| 59 static PassOwnPtr<MessageWorkerGlobalScopeTask> create(PassRefPtr<Serialized
ScriptValue> message, PassOwnPtr<MessagePortChannelArray> channels) | 60 static PassOwnPtr<MessageWorkerGlobalScopeTask> create(PassRefPtr<Serialized
ScriptValue> message, PassOwnPtr<MessagePortChannelArray> channels) |
| 60 { | 61 { |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 } | 247 } |
| 247 | 248 |
| 248 void WorkerMessagingProxy::sendMessageToInspector(const String& message) | 249 void WorkerMessagingProxy::sendMessageToInspector(const String& message) |
| 249 { | 250 { |
| 250 if (m_askedToTerminate) | 251 if (m_askedToTerminate) |
| 251 return; | 252 return; |
| 252 m_workerThread->postDebuggerTask(createCrossThreadTask(dispatchOnInspectorBa
ckendTask, String(message))); | 253 m_workerThread->postDebuggerTask(createCrossThreadTask(dispatchOnInspectorBa
ckendTask, String(message))); |
| 253 m_workerThread->interruptAndDispatchInspectorCommands(); | 254 m_workerThread->interruptAndDispatchInspectorCommands(); |
| 254 } | 255 } |
| 255 | 256 |
| 257 static void dispatchWriteTimelineStartedEvent(ExecutionContext* context, const S
tring& sessionId) |
| 258 { |
| 259 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Tracin
gStartedInWorker", "sessionId", sessionId.utf8()); |
| 260 } |
| 261 |
| 262 void WorkerMessagingProxy::writeTimelineStartedEvent(const String& sessionId) |
| 263 { |
| 264 if (m_askedToTerminate) |
| 265 return; |
| 266 OwnPtr<ExecutionContextTask> task = createCrossThreadTask(dispatchWriteTimel
ineStartedEvent, String(sessionId)); |
| 267 if (m_workerThread) |
| 268 m_workerThread->postTask(task.release()); |
| 269 else |
| 270 m_queuedEarlyTasks.append(task.release()); |
| 271 } |
| 272 |
| 256 void WorkerMessagingProxy::workerGlobalScopeDestroyed() | 273 void WorkerMessagingProxy::workerGlobalScopeDestroyed() |
| 257 { | 274 { |
| 258 // This method is always the last to be performed, so the proxy is not neede
d for communication | 275 // This method is always the last to be performed, so the proxy is not neede
d for communication |
| 259 // in either side any more. However, the Worker object may still exist, and
it assumes that the proxy exists, too. | 276 // in either side any more. However, the Worker object may still exist, and
it assumes that the proxy exists, too. |
| 260 m_askedToTerminate = true; | 277 m_askedToTerminate = true; |
| 261 m_workerThread = nullptr; | 278 m_workerThread = nullptr; |
| 262 | 279 |
| 263 InspectorInstrumentation::workerGlobalScopeTerminated(m_executionContext.get
(), this); | 280 InspectorInstrumentation::workerGlobalScopeTerminated(m_executionContext.get
(), this); |
| 264 | 281 |
| 265 if (m_mayBeDestroyed) | 282 if (m_mayBeDestroyed) |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 { | 314 { |
| 298 m_workerThreadHadPendingActivity = hasPendingActivity; | 315 m_workerThreadHadPendingActivity = hasPendingActivity; |
| 299 } | 316 } |
| 300 | 317 |
| 301 bool WorkerMessagingProxy::hasPendingActivity() const | 318 bool WorkerMessagingProxy::hasPendingActivity() const |
| 302 { | 319 { |
| 303 return (m_unconfirmedMessageCount || m_workerThreadHadPendingActivity) && !m
_askedToTerminate; | 320 return (m_unconfirmedMessageCount || m_workerThreadHadPendingActivity) && !m
_askedToTerminate; |
| 304 } | 321 } |
| 305 | 322 |
| 306 } // namespace blink | 323 } // namespace blink |
| OLD | NEW |