| 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 27 matching lines...) Expand all Loading... |
| 38 #include "core/inspector/ConsoleMessage.h" | 38 #include "core/inspector/ConsoleMessage.h" |
| 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/text/AtomicString.h" | 42 #include "wtf/text/AtomicString.h" |
| 43 | 43 |
| 44 namespace blink { | 44 namespace blink { |
| 45 | 45 |
| 46 MessagePort* MessagePort::create(ExecutionContext& executionContext) | 46 MessagePort* MessagePort::create(ExecutionContext& executionContext) |
| 47 { | 47 { |
| 48 MessagePort* port = new MessagePort(executionContext); | 48 return new MessagePort(executionContext); |
| 49 port->suspendIfNeeded(); | |
| 50 return port; | |
| 51 } | 49 } |
| 52 | 50 |
| 53 MessagePort::MessagePort(ExecutionContext& executionContext) | 51 MessagePort::MessagePort(ExecutionContext& executionContext) |
| 54 : ActiveDOMObject(&executionContext) | 52 : ContextLifecycleObserver(&executionContext) |
| 55 , m_started(false) | 53 , m_started(false) |
| 56 , m_closed(false) | 54 , m_closed(false) |
| 57 , m_weakFactory(this) | 55 , m_weakFactory(this) |
| 58 { | 56 { |
| 59 } | 57 } |
| 60 | 58 |
| 61 MessagePort::~MessagePort() | 59 MessagePort::~MessagePort() |
| 62 { | 60 { |
| 63 close(); | 61 close(); |
| 64 if (m_scriptStateForConversion) | 62 if (m_scriptStateForConversion) |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 for (unsigned i = 0; i < channels->size(); ++i) { | 269 for (unsigned i = 0; i < channels->size(); ++i) { |
| 272 MessagePort* port = MessagePort::create(context); | 270 MessagePort* port = MessagePort::create(context); |
| 273 port->entangle((*channels)[i].release()); | 271 port->entangle((*channels)[i].release()); |
| 274 (*portArray)[i] = port; | 272 (*portArray)[i] = port; |
| 275 } | 273 } |
| 276 return portArray; | 274 return portArray; |
| 277 } | 275 } |
| 278 | 276 |
| 279 DEFINE_TRACE(MessagePort) | 277 DEFINE_TRACE(MessagePort) |
| 280 { | 278 { |
| 281 ActiveDOMObject::trace(visitor); | 279 ContextLifecycleObserver::trace(visitor); |
| 282 RefCountedGarbageCollectedEventTargetWithInlineData<MessagePort>::trace(visi
tor); | 280 RefCountedGarbageCollectedEventTargetWithInlineData<MessagePort>::trace(visi
tor); |
| 283 } | 281 } |
| 284 | 282 |
| 285 v8::Isolate* MessagePort::scriptIsolate() | 283 v8::Isolate* MessagePort::scriptIsolate() |
| 286 { | 284 { |
| 287 ASSERT(executionContext()); | 285 ASSERT(executionContext()); |
| 288 return toIsolate(executionContext()); | 286 return toIsolate(executionContext()); |
| 289 } | 287 } |
| 290 | 288 |
| 291 v8::Local<v8::Context> MessagePort::scriptContextForMessageConversion() | 289 v8::Local<v8::Context> MessagePort::scriptContextForMessageConversion() |
| 292 { | 290 { |
| 293 ASSERT(executionContext()); | 291 ASSERT(executionContext()); |
| 294 if (!m_scriptStateForConversion) { | 292 if (!m_scriptStateForConversion) { |
| 295 v8::Isolate* isolate = scriptIsolate(); | 293 v8::Isolate* isolate = scriptIsolate(); |
| 296 m_scriptStateForConversion = ScriptState::create(v8::Context::New(isolat
e), DOMWrapperWorld::create(isolate)); | 294 m_scriptStateForConversion = ScriptState::create(v8::Context::New(isolat
e), DOMWrapperWorld::create(isolate)); |
| 297 } | 295 } |
| 298 return m_scriptStateForConversion->context(); | 296 return m_scriptStateForConversion->context(); |
| 299 } | 297 } |
| 300 | 298 |
| 301 } // namespace blink | 299 } // namespace blink |
| OLD | NEW |