| 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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 static void workerGlobalScopeDidConnect(Bridge* bridge, | 237 static void workerGlobalScopeDidConnect(Bridge* bridge, |
| 238 const String& subprotocol, | 238 const String& subprotocol, |
| 239 const String& extensions) { | 239 const String& extensions) { |
| 240 if (bridge && bridge->client()) | 240 if (bridge && bridge->client()) |
| 241 bridge->client()->didConnect(subprotocol, extensions); | 241 bridge->client()->didConnect(subprotocol, extensions); |
| 242 } | 242 } |
| 243 | 243 |
| 244 void Peer::didConnect(const String& subprotocol, const String& extensions) { | 244 void Peer::didConnect(const String& subprotocol, const String& extensions) { |
| 245 DCHECK(isMainThread()); | 245 DCHECK(isMainThread()); |
| 246 m_loaderProxy->postTaskToWorkerGlobalScope( | 246 m_loaderProxy->postTaskToWorkerGlobalScope( |
| 247 BLINK_FROM_HERE, crossThreadBind(&workerGlobalScopeDidConnect, m_bridge, | 247 BLINK_FROM_HERE, |
| 248 subprotocol, extensions)); | 248 crossThreadBind(&workerGlobalScopeDidConnect, m_bridge, subprotocol, |
| 249 extensions)); |
| 249 } | 250 } |
| 250 | 251 |
| 251 static void workerGlobalScopeDidReceiveTextMessage(Bridge* bridge, | 252 static void workerGlobalScopeDidReceiveTextMessage(Bridge* bridge, |
| 252 const String& payload) { | 253 const String& payload) { |
| 253 if (bridge && bridge->client()) | 254 if (bridge && bridge->client()) |
| 254 bridge->client()->didReceiveTextMessage(payload); | 255 bridge->client()->didReceiveTextMessage(payload); |
| 255 } | 256 } |
| 256 | 257 |
| 257 void Peer::didReceiveTextMessage(const String& payload) { | 258 void Peer::didReceiveTextMessage(const String& payload) { |
| 258 DCHECK(isMainThread()); | 259 DCHECK(isMainThread()); |
| 259 m_loaderProxy->postTaskToWorkerGlobalScope( | 260 m_loaderProxy->postTaskToWorkerGlobalScope( |
| 260 BLINK_FROM_HERE, crossThreadBind(&workerGlobalScopeDidReceiveTextMessage, | 261 BLINK_FROM_HERE, |
| 261 m_bridge, payload)); | 262 crossThreadBind(&workerGlobalScopeDidReceiveTextMessage, m_bridge, |
| 263 payload)); |
| 262 } | 264 } |
| 263 | 265 |
| 264 static void workerGlobalScopeDidReceiveBinaryMessage( | 266 static void workerGlobalScopeDidReceiveBinaryMessage( |
| 265 Bridge* bridge, | 267 Bridge* bridge, |
| 266 std::unique_ptr<Vector<char>> payload) { | 268 std::unique_ptr<Vector<char>> payload) { |
| 267 if (bridge && bridge->client()) | 269 if (bridge && bridge->client()) |
| 268 bridge->client()->didReceiveBinaryMessage(std::move(payload)); | 270 bridge->client()->didReceiveBinaryMessage(std::move(payload)); |
| 269 } | 271 } |
| 270 | 272 |
| 271 void Peer::didReceiveBinaryMessage(std::unique_ptr<Vector<char>> payload) { | 273 void Peer::didReceiveBinaryMessage(std::unique_ptr<Vector<char>> payload) { |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 m_loaderProxy->postTaskToLoader( | 444 m_loaderProxy->postTaskToLoader( |
| 443 BLINK_FROM_HERE, | 445 BLINK_FROM_HERE, |
| 444 createCrossThreadTask(&Peer::close, m_peer, code, reason)); | 446 createCrossThreadTask(&Peer::close, m_peer, code, reason)); |
| 445 } | 447 } |
| 446 | 448 |
| 447 void Bridge::fail(const String& reason, | 449 void Bridge::fail(const String& reason, |
| 448 MessageLevel level, | 450 MessageLevel level, |
| 449 std::unique_ptr<SourceLocation> location) { | 451 std::unique_ptr<SourceLocation> location) { |
| 450 DCHECK(m_peer); | 452 DCHECK(m_peer); |
| 451 m_loaderProxy->postTaskToLoader( | 453 m_loaderProxy->postTaskToLoader( |
| 452 BLINK_FROM_HERE, createCrossThreadTask(&Peer::fail, m_peer, reason, level, | 454 BLINK_FROM_HERE, |
| 453 WTF::passed(location->clone()))); | 455 createCrossThreadTask(&Peer::fail, m_peer, reason, level, |
| 456 WTF::passed(location->clone()))); |
| 454 } | 457 } |
| 455 | 458 |
| 456 void Bridge::disconnect() { | 459 void Bridge::disconnect() { |
| 457 if (!m_peer) | 460 if (!m_peer) |
| 458 return; | 461 return; |
| 459 | 462 |
| 460 m_loaderProxy->postTaskToLoader( | 463 m_loaderProxy->postTaskToLoader( |
| 461 BLINK_FROM_HERE, createCrossThreadTask(&Peer::disconnect, m_peer)); | 464 BLINK_FROM_HERE, createCrossThreadTask(&Peer::disconnect, m_peer)); |
| 462 | 465 |
| 463 m_client = nullptr; | 466 m_client = nullptr; |
| 464 m_peer = nullptr; | 467 m_peer = nullptr; |
| 465 m_workerGlobalScope.clear(); | 468 m_workerGlobalScope.clear(); |
| 466 } | 469 } |
| 467 | 470 |
| 468 DEFINE_TRACE(Bridge) { | 471 DEFINE_TRACE(Bridge) { |
| 469 visitor->trace(m_client); | 472 visitor->trace(m_client); |
| 470 visitor->trace(m_workerGlobalScope); | 473 visitor->trace(m_workerGlobalScope); |
| 471 } | 474 } |
| 472 | 475 |
| 473 } // namespace blink | 476 } // namespace blink |
| OLD | NEW |