| 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 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 #include "config.h" | 27 #include "config.h" |
| 28 #include "core/dom/MessageChannel.h" | 28 #include "core/dom/MessageChannel.h" |
| 29 | 29 |
| 30 #include "core/dom/MessagePort.h" | 30 #include "core/dom/MessagePort.h" |
| 31 #include "public/platform/Platform.h" | 31 #include "public/platform/Platform.h" |
| 32 #include "public/platform/WebMessagePortChannel.h" | 32 #include "public/platform/WebMessagePortChannel.h" |
| 33 | 33 |
| 34 namespace WebCore { | 34 namespace WebCore { |
| 35 | 35 |
| 36 DEFINE_GC_INFO(MessageChannel); |
| 37 |
| 36 static void createChannel(MessagePort* port1, MessagePort* port2) | 38 static void createChannel(MessagePort* port1, MessagePort* port2) |
| 37 { | 39 { |
| 38 // Create proxies for each endpoint. | 40 // Create proxies for each endpoint. |
| 39 OwnPtr<blink::WebMessagePortChannel> channel1 = adoptPtr(blink::Platform::cu
rrent()->createMessagePortChannel()); | 41 OwnPtr<blink::WebMessagePortChannel> channel1 = adoptPtr(blink::Platform::cu
rrent()->createMessagePortChannel()); |
| 40 OwnPtr<blink::WebMessagePortChannel> channel2 = adoptPtr(blink::Platform::cu
rrent()->createMessagePortChannel()); | 42 OwnPtr<blink::WebMessagePortChannel> channel2 = adoptPtr(blink::Platform::cu
rrent()->createMessagePortChannel()); |
| 41 | 43 |
| 42 // Entangle the two endpoints. | 44 // Entangle the two endpoints. |
| 43 channel1->entangle(channel2.get()); | 45 channel1->entangle(channel2.get()); |
| 44 channel2->entangle(channel1.get()); | 46 channel2->entangle(channel1.get()); |
| 45 | 47 |
| 46 // Now entangle the proxies with the appropriate local ports. | 48 // Now entangle the proxies with the appropriate local ports. |
| 47 port1->entangle(channel2.release()); | 49 port1->entangle(channel2.release()); |
| 48 port2->entangle(channel1.release()); | 50 port2->entangle(channel1.release()); |
| 49 } | 51 } |
| 50 | 52 |
| 51 MessageChannel::MessageChannel(ExecutionContext* context) | 53 MessageChannel::MessageChannel(ExecutionContext* context) |
| 52 : m_port1(MessagePort::create(*context)) | 54 : m_port1(MessagePort::create(*context)) |
| 53 , m_port2(MessagePort::create(*context)) | 55 , m_port2(MessagePort::create(*context)) |
| 54 { | 56 { |
| 55 ScriptWrappable::init(this); | 57 ScriptWrappable::init(this); |
| 56 createChannel(m_port1.get(), m_port2.get()); | 58 createChannel(m_port1.get(), m_port2.get()); |
| 57 } | 59 } |
| 58 | 60 |
| 59 MessageChannel::~MessageChannel() | 61 MessageChannel::~MessageChannel() |
| 60 { | 62 { |
| 61 } | 63 } |
| 62 | 64 |
| 65 void MessageChannel::trace(Visitor* visitor) |
| 66 { |
| 67 visitor->trace(m_port1); |
| 68 visitor->trace(m_port2); |
| 69 } |
| 70 |
| 63 } // namespace WebCore | 71 } // namespace WebCore |
| OLD | NEW |