| 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 23 matching lines...) Expand all Loading... |
| 34 #include "core/dom/CrossThreadTask.h" | 34 #include "core/dom/CrossThreadTask.h" |
| 35 #include "core/dom/DOMArrayBuffer.h" | 35 #include "core/dom/DOMArrayBuffer.h" |
| 36 #include "core/dom/Document.h" | 36 #include "core/dom/Document.h" |
| 37 #include "core/dom/ExecutionContext.h" | 37 #include "core/dom/ExecutionContext.h" |
| 38 #include "core/dom/ExecutionContextTask.h" | 38 #include "core/dom/ExecutionContextTask.h" |
| 39 #include "core/fileapi/Blob.h" | 39 #include "core/fileapi/Blob.h" |
| 40 #include "core/workers/WorkerGlobalScope.h" | 40 #include "core/workers/WorkerGlobalScope.h" |
| 41 #include "core/workers/WorkerLoaderProxy.h" | 41 #include "core/workers/WorkerLoaderProxy.h" |
| 42 #include "core/workers/WorkerThread.h" | 42 #include "core/workers/WorkerThread.h" |
| 43 #include "modules/websockets/DocumentWebSocketChannel.h" | 43 #include "modules/websockets/DocumentWebSocketChannel.h" |
| 44 #include "platform/WaitableEvent.h" |
| 44 #include "platform/heap/SafePoint.h" | 45 #include "platform/heap/SafePoint.h" |
| 45 #include "public/platform/Platform.h" | 46 #include "public/platform/Platform.h" |
| 46 #include "public/platform/WebWaitableEvent.h" | |
| 47 #include "wtf/Assertions.h" | 47 #include "wtf/Assertions.h" |
| 48 #include "wtf/Functional.h" | 48 #include "wtf/Functional.h" |
| 49 #include "wtf/MainThread.h" | 49 #include "wtf/MainThread.h" |
| 50 #include "wtf/text/CString.h" | 50 #include "wtf/text/CString.h" |
| 51 #include "wtf/text/WTFString.h" | 51 #include "wtf/text/WTFString.h" |
| 52 | 52 |
| 53 namespace blink { | 53 namespace blink { |
| 54 | 54 |
| 55 typedef WorkerWebSocketChannel::Bridge Bridge; | 55 typedef WorkerWebSocketChannel::Bridge Bridge; |
| 56 typedef WorkerWebSocketChannel::Peer Peer; | 56 typedef WorkerWebSocketChannel::Peer Peer; |
| 57 | 57 |
| 58 // Created and destroyed on the worker thread. All setters of this class are | 58 // Created and destroyed on the worker thread. All setters of this class are |
| 59 // called on the main thread, while all getters are called on the worker | 59 // called on the main thread, while all getters are called on the worker |
| 60 // thread. signalWorkerThread() must be called before any getters are called. | 60 // thread. signalWorkerThread() must be called before any getters are called. |
| 61 class WebSocketChannelSyncHelper : public GarbageCollectedFinalized<WebSocketCha
nnelSyncHelper> { | 61 class WebSocketChannelSyncHelper : public GarbageCollectedFinalized<WebSocketCha
nnelSyncHelper> { |
| 62 public: | 62 public: |
| 63 static WebSocketChannelSyncHelper* create(PassOwnPtr<WebWaitableEvent> event
) | 63 static WebSocketChannelSyncHelper* create(PassOwnPtr<WaitableEvent> event) |
| 64 { | 64 { |
| 65 return new WebSocketChannelSyncHelper(event); | 65 return new WebSocketChannelSyncHelper(event); |
| 66 } | 66 } |
| 67 | 67 |
| 68 ~WebSocketChannelSyncHelper() | 68 ~WebSocketChannelSyncHelper() |
| 69 { | 69 { |
| 70 } | 70 } |
| 71 | 71 |
| 72 // All setters are called on the main thread. | 72 // All setters are called on the main thread. |
| 73 void setConnectRequestResult(bool connectRequestResult) | 73 void setConnectRequestResult(bool connectRequestResult) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 88 m_event->signal(); | 88 m_event->signal(); |
| 89 } | 89 } |
| 90 void wait() | 90 void wait() |
| 91 { | 91 { |
| 92 m_event->wait(); | 92 m_event->wait(); |
| 93 } | 93 } |
| 94 | 94 |
| 95 DEFINE_INLINE_TRACE() { } | 95 DEFINE_INLINE_TRACE() { } |
| 96 | 96 |
| 97 private: | 97 private: |
| 98 explicit WebSocketChannelSyncHelper(PassOwnPtr<WebWaitableEvent> event) | 98 explicit WebSocketChannelSyncHelper(PassOwnPtr<WaitableEvent> event) |
| 99 : m_event(event) | 99 : m_event(event) |
| 100 , m_connectRequestResult(false) | 100 , m_connectRequestResult(false) |
| 101 { | 101 { |
| 102 } | 102 } |
| 103 | 103 |
| 104 OwnPtr<WebWaitableEvent> m_event; | 104 OwnPtr<WaitableEvent> m_event; |
| 105 bool m_connectRequestResult; | 105 bool m_connectRequestResult; |
| 106 }; | 106 }; |
| 107 | 107 |
| 108 WorkerWebSocketChannel::WorkerWebSocketChannel(WorkerGlobalScope& workerGlobalSc
ope, WebSocketChannelClient* client, const String& sourceURL, unsigned lineNumbe
r) | 108 WorkerWebSocketChannel::WorkerWebSocketChannel(WorkerGlobalScope& workerGlobalSc
ope, WebSocketChannelClient* client, const String& sourceURL, unsigned lineNumbe
r) |
| 109 : m_bridge(new Bridge(client, workerGlobalScope)) | 109 : m_bridge(new Bridge(client, workerGlobalScope)) |
| 110 , m_sourceURLAtConnection(sourceURL) | 110 , m_sourceURLAtConnection(sourceURL) |
| 111 , m_lineNumberAtConnection(lineNumber) | 111 , m_lineNumberAtConnection(lineNumber) |
| 112 { | 112 { |
| 113 m_bridge->initialize(sourceURL, lineNumber); | 113 m_bridge->initialize(sourceURL, lineNumber); |
| 114 } | 114 } |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 visitor->trace(m_bridge); | 366 visitor->trace(m_bridge); |
| 367 visitor->trace(m_mainWebSocketChannel); | 367 visitor->trace(m_mainWebSocketChannel); |
| 368 visitor->trace(m_syncHelper); | 368 visitor->trace(m_syncHelper); |
| 369 WebSocketChannelClient::trace(visitor); | 369 WebSocketChannelClient::trace(visitor); |
| 370 } | 370 } |
| 371 | 371 |
| 372 Bridge::Bridge(WebSocketChannelClient* client, WorkerGlobalScope& workerGlobalSc
ope) | 372 Bridge::Bridge(WebSocketChannelClient* client, WorkerGlobalScope& workerGlobalSc
ope) |
| 373 : m_client(client) | 373 : m_client(client) |
| 374 , m_workerGlobalScope(workerGlobalScope) | 374 , m_workerGlobalScope(workerGlobalScope) |
| 375 , m_loaderProxy(m_workerGlobalScope->thread()->workerLoaderProxy()) | 375 , m_loaderProxy(m_workerGlobalScope->thread()->workerLoaderProxy()) |
| 376 , m_syncHelper(WebSocketChannelSyncHelper::create(adoptPtr(Platform::current
()->createWaitableEvent()))) | 376 , m_syncHelper(WebSocketChannelSyncHelper::create(adoptPtr(new WaitableEvent
()))) |
| 377 , m_peer(new Peer(this, m_loaderProxy, m_syncHelper)) | 377 , m_peer(new Peer(this, m_loaderProxy, m_syncHelper)) |
| 378 { | 378 { |
| 379 } | 379 } |
| 380 | 380 |
| 381 Bridge::~Bridge() | 381 Bridge::~Bridge() |
| 382 { | 382 { |
| 383 ASSERT(!m_peer); | 383 ASSERT(!m_peer); |
| 384 } | 384 } |
| 385 | 385 |
| 386 void Bridge::initialize(const String& sourceURL, unsigned lineNumber) | 386 void Bridge::initialize(const String& sourceURL, unsigned lineNumber) |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 | 475 |
| 476 DEFINE_TRACE(Bridge) | 476 DEFINE_TRACE(Bridge) |
| 477 { | 477 { |
| 478 visitor->trace(m_client); | 478 visitor->trace(m_client); |
| 479 visitor->trace(m_workerGlobalScope); | 479 visitor->trace(m_workerGlobalScope); |
| 480 visitor->trace(m_syncHelper); | 480 visitor->trace(m_syncHelper); |
| 481 visitor->trace(m_peer); | 481 visitor->trace(m_peer); |
| 482 } | 482 } |
| 483 | 483 |
| 484 } // namespace blink | 484 } // namespace blink |
| OLD | NEW |