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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 namespace blink { | 43 namespace blink { |
44 | 44 |
45 class ExceptionState; | 45 class ExceptionState; |
46 class MessagePort; | 46 class MessagePort; |
47 class ExecutionContext; | 47 class ExecutionContext; |
48 class SerializedScriptValue; | 48 class SerializedScriptValue; |
49 | 49 |
50 // The overwhelmingly common case is sending a single port, so handle that effic
iently with an inline buffer of size 1. | 50 // The overwhelmingly common case is sending a single port, so handle that effic
iently with an inline buffer of size 1. |
51 typedef WillBeHeapVector<RefPtrWillBeMember<MessagePort>, 1> MessagePortArray; | 51 typedef WillBeHeapVector<RefPtrWillBeMember<MessagePort>, 1> MessagePortArray; |
52 | 52 |
53 // Not to be confused with blink::WebMessagePortChannelArray; this one uses Vect
or and OwnPtr instead of WebVector and raw pointers. | 53 // Not to be confused with WebMessagePortChannelArray; this one uses Vector and
OwnPtr instead of WebVector and raw pointers. |
54 typedef Vector<OwnPtr<blink::WebMessagePortChannel>, 1> MessagePortChannelArray; | 54 typedef Vector<OwnPtr<WebMessagePortChannel>, 1> MessagePortChannelArray; |
55 | 55 |
56 class MessagePort FINAL : public RefCountedWillBeRefCountedGarbageCollected<Mess
agePort> | 56 class MessagePort FINAL : public RefCountedWillBeRefCountedGarbageCollected<Mess
agePort> |
57 , public ActiveDOMObject | 57 , public ActiveDOMObject |
58 , public EventTargetWithInlineData | 58 , public EventTargetWithInlineData |
59 , public blink::WebMessagePortChannelClient { | 59 , public WebMessagePortChannelClient { |
60 REFCOUNTED_EVENT_TARGET(MessagePort); | 60 REFCOUNTED_EVENT_TARGET(MessagePort); |
61 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(MessagePort); | 61 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(MessagePort); |
62 public: | 62 public: |
63 static PassRefPtrWillBeRawPtr<MessagePort> create(ExecutionContext&); | 63 static PassRefPtrWillBeRawPtr<MessagePort> create(ExecutionContext&); |
64 virtual ~MessagePort(); | 64 virtual ~MessagePort(); |
65 | 65 |
66 void postMessage(ExecutionContext*, PassRefPtr<SerializedScriptValue> messag
e, const MessagePortArray*, ExceptionState&); | 66 void postMessage(ExecutionContext*, PassRefPtr<SerializedScriptValue> messag
e, const MessagePortArray*, ExceptionState&); |
67 | 67 |
68 void start(); | 68 void start(); |
69 void close(); | 69 void close(); |
70 | 70 |
71 void entangle(PassOwnPtr<blink::WebMessagePortChannel>); | 71 void entangle(PassOwnPtr<WebMessagePortChannel>); |
72 PassOwnPtr<blink::WebMessagePortChannel> disentangle(); | 72 PassOwnPtr<WebMessagePortChannel> disentangle(); |
73 | 73 |
74 static PassOwnPtr<blink::WebMessagePortChannelArray> toWebMessagePortChannel
Array(PassOwnPtr<MessagePortChannelArray>); | 74 static PassOwnPtr<WebMessagePortChannelArray> toWebMessagePortChannelArray(P
assOwnPtr<MessagePortChannelArray>); |
75 static PassOwnPtrWillBeRawPtr<MessagePortArray> toMessagePortArray(Execution
Context*, const blink::WebMessagePortChannelArray&); | 75 static PassOwnPtrWillBeRawPtr<MessagePortArray> toMessagePortArray(Execution
Context*, const WebMessagePortChannelArray&); |
76 | 76 |
77 // Returns 0 if there is an exception, or if the passed-in array is 0/empty. | 77 // Returns 0 if there is an exception, or if the passed-in array is 0/empty. |
78 static PassOwnPtr<MessagePortChannelArray> disentanglePorts(const MessagePor
tArray*, ExceptionState&); | 78 static PassOwnPtr<MessagePortChannelArray> disentanglePorts(const MessagePor
tArray*, ExceptionState&); |
79 | 79 |
80 // Returns 0 if the passed array is 0/empty. | 80 // Returns 0 if the passed array is 0/empty. |
81 static PassOwnPtrWillBeRawPtr<MessagePortArray> entanglePorts(ExecutionConte
xt&, PassOwnPtr<MessagePortChannelArray>); | 81 static PassOwnPtrWillBeRawPtr<MessagePortArray> entanglePorts(ExecutionConte
xt&, PassOwnPtr<MessagePortChannelArray>); |
82 | 82 |
83 bool started() const { return m_started; } | 83 bool started() const { return m_started; } |
84 | 84 |
85 virtual const AtomicString& interfaceName() const OVERRIDE; | 85 virtual const AtomicString& interfaceName() const OVERRIDE; |
(...skipping 17 matching lines...) Expand all Loading... |
103 // A port gets neutered when it is transferred to a new owner via postMessag
e(). | 103 // A port gets neutered when it is transferred to a new owner via postMessag
e(). |
104 bool isNeutered() const { return !m_entangledChannel; } | 104 bool isNeutered() const { return !m_entangledChannel; } |
105 | 105 |
106 private: | 106 private: |
107 explicit MessagePort(ExecutionContext&); | 107 explicit MessagePort(ExecutionContext&); |
108 | 108 |
109 // WebMessagePortChannelClient implementation. | 109 // WebMessagePortChannelClient implementation. |
110 virtual void messageAvailable() OVERRIDE; | 110 virtual void messageAvailable() OVERRIDE; |
111 void dispatchMessages(); | 111 void dispatchMessages(); |
112 | 112 |
113 OwnPtr<blink::WebMessagePortChannel> m_entangledChannel; | 113 OwnPtr<WebMessagePortChannel> m_entangledChannel; |
114 | 114 |
115 bool m_started; | 115 bool m_started; |
116 bool m_closed; | 116 bool m_closed; |
117 | 117 |
118 WeakPtrFactory<MessagePort> m_weakFactory; | 118 WeakPtrFactory<MessagePort> m_weakFactory; |
119 }; | 119 }; |
120 | 120 |
121 } // namespace blink | 121 } // namespace blink |
122 | 122 |
123 #endif // MessagePort_h | 123 #endif // MessagePort_h |
OLD | NEW |