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

Side by Side Diff: webkit/api/src/PlatformMessagePortChannel.cpp

Issue 263005: Webkit roll: 49213:49221 (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 20 matching lines...) Expand all
31 #include "config.h" 31 #include "config.h"
32 #include "PlatformMessagePortChannel.h" 32 #include "PlatformMessagePortChannel.h"
33 33
34 #include "WebKit.h" 34 #include "WebKit.h"
35 #include "WebKitClient.h" 35 #include "WebKitClient.h"
36 #include "WebMessagePortChannel.h" 36 #include "WebMessagePortChannel.h"
37 #include "WebString.h" 37 #include "WebString.h"
38 38
39 #include "MessagePort.h" 39 #include "MessagePort.h"
40 #include "ScriptExecutionContext.h" 40 #include "ScriptExecutionContext.h"
41 #include "SerializedScriptValue.h"
41 42
42 using namespace WebKit; 43 using namespace WebKit;
43 44
44 namespace WebCore { 45 namespace WebCore {
45 46
46 PassOwnPtr<MessagePortChannel> MessagePortChannel::create(PassRefPtr<PlatformMessagePortChannel> channel) 47 PassOwnPtr<MessagePortChannel> MessagePortChannel::create(PassRefPtr<PlatformMessagePortChannel> channel)
47 { 48 {
48 return new MessagePortChannel(channel); 49 return new MessagePortChannel(channel);
49 } 50 }
50 51
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 { 172 {
172 MutexLocker lock(m_mutex); 173 MutexLocker lock(m_mutex);
173 m_localPort = 0; 174 m_localPort = 0;
174 } 175 }
175 176
176 void PlatformMessagePortChannel::postMessageToRemote(PassOwnPtr<MessagePortChannel::EventData> message) 177 void PlatformMessagePortChannel::postMessageToRemote(PassOwnPtr<MessagePortChannel::EventData> message)
177 { 178 {
178 if (!m_localPort || !m_webChannel) 179 if (!m_localPort || !m_webChannel)
179 return; 180 return;
180 181
181 WebString messageString = message->message(); 182 WebString messageString = message->message()->toString();
182 OwnPtr<WebCore::MessagePortChannelArray> channels = message->channels(); 183 OwnPtr<WebCore::MessagePortChannelArray> channels = message->channels();
183 WebMessagePortChannelArray* webChannels = NULL; 184 WebMessagePortChannelArray* webChannels = NULL;
184 if (channels.get() && channels->size()) { 185 if (channels.get() && channels->size()) {
185 webChannels = new WebMessagePortChannelArray(channels->size()); 186 webChannels = new WebMessagePortChannelArray(channels->size());
186 for (size_t i = 0; i < channels->size(); ++i) { 187 for (size_t i = 0; i < channels->size(); ++i) {
187 WebCore::PlatformMessagePortChannel* platformChannel = (*channels)[i]->channel(); 188 WebCore::PlatformMessagePortChannel* platformChannel = (*channels)[i]->channel();
188 (*webChannels)[i] = platformChannel->webChannelRelease(); 189 (*webChannels)[i] = platformChannel->webChannelRelease();
189 (*webChannels)[i]->setClient(0); 190 (*webChannels)[i]->setClient(0);
190 } 191 }
191 } 192 }
(...skipping 11 matching lines...) Expand all
203 if (rv) { 204 if (rv) {
204 OwnPtr<MessagePortChannelArray> channels; 205 OwnPtr<MessagePortChannelArray> channels;
205 if (webChannels.size()) { 206 if (webChannels.size()) {
206 channels = new MessagePortChannelArray(webChannels.size()); 207 channels = new MessagePortChannelArray(webChannels.size());
207 for (size_t i = 0; i < webChannels.size(); ++i) { 208 for (size_t i = 0; i < webChannels.size(); ++i) {
208 RefPtr<PlatformMessagePortChannel> platformChannel = create(webChannels[i]); 209 RefPtr<PlatformMessagePortChannel> platformChannel = create(webChannels[i]);
209 webChannels[i]->setClient(platformChannel.get()); 210 webChannels[i]->setClient(platformChannel.get());
210 (*channels)[i] = MessagePortChannel::create(platformChannel); 211 (*channels)[i] = MessagePortChannel::create(platformChannel);
211 } 212 }
212 } 213 }
213 result = MessagePortChannel::EventData::create(message, channels.release()); 214 RefPtr<SerializedScriptValue> serializedMessage = SerializedScriptValue::create(message);
215 result = MessagePortChannel::EventData::create(serializedMessage.release(), channels.release());
214 } 216 }
215 217
216 return rv; 218 return rv;
217 } 219 }
218 220
219 void PlatformMessagePortChannel::close() 221 void PlatformMessagePortChannel::close()
220 { 222 {
221 MutexLocker lock(m_mutex); 223 MutexLocker lock(m_mutex);
222 // Disentangle ourselves from the other end. We still maintain a reference to m_webChannel, 224 // Disentangle ourselves from the other end. We still maintain a reference to m_webChannel,
223 // since previously-existing messages should still be delivered. 225 // since previously-existing messages should still be delivered.
(...skipping 23 matching lines...) Expand all
247 } 249 }
248 250
249 WebMessagePortChannel* PlatformMessagePortChannel::webChannelRelease() 251 WebMessagePortChannel* PlatformMessagePortChannel::webChannelRelease()
250 { 252 {
251 WebMessagePortChannel* rv = m_webChannel; 253 WebMessagePortChannel* rv = m_webChannel;
252 m_webChannel = 0; 254 m_webChannel = 0;
253 return rv; 255 return rv;
254 } 256 }
255 257
256 } // namespace WebCore 258 } // namespace WebCore
OLDNEW
« no previous file with comments | « DEPS ('k') | webkit/glue/webworker_impl.h » ('j') | webkit/glue/webworkerclient_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698