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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 namespace WebCore { | 44 namespace WebCore { |
45 | 45 |
46 class Event; | 46 class Event; |
47 class ExceptionState; | 47 class ExceptionState; |
48 class LocalFrame; | 48 class LocalFrame; |
49 class MessagePort; | 49 class MessagePort; |
50 class ExecutionContext; | 50 class ExecutionContext; |
51 class SerializedScriptValue; | 51 class SerializedScriptValue; |
52 | 52 |
53 // The overwhelmingly common case is sending a single port, so handle that effic
iently with an inline buffer of size 1. | 53 // The overwhelmingly common case is sending a single port, so handle that effic
iently with an inline buffer of size 1. |
54 typedef Vector<RefPtr<MessagePort>, 1> MessagePortArray; | 54 typedef WillBeHeapVector<RefPtrWillBeMember<MessagePort>, 1> MessagePortArray; |
55 | 55 |
56 // Not to be confused with blink::WebMessagePortChannelArray; this one uses Vect
or and OwnPtr instead of WebVector and raw pointers. | 56 // Not to be confused with blink::WebMessagePortChannelArray; this one uses Vect
or and OwnPtr instead of WebVector and raw pointers. |
57 typedef Vector<OwnPtr<blink::WebMessagePortChannel>, 1> MessagePortChannelArray; | 57 typedef Vector<OwnPtr<blink::WebMessagePortChannel>, 1> MessagePortChannelArray; |
58 | 58 |
59 class MessagePort FINAL : public RefCountedWillBeRefCountedGarbageCollected<Mess
agePort> | 59 class MessagePort FINAL : public RefCountedWillBeRefCountedGarbageCollected<Mess
agePort> |
60 , public ActiveDOMObject | 60 , public ActiveDOMObject |
61 , public EventTargetWithInlineData | 61 , public EventTargetWithInlineData |
62 , public ScriptWrappable | 62 , public ScriptWrappable |
63 , public blink::WebMessagePortChannelClient { | 63 , public blink::WebMessagePortChannelClient { |
64 REFCOUNTED_EVENT_TARGET(MessagePort); | 64 REFCOUNTED_EVENT_TARGET(MessagePort); |
65 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(MessagePort); | 65 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(MessagePort); |
66 public: | 66 public: |
67 static PassRefPtrWillBeRawPtr<MessagePort> create(ExecutionContext&); | 67 static PassRefPtrWillBeRawPtr<MessagePort> create(ExecutionContext&); |
68 virtual ~MessagePort(); | 68 virtual ~MessagePort(); |
69 | 69 |
70 void postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePor
tArray*, ExceptionState&); | 70 void postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePor
tArray*, ExceptionState&); |
71 | 71 |
72 void start(); | 72 void start(); |
73 void close(); | 73 void close(); |
74 | 74 |
75 void entangle(PassOwnPtr<blink::WebMessagePortChannel>); | 75 void entangle(PassOwnPtr<blink::WebMessagePortChannel>); |
76 PassOwnPtr<blink::WebMessagePortChannel> disentangle(); | 76 PassOwnPtr<blink::WebMessagePortChannel> disentangle(); |
77 | 77 |
78 static PassOwnPtr<blink::WebMessagePortChannelArray> toWebMessagePortChannel
Array(PassOwnPtr<MessagePortChannelArray>); | 78 static PassOwnPtr<blink::WebMessagePortChannelArray> toWebMessagePortChannel
Array(PassOwnPtr<MessagePortChannelArray>); |
79 static PassOwnPtr<MessagePortArray> toMessagePortArray(ExecutionContext*, co
nst blink::WebMessagePortChannelArray&); | 79 static PassOwnPtrWillBeRawPtr<MessagePortArray> toMessagePortArray(Execution
Context*, const blink::WebMessagePortChannelArray&); |
80 | 80 |
81 // Returns 0 if there is an exception, or if the passed-in array is 0/empty. | 81 // Returns 0 if there is an exception, or if the passed-in array is 0/empty. |
82 static PassOwnPtr<MessagePortChannelArray> disentanglePorts(const MessagePor
tArray*, ExceptionState&); | 82 static PassOwnPtr<MessagePortChannelArray> disentanglePorts(const MessagePor
tArray*, ExceptionState&); |
83 | 83 |
84 // Returns 0 if the passed array is 0/empty. | 84 // Returns 0 if the passed array is 0/empty. |
85 static PassOwnPtr<MessagePortArray> entanglePorts(ExecutionContext&, PassOwn
Ptr<MessagePortChannelArray>); | 85 static PassOwnPtrWillBeRawPtr<MessagePortArray> entanglePorts(ExecutionConte
xt&, PassOwnPtr<MessagePortChannelArray>); |
86 | 86 |
87 bool started() const { return m_started; } | 87 bool started() const { return m_started; } |
88 | 88 |
89 virtual const AtomicString& interfaceName() const OVERRIDE; | 89 virtual const AtomicString& interfaceName() const OVERRIDE; |
90 virtual ExecutionContext* executionContext() const OVERRIDE { return ActiveD
OMObject::executionContext(); } | 90 virtual ExecutionContext* executionContext() const OVERRIDE { return ActiveD
OMObject::executionContext(); } |
91 virtual MessagePort* toMessagePort() OVERRIDE { return this; } | 91 virtual MessagePort* toMessagePort() OVERRIDE { return this; } |
92 | 92 |
93 // ActiveDOMObject implementation. | 93 // ActiveDOMObject implementation. |
94 virtual bool hasPendingActivity() const OVERRIDE; | 94 virtual bool hasPendingActivity() const OVERRIDE; |
95 virtual void stop() OVERRIDE { close(); } | 95 virtual void stop() OVERRIDE { close(); } |
(...skipping 22 matching lines...) Expand all Loading... |
118 | 118 |
119 bool m_started; | 119 bool m_started; |
120 bool m_closed; | 120 bool m_closed; |
121 | 121 |
122 WeakPtrFactory<MessagePort> m_weakFactory; | 122 WeakPtrFactory<MessagePort> m_weakFactory; |
123 }; | 123 }; |
124 | 124 |
125 } // namespace WebCore | 125 } // namespace WebCore |
126 | 126 |
127 #endif // MessagePort_h | 127 #endif // MessagePort_h |
OLD | NEW |