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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 m_bridge->disconnect(); | 136 m_bridge->disconnect(); |
137 } | 137 } |
138 | 138 |
139 bool WorkerThreadableWebSocketChannel::connect(const KURL& url, const String& pr
otocol) | 139 bool WorkerThreadableWebSocketChannel::connect(const KURL& url, const String& pr
otocol) |
140 { | 140 { |
141 if (m_bridge) | 141 if (m_bridge) |
142 return m_bridge->connect(url, protocol); | 142 return m_bridge->connect(url, protocol); |
143 return false; | 143 return false; |
144 } | 144 } |
145 | 145 |
146 String WorkerThreadableWebSocketChannel::subprotocol() | |
147 { | |
148 return m_workerClientWrapper->subprotocol(); | |
149 } | |
150 | |
151 String WorkerThreadableWebSocketChannel::extensions() | |
152 { | |
153 return m_workerClientWrapper->extensions(); | |
154 } | |
155 | |
156 WebSocketChannel::SendResult WorkerThreadableWebSocketChannel::send(const String
& message) | 146 WebSocketChannel::SendResult WorkerThreadableWebSocketChannel::send(const String
& message) |
157 { | 147 { |
158 if (!m_bridge) | 148 if (!m_bridge) |
159 return WebSocketChannel::SendFail; | 149 return WebSocketChannel::SendFail; |
160 return m_bridge->send(message); | 150 return m_bridge->send(message); |
161 } | 151 } |
162 | 152 |
163 WebSocketChannel::SendResult WorkerThreadableWebSocketChannel::send(const ArrayB
uffer& binaryData, unsigned byteOffset, unsigned byteLength) | 153 WebSocketChannel::SendResult WorkerThreadableWebSocketChannel::send(const ArrayB
uffer& binaryData, unsigned byteOffset, unsigned byteLength) |
164 { | 154 { |
165 if (!m_bridge) | 155 if (!m_bridge) |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 { | 360 { |
371 ASSERT(isMainThread()); | 361 ASSERT(isMainThread()); |
372 if (!m_mainWebSocketChannel) | 362 if (!m_mainWebSocketChannel) |
373 return; | 363 return; |
374 m_mainWebSocketChannel->resume(); | 364 m_mainWebSocketChannel->resume(); |
375 } | 365 } |
376 | 366 |
377 static void workerGlobalScopeDidConnect(ExecutionContext* context, PassRefPtrWil
lBeRawPtr<ThreadableWebSocketChannelClientWrapper> workerClientWrapper, const St
ring& subprotocol, const String& extensions) | 367 static void workerGlobalScopeDidConnect(ExecutionContext* context, PassRefPtrWil
lBeRawPtr<ThreadableWebSocketChannelClientWrapper> workerClientWrapper, const St
ring& subprotocol, const String& extensions) |
378 { | 368 { |
379 ASSERT_UNUSED(context, context->isWorkerGlobalScope()); | 369 ASSERT_UNUSED(context, context->isWorkerGlobalScope()); |
380 workerClientWrapper->setSubprotocol(subprotocol); | 370 workerClientWrapper->didConnect(subprotocol, extensions); |
381 workerClientWrapper->setExtensions(extensions); | |
382 workerClientWrapper->didConnect(); | |
383 } | 371 } |
384 | 372 |
385 void WorkerThreadableWebSocketChannel::Peer::didConnect() | 373 void WorkerThreadableWebSocketChannel::Peer::didConnect(const String& subprotoco
l, const String& extensions) |
386 { | 374 { |
387 ASSERT(isMainThread()); | 375 ASSERT(isMainThread()); |
388 m_loaderProxy.postTaskToWorkerGlobalScope(createCallbackTask(&workerGlobalSc
opeDidConnect, m_workerClientWrapper.get(), m_mainWebSocketChannel->subprotocol(
), m_mainWebSocketChannel->extensions())); | 376 m_loaderProxy.postTaskToWorkerGlobalScope(createCallbackTask(&workerGlobalSc
opeDidConnect, m_workerClientWrapper.get(), subprotocol, extensions)); |
389 } | 377 } |
390 | 378 |
391 static void workerGlobalScopeDidReceiveMessage(ExecutionContext* context, PassRe
fPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper> workerClientWrapper, c
onst String& message) | 379 static void workerGlobalScopeDidReceiveMessage(ExecutionContext* context, PassRe
fPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper> workerClientWrapper, c
onst String& message) |
392 { | 380 { |
393 ASSERT_UNUSED(context, context->isWorkerGlobalScope()); | 381 ASSERT_UNUSED(context, context->isWorkerGlobalScope()); |
394 workerClientWrapper->didReceiveMessage(message); | 382 workerClientWrapper->didReceiveMessage(message); |
395 } | 383 } |
396 | 384 |
397 void WorkerThreadableWebSocketChannel::Peer::didReceiveMessage(const String& mes
sage) | 385 void WorkerThreadableWebSocketChannel::Peer::didReceiveMessage(const String& mes
sage) |
398 { | 386 { |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 m_loaderProxy.postTaskToLoader(CallClosureTask::create(bind(&Peer::destroy,
m_peer))); | 611 m_loaderProxy.postTaskToLoader(CallClosureTask::create(bind(&Peer::destroy,
m_peer))); |
624 // Peer::destroy() deletes m_peer and then m_syncHelper will be released. | 612 // Peer::destroy() deletes m_peer and then m_syncHelper will be released. |
625 // We must not touch m_syncHelper any more. | 613 // We must not touch m_syncHelper any more. |
626 m_syncHelper = 0; | 614 m_syncHelper = 0; |
627 | 615 |
628 // We won't use this any more. | 616 // We won't use this any more. |
629 m_workerGlobalScope = nullptr; | 617 m_workerGlobalScope = nullptr; |
630 } | 618 } |
631 | 619 |
632 } // namespace WebCore | 620 } // namespace WebCore |
OLD | NEW |