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

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

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, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 3 * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
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 15 matching lines...) Expand all
26 */ 26 */
27 27
28 #include "config.h" 28 #include "config.h"
29 #include "core/dom/MessageEvent.h" 29 #include "core/dom/MessageEvent.h"
30 30
31 #include "core/dom/EventNames.h" 31 #include "core/dom/EventNames.h"
32 #include "core/page/DOMWindow.h" 32 #include "core/page/DOMWindow.h"
33 33
34 namespace WebCore { 34 namespace WebCore {
35 35
36 static inline bool isValidSource(EventTarget* source)
37 {
38 return !source || source->toDOMWindow() || source->toMessagePort();
39 }
40
36 MessageEventInit::MessageEventInit() 41 MessageEventInit::MessageEventInit()
37 { 42 {
38 } 43 }
39 44
40 MessageEvent::MessageEvent() 45 MessageEvent::MessageEvent()
41 : m_dataType(DataTypeScriptValue) 46 : m_dataType(DataTypeScriptValue)
42 { 47 {
43 ScriptWrappable::init(this); 48 ScriptWrappable::init(this);
44 } 49 }
45 50
46 MessageEvent::MessageEvent(const AtomicString& type, const MessageEventInit& ini tializer) 51 MessageEvent::MessageEvent(const AtomicString& type, const MessageEventInit& ini tializer)
47 : Event(type, initializer) 52 : Event(type, initializer)
48 , m_dataType(DataTypeScriptValue) 53 , m_dataType(DataTypeScriptValue)
49 , m_origin(initializer.origin) 54 , m_origin(initializer.origin)
50 , m_lastEventId(initializer.lastEventId) 55 , m_lastEventId(initializer.lastEventId)
51 , m_source(initializer.source) 56 , m_source(initializer.source)
52 , m_ports(adoptPtr(new MessagePortArray(initializer.ports))) 57 , m_ports(adoptPtr(new MessagePortArray(initializer.ports)))
53 { 58 {
54 ScriptWrappable::init(this); 59 ScriptWrappable::init(this);
60 ASSERT(isValidSource(m_source.get()));
55 } 61 }
56 62
57 MessageEvent::MessageEvent(const String& origin, const String& lastEventId, Pass RefPtr<DOMWindow> source, PassOwnPtr<MessagePortArray> ports) 63 MessageEvent::MessageEvent(const String& origin, const String& lastEventId, Pass RefPtr<EventTarget> source, PassOwnPtr<MessagePortArray> ports)
58 : Event(eventNames().messageEvent, false, false) 64 : Event(eventNames().messageEvent, false, false)
59 , m_dataType(DataTypeScriptValue) 65 , m_dataType(DataTypeScriptValue)
60 , m_origin(origin) 66 , m_origin(origin)
61 , m_lastEventId(lastEventId) 67 , m_lastEventId(lastEventId)
62 , m_source(source) 68 , m_source(source)
63 , m_ports(ports) 69 , m_ports(ports)
64 { 70 {
65 ScriptWrappable::init(this); 71 ScriptWrappable::init(this);
72 ASSERT(isValidSource(m_source.get()));
66 } 73 }
67 74
68 MessageEvent::MessageEvent(PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, PassRefPtr<DOMWindow> source, PassOwnPtr<Mes sagePortArray> ports) 75 MessageEvent::MessageEvent(PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, PassRefPtr<EventTarget> source, PassOwnPtr<M essagePortArray> ports)
69 : Event(eventNames().messageEvent, false, false) 76 : Event(eventNames().messageEvent, false, false)
70 , m_dataType(DataTypeSerializedScriptValue) 77 , m_dataType(DataTypeSerializedScriptValue)
71 , m_dataAsSerializedScriptValue(data) 78 , m_dataAsSerializedScriptValue(data)
72 , m_origin(origin) 79 , m_origin(origin)
73 , m_lastEventId(lastEventId) 80 , m_lastEventId(lastEventId)
74 , m_source(source) 81 , m_source(source)
75 , m_ports(ports) 82 , m_ports(ports)
76 { 83 {
77 ScriptWrappable::init(this); 84 ScriptWrappable::init(this);
78 if (m_dataAsSerializedScriptValue) 85 if (m_dataAsSerializedScriptValue)
79 m_dataAsSerializedScriptValue->registerMemoryAllocatedWithCurrentScriptC ontext(); 86 m_dataAsSerializedScriptValue->registerMemoryAllocatedWithCurrentScriptC ontext();
87 ASSERT(isValidSource(m_source.get()));
80 } 88 }
81 89
82 MessageEvent::MessageEvent(const String& data, const String& origin) 90 MessageEvent::MessageEvent(const String& data, const String& origin)
83 : Event(eventNames().messageEvent, false, false) 91 : Event(eventNames().messageEvent, false, false)
84 , m_dataType(DataTypeString) 92 , m_dataType(DataTypeString)
85 , m_dataAsString(data) 93 , m_dataAsString(data)
86 , m_origin(origin) 94 , m_origin(origin)
87 , m_lastEventId("") 95 , m_lastEventId("")
88 { 96 {
89 ScriptWrappable::init(this); 97 ScriptWrappable::init(this);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 if (m_dataAsSerializedScriptValue) 152 if (m_dataAsSerializedScriptValue)
145 m_dataAsSerializedScriptValue->registerMemoryAllocatedWithCurrentScriptC ontext(); 153 m_dataAsSerializedScriptValue->registerMemoryAllocatedWithCurrentScriptC ontext();
146 } 154 }
147 155
148 const AtomicString& MessageEvent::interfaceName() const 156 const AtomicString& MessageEvent::interfaceName() const
149 { 157 {
150 return eventNames().interfaceForMessageEvent; 158 return eventNames().interfaceForMessageEvent;
151 } 159 }
152 160
153 } // namespace WebCore 161 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698