Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Side by Side Diff: Source/core/dom/MessageEvent.h

Issue 23319002: Set MessageEvent.source to the newly created port for shared workers' connect events (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add test and assertions Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007 Henry Mason (hmason@mac.com) 2 * Copyright (C) 2007 Henry Mason (hmason@mac.com)
3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserv ed. 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserv ed.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 12 matching lines...) Expand all
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 * 25 *
26 */ 26 */
27 27
28 #ifndef MessageEvent_h 28 #ifndef MessageEvent_h
29 #define MessageEvent_h 29 #define MessageEvent_h
30 30
31 #include "bindings/v8/SerializedScriptValue.h" 31 #include "bindings/v8/SerializedScriptValue.h"
32 #include "core/dom/Event.h" 32 #include "core/dom/Event.h"
33 #include "core/dom/EventTarget.h"
33 #include "core/dom/MessagePort.h" 34 #include "core/dom/MessagePort.h"
34 #include "core/fileapi/Blob.h" 35 #include "core/fileapi/Blob.h"
35 #include "core/page/DOMWindow.h" 36 #include "core/page/DOMWindow.h"
36 #include "wtf/ArrayBuffer.h" 37 #include "wtf/ArrayBuffer.h"
37 38
38 namespace WebCore { 39 namespace WebCore {
39 40
40 class DOMWindow;
41
42 struct MessageEventInit : public EventInit { 41 struct MessageEventInit : public EventInit {
43 MessageEventInit(); 42 MessageEventInit();
44 43
45 String origin; 44 String origin;
46 String lastEventId; 45 String lastEventId;
47 RefPtr<DOMWindow> source; 46 RefPtr<DOMWindow> source;
48 MessagePortArray ports; 47 MessagePortArray ports;
49 }; 48 };
50 49
51 class MessageEvent : public Event { 50 class MessageEvent : public Event {
52 public: 51 public:
53 static PassRefPtr<MessageEvent> create() 52 static PassRefPtr<MessageEvent> create()
54 { 53 {
55 return adoptRef(new MessageEvent); 54 return adoptRef(new MessageEvent);
56 } 55 }
57 static PassRefPtr<MessageEvent> create(PassOwnPtr<MessagePortArray> ports, c onst String& origin = "", const String& lastEventId = "", PassRefPtr<DOMWindow> source = 0) 56 static PassRefPtr<MessageEvent> create(PassOwnPtr<MessagePortArray> ports, c onst String& origin = "", const String& lastEventId = "", PassRefPtr<EventTarget > source = 0)
58 { 57 {
59 return adoptRef(new MessageEvent(origin, lastEventId, source, ports)); 58 return adoptRef(new MessageEvent(origin, lastEventId, source, ports));
60 } 59 }
61 static PassRefPtr<MessageEvent> create(PassOwnPtr<MessagePortArray> ports, P assRefPtr<SerializedScriptValue> data, const String& origin = "", const String& lastEventId = "", PassRefPtr<DOMWindow> source = 0) 60 static PassRefPtr<MessageEvent> create(PassOwnPtr<MessagePortArray> ports, P assRefPtr<SerializedScriptValue> data, const String& origin = "", const String& lastEventId = "", PassRefPtr<EventTarget> source = 0)
62 { 61 {
63 return adoptRef(new MessageEvent(data, origin, lastEventId, source, port s)); 62 return adoptRef(new MessageEvent(data, origin, lastEventId, source, port s));
64 } 63 }
65 static PassRefPtr<MessageEvent> create(const String& data, const String& ori gin = "") 64 static PassRefPtr<MessageEvent> create(const String& data, const String& ori gin = "")
66 { 65 {
67 return adoptRef(new MessageEvent(data, origin)); 66 return adoptRef(new MessageEvent(data, origin));
68 } 67 }
69 static PassRefPtr<MessageEvent> create(PassRefPtr<Blob> data, const String& origin = "") 68 static PassRefPtr<MessageEvent> create(PassRefPtr<Blob> data, const String& origin = "")
70 { 69 {
71 return adoptRef(new MessageEvent(data, origin)); 70 return adoptRef(new MessageEvent(data, origin));
72 } 71 }
73 static PassRefPtr<MessageEvent> create(PassRefPtr<ArrayBuffer> data, const S tring& origin = "") 72 static PassRefPtr<MessageEvent> create(PassRefPtr<ArrayBuffer> data, const S tring& origin = "")
74 { 73 {
75 return adoptRef(new MessageEvent(data, origin)); 74 return adoptRef(new MessageEvent(data, origin));
76 } 75 }
77 static PassRefPtr<MessageEvent> create(const AtomicString& type, const Messa geEventInit& initializer) 76 static PassRefPtr<MessageEvent> create(const AtomicString& type, const Messa geEventInit& initializer)
78 { 77 {
79 return adoptRef(new MessageEvent(type, initializer)); 78 return adoptRef(new MessageEvent(type, initializer));
80 } 79 }
81 virtual ~MessageEvent(); 80 virtual ~MessageEvent();
82 81
83 void initMessageEvent(const AtomicString& type, bool canBubble, bool cancela ble, const String& origin, const String& lastEventId, DOMWindow* source, PassOwn Ptr<MessagePortArray>); 82 void initMessageEvent(const AtomicString& type, bool canBubble, bool cancela ble, const String& origin, const String& lastEventId, DOMWindow* source, PassOwn Ptr<MessagePortArray>);
84 void initMessageEvent(const AtomicString& type, bool canBubble, bool cancela ble, PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, DOMWindow* source, PassOwnPtr<MessagePortArray>); 83 void initMessageEvent(const AtomicString& type, bool canBubble, bool cancela ble, PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, DOMWindow* source, PassOwnPtr<MessagePortArray>);
85 84
86 const String& origin() const { return m_origin; } 85 const String& origin() const { return m_origin; }
87 const String& lastEventId() const { return m_lastEventId; } 86 const String& lastEventId() const { return m_lastEventId; }
88 DOMWindow* source() const { return m_source.get(); } 87 EventTarget* source() const { return m_source.get(); }
89 MessagePortArray ports() const { return m_ports ? *m_ports : MessagePortArra y(); } 88 MessagePortArray ports() const { return m_ports ? *m_ports : MessagePortArra y(); }
90 89
91 virtual const AtomicString& interfaceName() const; 90 virtual const AtomicString& interfaceName() const;
92 91
93 enum DataType { 92 enum DataType {
94 DataTypeScriptValue, 93 DataTypeScriptValue,
95 DataTypeSerializedScriptValue, 94 DataTypeSerializedScriptValue,
96 DataTypeString, 95 DataTypeString,
97 DataTypeBlob, 96 DataTypeBlob,
98 DataTypeArrayBuffer 97 DataTypeArrayBuffer
99 }; 98 };
100 DataType dataType() const { return m_dataType; } 99 DataType dataType() const { return m_dataType; }
101 SerializedScriptValue* dataAsSerializedScriptValue() const { ASSERT(m_dataTy pe == DataTypeScriptValue || m_dataType == DataTypeSerializedScriptValue); retur n m_dataAsSerializedScriptValue.get(); } 100 SerializedScriptValue* dataAsSerializedScriptValue() const { ASSERT(m_dataTy pe == DataTypeScriptValue || m_dataType == DataTypeSerializedScriptValue); retur n m_dataAsSerializedScriptValue.get(); }
102 String dataAsString() const { ASSERT(m_dataType == DataTypeString); return m _dataAsString; } 101 String dataAsString() const { ASSERT(m_dataType == DataTypeString); return m _dataAsString; }
103 Blob* dataAsBlob() const { ASSERT(m_dataType == DataTypeBlob); return m_data AsBlob.get(); } 102 Blob* dataAsBlob() const { ASSERT(m_dataType == DataTypeBlob); return m_data AsBlob.get(); }
104 ArrayBuffer* dataAsArrayBuffer() const { ASSERT(m_dataType == DataTypeArrayB uffer); return m_dataAsArrayBuffer.get(); } 103 ArrayBuffer* dataAsArrayBuffer() const { ASSERT(m_dataType == DataTypeArrayB uffer); return m_dataAsArrayBuffer.get(); }
105 104
106 void setSerializedData(PassRefPtr<SerializedScriptValue> data) 105 void setSerializedData(PassRefPtr<SerializedScriptValue> data)
107 { 106 {
108 ASSERT(!m_dataAsSerializedScriptValue); 107 ASSERT(!m_dataAsSerializedScriptValue);
109 m_dataAsSerializedScriptValue = data; 108 m_dataAsSerializedScriptValue = data;
110 } 109 }
111 110
112 private: 111 private:
113 MessageEvent(); 112 MessageEvent();
114 MessageEvent(const AtomicString&, const MessageEventInit&); 113 MessageEvent(const AtomicString&, const MessageEventInit&);
115 MessageEvent(const String& origin, const String& lastEventId, PassRefPtr<DOM Window> source, PassOwnPtr<MessagePortArray>); 114 MessageEvent(const String& origin, const String& lastEventId, PassRefPtr<Eve ntTarget> source, PassOwnPtr<MessagePortArray>);
116 MessageEvent(PassRefPtr<SerializedScriptValue> data, const String& origin, c onst String& lastEventId, PassRefPtr<DOMWindow> source, PassOwnPtr<MessagePortAr ray>); 115 MessageEvent(PassRefPtr<SerializedScriptValue> data, const String& origin, c onst String& lastEventId, PassRefPtr<EventTarget> source, PassOwnPtr<MessagePort Array>);
117 116
118 explicit MessageEvent(const String& data, const String& origin); 117 explicit MessageEvent(const String& data, const String& origin);
119 explicit MessageEvent(PassRefPtr<Blob> data, const String& origin); 118 explicit MessageEvent(PassRefPtr<Blob> data, const String& origin);
120 explicit MessageEvent(PassRefPtr<ArrayBuffer> data, const String& origin); 119 explicit MessageEvent(PassRefPtr<ArrayBuffer> data, const String& origin);
121 120
122 DataType m_dataType; 121 DataType m_dataType;
123 RefPtr<SerializedScriptValue> m_dataAsSerializedScriptValue; 122 RefPtr<SerializedScriptValue> m_dataAsSerializedScriptValue;
124 String m_dataAsString; 123 String m_dataAsString;
125 RefPtr<Blob> m_dataAsBlob; 124 RefPtr<Blob> m_dataAsBlob;
126 RefPtr<ArrayBuffer> m_dataAsArrayBuffer; 125 RefPtr<ArrayBuffer> m_dataAsArrayBuffer;
127 String m_origin; 126 String m_origin;
128 String m_lastEventId; 127 String m_lastEventId;
129 RefPtr<DOMWindow> m_source; 128 RefPtr<EventTarget> m_source;
130 OwnPtr<MessagePortArray> m_ports; 129 OwnPtr<MessagePortArray> m_ports;
131 }; 130 };
132 131
133 } // namespace WebCore 132 } // namespace WebCore
134 133
135 #endif // MessageEvent_h 134 #endif // MessageEvent_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698