| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 #include "core/workers/WorkerGlobalScope.h" | 39 #include "core/workers/WorkerGlobalScope.h" |
| 40 #include "public/platform/WebString.h" | 40 #include "public/platform/WebString.h" |
| 41 #include "wtf/Functional.h" | 41 #include "wtf/Functional.h" |
| 42 #include "wtf/PtrUtil.h" | 42 #include "wtf/PtrUtil.h" |
| 43 #include "wtf/text/AtomicString.h" | 43 #include "wtf/text/AtomicString.h" |
| 44 #include <memory> | 44 #include <memory> |
| 45 | 45 |
| 46 namespace blink { | 46 namespace blink { |
| 47 | 47 |
| 48 MessagePort* MessagePort::create(ExecutionContext& executionContext) { | 48 MessagePort* MessagePort::create(ExecutionContext& executionContext) { |
| 49 MessagePort* port = new MessagePort(executionContext); | 49 return new MessagePort(executionContext); |
| 50 port->suspendIfNeeded(); | |
| 51 return port; | |
| 52 } | 50 } |
| 53 | 51 |
| 54 MessagePort::MessagePort(ExecutionContext& executionContext) | 52 MessagePort::MessagePort(ExecutionContext& executionContext) |
| 55 : SuspendableObject(&executionContext), m_started(false), m_closed(false) {} | 53 : ContextLifecycleObserver(&executionContext), |
| 54 m_started(false), |
| 55 m_closed(false) {} |
| 56 | 56 |
| 57 MessagePort::~MessagePort() { | 57 MessagePort::~MessagePort() { |
| 58 DCHECK(!m_started || !isEntangled()); | 58 DCHECK(!m_started || !isEntangled()); |
| 59 } | 59 } |
| 60 | 60 |
| 61 void MessagePort::postMessage(ExecutionContext* context, | 61 void MessagePort::postMessage(ExecutionContext* context, |
| 62 PassRefPtr<SerializedScriptValue> message, | 62 PassRefPtr<SerializedScriptValue> message, |
| 63 const MessagePortArray& ports, | 63 const MessagePortArray& ports, |
| 64 ExceptionState& exceptionState) { | 64 ExceptionState& exceptionState) { |
| 65 if (!isEntangled()) | 65 if (!isEntangled()) |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 MessagePortArray* portArray = new MessagePortArray(channels->size()); | 284 MessagePortArray* portArray = new MessagePortArray(channels->size()); |
| 285 for (unsigned i = 0; i < channels->size(); ++i) { | 285 for (unsigned i = 0; i < channels->size(); ++i) { |
| 286 MessagePort* port = MessagePort::create(context); | 286 MessagePort* port = MessagePort::create(context); |
| 287 port->entangle(std::move((*channels)[i])); | 287 port->entangle(std::move((*channels)[i])); |
| 288 (*portArray)[i] = port; | 288 (*portArray)[i] = port; |
| 289 } | 289 } |
| 290 return portArray; | 290 return portArray; |
| 291 } | 291 } |
| 292 | 292 |
| 293 DEFINE_TRACE(MessagePort) { | 293 DEFINE_TRACE(MessagePort) { |
| 294 SuspendableObject::trace(visitor); | 294 ContextLifecycleObserver::trace(visitor); |
| 295 EventTargetWithInlineData::trace(visitor); | 295 EventTargetWithInlineData::trace(visitor); |
| 296 } | 296 } |
| 297 | 297 |
| 298 } // namespace blink | 298 } // namespace blink |
| OLD | NEW |