OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "modules/serviceworkers/ServiceWorkerMessageEvent.h" | 5 #include "modules/serviceworkers/ServiceWorkerMessageEvent.h" |
6 | 6 |
7 namespace blink { | 7 namespace blink { |
8 | 8 |
9 ServiceWorkerMessageEvent::ServiceWorkerMessageEvent() | 9 ServiceWorkerMessageEvent::ServiceWorkerMessageEvent() |
10 { | 10 { |
(...skipping 27 matching lines...) Expand all Loading... |
38 if (m_serializedData) | 38 if (m_serializedData) |
39 m_serializedData->registerMemoryAllocatedWithCurrentScriptContext(); | 39 m_serializedData->registerMemoryAllocatedWithCurrentScriptContext(); |
40 } | 40 } |
41 | 41 |
42 ServiceWorkerMessageEvent::~ServiceWorkerMessageEvent() | 42 ServiceWorkerMessageEvent::~ServiceWorkerMessageEvent() |
43 { | 43 { |
44 } | 44 } |
45 | 45 |
46 MessagePortArray ServiceWorkerMessageEvent::ports(bool& isNull) const | 46 MessagePortArray ServiceWorkerMessageEvent::ports(bool& isNull) const |
47 { | 47 { |
| 48 // TODO(bashi): Currently we return a copied array because the binding |
| 49 // layer could modify the content of the array while executing JS callbacks. |
| 50 // Avoid copying once we can make sure that the binding layer won't |
| 51 // modify the content. |
48 if (m_ports) { | 52 if (m_ports) { |
49 isNull = false; | 53 isNull = false; |
50 return *m_ports; | 54 return *m_ports; |
51 } | 55 } |
52 isNull = true; | 56 isNull = true; |
53 return MessagePortArray(); | 57 return MessagePortArray(); |
54 } | 58 } |
55 | 59 |
56 MessagePortArray ServiceWorkerMessageEvent::ports() const | 60 MessagePortArray ServiceWorkerMessageEvent::ports() const |
57 { | 61 { |
(...skipping 16 matching lines...) Expand all Loading... |
74 | 78 |
75 DEFINE_TRACE(ServiceWorkerMessageEvent) | 79 DEFINE_TRACE(ServiceWorkerMessageEvent) |
76 { | 80 { |
77 visitor->trace(m_sourceAsServiceWorker); | 81 visitor->trace(m_sourceAsServiceWorker); |
78 visitor->trace(m_sourceAsMessagePort); | 82 visitor->trace(m_sourceAsMessagePort); |
79 visitor->trace(m_ports); | 83 visitor->trace(m_ports); |
80 Event::trace(visitor); | 84 Event::trace(visitor); |
81 } | 85 } |
82 | 86 |
83 } // namespace blink | 87 } // namespace blink |
OLD | NEW |