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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 ASSERT(m_bridge); | 143 ASSERT(m_bridge); |
144 m_bridge->send(blobData); | 144 m_bridge->send(blobData); |
145 } | 145 } |
146 | 146 |
147 void WorkerWebSocketChannel::close(int code, const String& reason) | 147 void WorkerWebSocketChannel::close(int code, const String& reason) |
148 { | 148 { |
149 ASSERT(m_bridge); | 149 ASSERT(m_bridge); |
150 m_bridge->close(code, reason); | 150 m_bridge->close(code, reason); |
151 } | 151 } |
152 | 152 |
| 153 void WorkerWebSocketChannel::changeBinaryType(BinaryType newBinaryType) |
| 154 { |
| 155 ASSERT(m_bridge); |
| 156 m_bridge->changeBinaryType(newBinaryType); |
| 157 } |
| 158 |
153 void WorkerWebSocketChannel::fail(const String& reason, MessageLevel level, cons
t String& sourceURL, unsigned lineNumber) | 159 void WorkerWebSocketChannel::fail(const String& reason, MessageLevel level, cons
t String& sourceURL, unsigned lineNumber) |
154 { | 160 { |
155 if (!m_bridge) | 161 if (!m_bridge) |
156 return; | 162 return; |
157 | 163 |
158 RefPtrWillBeRawPtr<ScriptCallStack> callStack = currentScriptCallStack(1); | 164 RefPtrWillBeRawPtr<ScriptCallStack> callStack = currentScriptCallStack(1); |
159 if (callStack && callStack->size()) { | 165 if (callStack && callStack->size()) { |
160 // In order to emulate the ConsoleMessage behavior, | 166 // In order to emulate the ConsoleMessage behavior, |
161 // we should ignore the specified url and line number if | 167 // we should ignore the specified url and line number if |
162 // we can get the JavaScript context. | 168 // we can get the JavaScript context. |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 | 247 |
242 void Peer::close(int code, const String& reason) | 248 void Peer::close(int code, const String& reason) |
243 { | 249 { |
244 ASSERT(isMainThread()); | 250 ASSERT(isMainThread()); |
245 ASSERT(m_syncHelper); | 251 ASSERT(m_syncHelper); |
246 if (!m_mainWebSocketChannel) | 252 if (!m_mainWebSocketChannel) |
247 return; | 253 return; |
248 m_mainWebSocketChannel->close(code, reason); | 254 m_mainWebSocketChannel->close(code, reason); |
249 } | 255 } |
250 | 256 |
| 257 void Peer::changeBinaryType(BinaryType newBinaryType) |
| 258 { |
| 259 ASSERT(isMainThread()); |
| 260 if (m_mainWebSocketChannel) |
| 261 m_mainWebSocketChannel->changeBinaryType(newBinaryType); |
| 262 } |
| 263 |
251 void Peer::fail(const String& reason, MessageLevel level, const String& sourceUR
L, unsigned lineNumber) | 264 void Peer::fail(const String& reason, MessageLevel level, const String& sourceUR
L, unsigned lineNumber) |
252 { | 265 { |
253 ASSERT(isMainThread()); | 266 ASSERT(isMainThread()); |
254 ASSERT(m_syncHelper); | 267 ASSERT(m_syncHelper); |
255 if (!m_mainWebSocketChannel) | 268 if (!m_mainWebSocketChannel) |
256 return; | 269 return; |
257 m_mainWebSocketChannel->fail(reason, level, sourceURL, lineNumber); | 270 m_mainWebSocketChannel->fail(reason, level, sourceURL, lineNumber); |
258 } | 271 } |
259 | 272 |
260 void Peer::disconnect() | 273 void Peer::disconnect() |
(...skipping 26 matching lines...) Expand all Loading... |
287 if (bridge->client()) | 300 if (bridge->client()) |
288 bridge->client()->didReceiveTextMessage(payload); | 301 bridge->client()->didReceiveTextMessage(payload); |
289 } | 302 } |
290 | 303 |
291 void Peer::didReceiveTextMessage(const String& payload) | 304 void Peer::didReceiveTextMessage(const String& payload) |
292 { | 305 { |
293 ASSERT(isMainThread()); | 306 ASSERT(isMainThread()); |
294 m_loaderProxy->postTaskToWorkerGlobalScope(createCrossThreadTask(&workerGlob
alScopeDidReceiveTextMessage, m_bridge, payload)); | 307 m_loaderProxy->postTaskToWorkerGlobalScope(createCrossThreadTask(&workerGlob
alScopeDidReceiveTextMessage, m_bridge, payload)); |
295 } | 308 } |
296 | 309 |
297 static void workerGlobalScopeDidReceiveBinaryMessage(Bridge* bridge, PassOwnPtr<
Vector<char>> payload, ExecutionContext* context) | 310 static void workerGlobalScopeDidReceiveArrayBuffer(Bridge* bridge, PassOwnPtr<Ve
ctor<char>> payload, ExecutionContext* context) |
298 { | 311 { |
299 ASSERT_UNUSED(context, context->isWorkerGlobalScope()); | 312 ASSERT_UNUSED(context, context->isWorkerGlobalScope()); |
300 if (bridge->client()) | 313 if (bridge->client()) |
301 bridge->client()->didReceiveBinaryMessage(payload); | 314 bridge->client()->didReceiveArrayBuffer(payload); |
302 } | 315 } |
303 | 316 |
304 void Peer::didReceiveBinaryMessage(PassOwnPtr<Vector<char>> payload) | 317 void Peer::didReceiveArrayBuffer(PassOwnPtr<Vector<char>> payload) |
305 { | 318 { |
306 ASSERT(isMainThread()); | 319 ASSERT(isMainThread()); |
307 m_loaderProxy->postTaskToWorkerGlobalScope(createCrossThreadTask(&workerGlob
alScopeDidReceiveBinaryMessage, m_bridge, payload)); | 320 m_loaderProxy->postTaskToWorkerGlobalScope(createCrossThreadTask(&workerGlob
alScopeDidReceiveArrayBuffer, m_bridge, payload)); |
| 321 } |
| 322 |
| 323 static void workerGlobalScopeDidReceiveBlob(Bridge* bridge, PassRefPtr<blink::Bl
obDataHandle> blobDataHandle, ExecutionContext* context) |
| 324 { |
| 325 ASSERT_UNUSED(context, context->isWorkerGlobalScope()); |
| 326 if (bridge->client()) |
| 327 bridge->client()->didReceiveBlob(blobDataHandle); |
| 328 } |
| 329 |
| 330 void Peer::didReceiveBlob(PassRefPtr<blink::BlobDataHandle> blobDataHandle) |
| 331 { |
| 332 ASSERT(isMainThread()); |
| 333 m_loaderProxy->postTaskToWorkerGlobalScope(createCrossThreadTask(&workerGlob
alScopeDidReceiveBlob, m_bridge, blobDataHandle)); |
308 } | 334 } |
309 | 335 |
310 static void workerGlobalScopeDidConsumeBufferedAmount(Bridge* bridge, uint64_t c
onsumed, ExecutionContext* context) | 336 static void workerGlobalScopeDidConsumeBufferedAmount(Bridge* bridge, uint64_t c
onsumed, ExecutionContext* context) |
311 { | 337 { |
312 ASSERT_UNUSED(context, context->isWorkerGlobalScope()); | 338 ASSERT_UNUSED(context, context->isWorkerGlobalScope()); |
313 if (bridge->client()) | 339 if (bridge->client()) |
314 bridge->client()->didConsumeBufferedAmount(consumed); | 340 bridge->client()->didConsumeBufferedAmount(consumed); |
315 } | 341 } |
316 | 342 |
317 void Peer::didConsumeBufferedAmount(uint64_t consumed) | 343 void Peer::didConsumeBufferedAmount(uint64_t consumed) |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 ASSERT(m_peer); | 456 ASSERT(m_peer); |
431 m_loaderProxy->postTaskToLoader(createCrossThreadTask(&Peer::sendBlob, m_pee
r.get(), data)); | 457 m_loaderProxy->postTaskToLoader(createCrossThreadTask(&Peer::sendBlob, m_pee
r.get(), data)); |
432 } | 458 } |
433 | 459 |
434 void Bridge::close(int code, const String& reason) | 460 void Bridge::close(int code, const String& reason) |
435 { | 461 { |
436 ASSERT(m_peer); | 462 ASSERT(m_peer); |
437 m_loaderProxy->postTaskToLoader(createCrossThreadTask(&Peer::close, m_peer.g
et(), code, reason)); | 463 m_loaderProxy->postTaskToLoader(createCrossThreadTask(&Peer::close, m_peer.g
et(), code, reason)); |
438 } | 464 } |
439 | 465 |
| 466 void Bridge::changeBinaryType(BinaryType newBinaryType) |
| 467 { |
| 468 ASSERT(m_peer); |
| 469 m_loaderProxy->postTaskToLoader(createCrossThreadTask(&Peer::changeBinaryTyp
e, m_peer.get(), newBinaryType)); |
| 470 } |
| 471 |
440 void Bridge::fail(const String& reason, MessageLevel level, const String& source
URL, unsigned lineNumber) | 472 void Bridge::fail(const String& reason, MessageLevel level, const String& source
URL, unsigned lineNumber) |
441 { | 473 { |
442 ASSERT(m_peer); | 474 ASSERT(m_peer); |
443 m_loaderProxy->postTaskToLoader(createCrossThreadTask(&Peer::fail, m_peer.ge
t(), reason, level, sourceURL, lineNumber)); | 475 m_loaderProxy->postTaskToLoader(createCrossThreadTask(&Peer::fail, m_peer.ge
t(), reason, level, sourceURL, lineNumber)); |
444 } | 476 } |
445 | 477 |
446 void Bridge::disconnect() | 478 void Bridge::disconnect() |
447 { | 479 { |
448 if (!m_peer) | 480 if (!m_peer) |
449 return; | 481 return; |
(...skipping 27 matching lines...) Expand all Loading... |
477 | 509 |
478 DEFINE_TRACE(Bridge) | 510 DEFINE_TRACE(Bridge) |
479 { | 511 { |
480 visitor->trace(m_client); | 512 visitor->trace(m_client); |
481 visitor->trace(m_workerGlobalScope); | 513 visitor->trace(m_workerGlobalScope); |
482 visitor->trace(m_syncHelper); | 514 visitor->trace(m_syncHelper); |
483 visitor->trace(m_peer); | 515 visitor->trace(m_peer); |
484 } | 516 } |
485 | 517 |
486 } // namespace blink | 518 } // namespace blink |
OLD | NEW |