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