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

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

Issue 460393003: Cleanup namespace usage in Source/core/{dom/* & fileapi/*} (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix Error and Rebase Created 6 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
« no previous file with comments | « Source/core/dom/MessagePort.h ('k') | Source/core/dom/Microtask.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 if (dataPort == this) { 78 if (dataPort == this) {
79 exceptionState.throwDOMException(DataCloneError, "Port at index " + String::number(i) + " contains the source port."); 79 exceptionState.throwDOMException(DataCloneError, "Port at index " + String::number(i) + " contains the source port.");
80 return; 80 return;
81 } 81 }
82 } 82 }
83 channels = MessagePort::disentanglePorts(ports, exceptionState); 83 channels = MessagePort::disentanglePorts(ports, exceptionState);
84 if (exceptionState.hadException()) 84 if (exceptionState.hadException())
85 return; 85 return;
86 } 86 }
87 87
88 blink::WebString messageString = message->toWireString(); 88 WebString messageString = message->toWireString();
89 OwnPtr<blink::WebMessagePortChannelArray> webChannels = toWebMessagePortChan nelArray(channels.release()); 89 OwnPtr<WebMessagePortChannelArray> webChannels = toWebMessagePortChannelArra y(channels.release());
90 m_entangledChannel->postMessage(messageString, webChannels.leakPtr()); 90 m_entangledChannel->postMessage(messageString, webChannels.leakPtr());
91 } 91 }
92 92
93 // static 93 // static
94 PassOwnPtr<blink::WebMessagePortChannelArray> MessagePort::toWebMessagePortChann elArray(PassOwnPtr<MessagePortChannelArray> channels) 94 PassOwnPtr<WebMessagePortChannelArray> MessagePort::toWebMessagePortChannelArray (PassOwnPtr<MessagePortChannelArray> channels)
95 { 95 {
96 OwnPtr<blink::WebMessagePortChannelArray> webChannels; 96 OwnPtr<WebMessagePortChannelArray> webChannels;
97 if (channels && channels->size()) { 97 if (channels && channels->size()) {
98 webChannels = adoptPtr(new blink::WebMessagePortChannelArray(channels->s ize())); 98 webChannels = adoptPtr(new WebMessagePortChannelArray(channels->size())) ;
99 for (size_t i = 0; i < channels->size(); ++i) 99 for (size_t i = 0; i < channels->size(); ++i)
100 (*webChannels)[i] = (*channels)[i].leakPtr(); 100 (*webChannels)[i] = (*channels)[i].leakPtr();
101 } 101 }
102 return webChannels.release(); 102 return webChannels.release();
103 } 103 }
104 104
105 // static 105 // static
106 PassOwnPtrWillBeRawPtr<MessagePortArray> MessagePort::toMessagePortArray(Executi onContext* context, const blink::WebMessagePortChannelArray& webChannels) 106 PassOwnPtrWillBeRawPtr<MessagePortArray> MessagePort::toMessagePortArray(Executi onContext* context, const WebMessagePortChannelArray& webChannels)
107 { 107 {
108 OwnPtrWillBeRawPtr<MessagePortArray> ports = nullptr; 108 OwnPtrWillBeRawPtr<MessagePortArray> ports = nullptr;
109 if (!webChannels.isEmpty()) { 109 if (!webChannels.isEmpty()) {
110 OwnPtr<MessagePortChannelArray> channels = adoptPtr(new MessagePortChann elArray(webChannels.size())); 110 OwnPtr<MessagePortChannelArray> channels = adoptPtr(new MessagePortChann elArray(webChannels.size()));
111 for (size_t i = 0; i < webChannels.size(); ++i) 111 for (size_t i = 0; i < webChannels.size(); ++i)
112 (*channels)[i] = adoptPtr(webChannels[i]); 112 (*channels)[i] = adoptPtr(webChannels[i]);
113 ports = MessagePort::entanglePorts(*context, channels.release()); 113 ports = MessagePort::entanglePorts(*context, channels.release());
114 } 114 }
115 return ports.release(); 115 return ports.release();
116 } 116 }
117 117
118 PassOwnPtr<blink::WebMessagePortChannel> MessagePort::disentangle() 118 PassOwnPtr<WebMessagePortChannel> MessagePort::disentangle()
119 { 119 {
120 ASSERT(m_entangledChannel); 120 ASSERT(m_entangledChannel);
121 m_entangledChannel->setClient(0); 121 m_entangledChannel->setClient(0);
122 return m_entangledChannel.release(); 122 return m_entangledChannel.release();
123 } 123 }
124 124
125 // Invoked to notify us that there are messages available for this port. 125 // Invoked to notify us that there are messages available for this port.
126 // This code may be called from another thread, and so should not call any non-t hreadsafe APIs (i.e. should not call into the entangled channel or access mutabl e variables). 126 // This code may be called from another thread, and so should not call any non-t hreadsafe APIs (i.e. should not call into the entangled channel or access mutabl e variables).
127 void MessagePort::messageAvailable() 127 void MessagePort::messageAvailable()
128 { 128 {
(...skipping 15 matching lines...) Expand all
144 messageAvailable(); 144 messageAvailable();
145 } 145 }
146 146
147 void MessagePort::close() 147 void MessagePort::close()
148 { 148 {
149 if (isEntangled()) 149 if (isEntangled())
150 m_entangledChannel->setClient(0); 150 m_entangledChannel->setClient(0);
151 m_closed = true; 151 m_closed = true;
152 } 152 }
153 153
154 void MessagePort::entangle(PassOwnPtr<blink::WebMessagePortChannel> remote) 154 void MessagePort::entangle(PassOwnPtr<WebMessagePortChannel> remote)
155 { 155 {
156 // Only invoked to set our initial entanglement. 156 // Only invoked to set our initial entanglement.
157 ASSERT(!m_entangledChannel); 157 ASSERT(!m_entangledChannel);
158 ASSERT(executionContext()); 158 ASSERT(executionContext());
159 159
160 m_entangledChannel = remote; 160 m_entangledChannel = remote;
161 m_entangledChannel->setClient(this); 161 m_entangledChannel->setClient(this);
162 } 162 }
163 163
164 const AtomicString& MessagePort::interfaceName() const 164 const AtomicString& MessagePort::interfaceName() const
165 { 165 {
166 return EventTargetNames::MessagePort; 166 return EventTargetNames::MessagePort;
167 } 167 }
168 168
169 static bool tryGetMessageFrom(blink::WebMessagePortChannel& webChannel, RefPtr<S erializedScriptValue>& message, OwnPtr<MessagePortChannelArray>& channels) 169 static bool tryGetMessageFrom(WebMessagePortChannel& webChannel, RefPtr<Serializ edScriptValue>& message, OwnPtr<MessagePortChannelArray>& channels)
170 { 170 {
171 blink::WebString messageString; 171 WebString messageString;
172 blink::WebMessagePortChannelArray webChannels; 172 WebMessagePortChannelArray webChannels;
173 if (!webChannel.tryGetMessage(&messageString, webChannels)) 173 if (!webChannel.tryGetMessage(&messageString, webChannels))
174 return false; 174 return false;
175 175
176 if (webChannels.size()) { 176 if (webChannels.size()) {
177 channels = adoptPtr(new MessagePortChannelArray(webChannels.size())); 177 channels = adoptPtr(new MessagePortChannelArray(webChannels.size()));
178 for (size_t i = 0; i < webChannels.size(); ++i) 178 for (size_t i = 0; i < webChannels.size(); ++i)
179 (*channels)[i] = adoptPtr(webChannels[i]); 179 (*channels)[i] = adoptPtr(webChannels[i]);
180 } 180 }
181 message = SerializedScriptValue::createFromWire(messageString); 181 message = SerializedScriptValue::createFromWire(messageString);
182 return true; 182 return true;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 OwnPtrWillBeRawPtr<MessagePortArray> portArray = adoptPtrWillBeNoop(new Mess agePortArray(channels->size())); 250 OwnPtrWillBeRawPtr<MessagePortArray> portArray = adoptPtrWillBeNoop(new Mess agePortArray(channels->size()));
251 for (unsigned i = 0; i < channels->size(); ++i) { 251 for (unsigned i = 0; i < channels->size(); ++i) {
252 RefPtrWillBeRawPtr<MessagePort> port = MessagePort::create(context); 252 RefPtrWillBeRawPtr<MessagePort> port = MessagePort::create(context);
253 port->entangle((*channels)[i].release()); 253 port->entangle((*channels)[i].release());
254 (*portArray)[i] = port.release(); 254 (*portArray)[i] = port.release();
255 } 255 }
256 return portArray.release(); 256 return portArray.release();
257 } 257 }
258 258
259 } // namespace blink 259 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/dom/MessagePort.h ('k') | Source/core/dom/Microtask.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698