OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 m_syncHelper->signalWorkerThread(); | 217 m_syncHelper->signalWorkerThread(); |
218 } | 218 } |
219 | 219 |
220 void Peer::send(const String& message) | 220 void Peer::send(const String& message) |
221 { | 221 { |
222 ASSERT(isMainThread()); | 222 ASSERT(isMainThread()); |
223 if (m_mainWebSocketChannel) | 223 if (m_mainWebSocketChannel) |
224 m_mainWebSocketChannel->send(message); | 224 m_mainWebSocketChannel->send(message); |
225 } | 225 } |
226 | 226 |
227 void Peer::sendArrayBuffer(PassOwnPtr<Vector<char> > data) | 227 void Peer::sendArrayBuffer(PassOwnPtr<Vector<char>> data) |
228 { | 228 { |
229 ASSERT(isMainThread()); | 229 ASSERT(isMainThread()); |
230 if (m_mainWebSocketChannel) | 230 if (m_mainWebSocketChannel) |
231 m_mainWebSocketChannel->send(data); | 231 m_mainWebSocketChannel->send(data); |
232 } | 232 } |
233 | 233 |
234 void Peer::sendBlob(PassRefPtr<BlobDataHandle> blobData) | 234 void Peer::sendBlob(PassRefPtr<BlobDataHandle> blobData) |
235 { | 235 { |
236 ASSERT(isMainThread()); | 236 ASSERT(isMainThread()); |
237 if (m_mainWebSocketChannel) | 237 if (m_mainWebSocketChannel) |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 if (bridge->client()) | 286 if (bridge->client()) |
287 bridge->client()->didReceiveTextMessage(payload); | 287 bridge->client()->didReceiveTextMessage(payload); |
288 } | 288 } |
289 | 289 |
290 void Peer::didReceiveTextMessage(const String& payload) | 290 void Peer::didReceiveTextMessage(const String& payload) |
291 { | 291 { |
292 ASSERT(isMainThread()); | 292 ASSERT(isMainThread()); |
293 m_loaderProxy.postTaskToWorkerGlobalScope(createCrossThreadTask(&workerGloba
lScopeDidReceiveTextMessage, m_bridge, payload)); | 293 m_loaderProxy.postTaskToWorkerGlobalScope(createCrossThreadTask(&workerGloba
lScopeDidReceiveTextMessage, m_bridge, payload)); |
294 } | 294 } |
295 | 295 |
296 static void workerGlobalScopeDidReceiveBinaryMessage(ExecutionContext* context,
Bridge* bridge, PassOwnPtr<Vector<char> > payload) | 296 static void workerGlobalScopeDidReceiveBinaryMessage(ExecutionContext* context,
Bridge* bridge, PassOwnPtr<Vector<char>> payload) |
297 { | 297 { |
298 ASSERT_UNUSED(context, context->isWorkerGlobalScope()); | 298 ASSERT_UNUSED(context, context->isWorkerGlobalScope()); |
299 if (bridge->client()) | 299 if (bridge->client()) |
300 bridge->client()->didReceiveBinaryMessage(payload); | 300 bridge->client()->didReceiveBinaryMessage(payload); |
301 } | 301 } |
302 | 302 |
303 void Peer::didReceiveBinaryMessage(PassOwnPtr<Vector<char> > payload) | 303 void Peer::didReceiveBinaryMessage(PassOwnPtr<Vector<char>> payload) |
304 { | 304 { |
305 ASSERT(isMainThread()); | 305 ASSERT(isMainThread()); |
306 m_loaderProxy.postTaskToWorkerGlobalScope(createCrossThreadTask(&workerGloba
lScopeDidReceiveBinaryMessage, m_bridge, payload)); | 306 m_loaderProxy.postTaskToWorkerGlobalScope(createCrossThreadTask(&workerGloba
lScopeDidReceiveBinaryMessage, m_bridge, payload)); |
307 } | 307 } |
308 | 308 |
309 static void workerGlobalScopeDidConsumeBufferedAmount(ExecutionContext* context,
Bridge* bridge, uint64_t consumed) | 309 static void workerGlobalScopeDidConsumeBufferedAmount(ExecutionContext* context,
Bridge* bridge, uint64_t consumed) |
310 { | 310 { |
311 ASSERT_UNUSED(context, context->isWorkerGlobalScope()); | 311 ASSERT_UNUSED(context, context->isWorkerGlobalScope()); |
312 if (bridge->client()) | 312 if (bridge->client()) |
313 bridge->client()->didConsumeBufferedAmount(consumed); | 313 bridge->client()->didConsumeBufferedAmount(consumed); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 void Bridge::send(const String& message) | 406 void Bridge::send(const String& message) |
407 { | 407 { |
408 ASSERT(m_peer); | 408 ASSERT(m_peer); |
409 m_loaderProxy.postTaskToLoader(createCrossThreadTask(&Peer::send, m_peer.get
(), message)); | 409 m_loaderProxy.postTaskToLoader(createCrossThreadTask(&Peer::send, m_peer.get
(), message)); |
410 } | 410 } |
411 | 411 |
412 void Bridge::send(const DOMArrayBuffer& binaryData, unsigned byteOffset, unsigne
d byteLength) | 412 void Bridge::send(const DOMArrayBuffer& binaryData, unsigned byteOffset, unsigne
d byteLength) |
413 { | 413 { |
414 ASSERT(m_peer); | 414 ASSERT(m_peer); |
415 // ArrayBuffer isn't thread-safe, hence the content of ArrayBuffer is copied
into Vector<char>. | 415 // ArrayBuffer isn't thread-safe, hence the content of ArrayBuffer is copied
into Vector<char>. |
416 OwnPtr<Vector<char> > data = adoptPtr(new Vector<char>(byteLength)); | 416 OwnPtr<Vector<char>> data = adoptPtr(new Vector<char>(byteLength)); |
417 if (binaryData.byteLength()) | 417 if (binaryData.byteLength()) |
418 memcpy(data->data(), static_cast<const char*>(binaryData.data()) + byteO
ffset, byteLength); | 418 memcpy(data->data(), static_cast<const char*>(binaryData.data()) + byteO
ffset, byteLength); |
419 | 419 |
420 m_loaderProxy.postTaskToLoader(createCrossThreadTask(&Peer::sendArrayBuffer,
m_peer.get(), data.release())); | 420 m_loaderProxy.postTaskToLoader(createCrossThreadTask(&Peer::sendArrayBuffer,
m_peer.get(), data.release())); |
421 } | 421 } |
422 | 422 |
423 void Bridge::send(PassRefPtr<BlobDataHandle> data) | 423 void Bridge::send(PassRefPtr<BlobDataHandle> data) |
424 { | 424 { |
425 ASSERT(m_peer); | 425 ASSERT(m_peer); |
426 m_loaderProxy.postTaskToLoader(createCrossThreadTask(&Peer::sendBlob, m_peer
.get(), data)); | 426 m_loaderProxy.postTaskToLoader(createCrossThreadTask(&Peer::sendBlob, m_peer
.get(), data)); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 | 472 |
473 void Bridge::trace(Visitor* visitor) | 473 void Bridge::trace(Visitor* visitor) |
474 { | 474 { |
475 visitor->trace(m_client); | 475 visitor->trace(m_client); |
476 visitor->trace(m_workerGlobalScope); | 476 visitor->trace(m_workerGlobalScope); |
477 visitor->trace(m_syncHelper); | 477 visitor->trace(m_syncHelper); |
478 visitor->trace(m_peer); | 478 visitor->trace(m_peer); |
479 } | 479 } |
480 | 480 |
481 } // namespace blink | 481 } // namespace blink |
OLD | NEW |