| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 private: | 116 private: |
| 117 Member<Bridge> m_bridge; | 117 Member<Bridge> m_bridge; |
| 118 RefPtr<WorkerLoaderProxy> m_loaderProxy; | 118 RefPtr<WorkerLoaderProxy> m_loaderProxy; |
| 119 Member<WebSocketChannel> m_mainWebSocketChannel; | 119 Member<WebSocketChannel> m_mainWebSocketChannel; |
| 120 Member<WebSocketChannelSyncHelper> m_syncHelper; | 120 Member<WebSocketChannelSyncHelper> m_syncHelper; |
| 121 }; | 121 }; |
| 122 | 122 |
| 123 // Bridge for Peer. Running on the worker thread. | 123 // Bridge for Peer. Running on the worker thread. |
| 124 class Bridge final : public GarbageCollectedFinalized<Bridge> { | 124 class Bridge final : public GarbageCollectedFinalized<Bridge> { |
| 125 WTF_MAKE_NONCOPYABLE(Bridge); | 125 WTF_MAKE_NONCOPYABLE(Bridge); |
| 126 USING_PRE_FINALIZER(Bridge, peerShouldBeDisconnected); | |
| 127 public: | 126 public: |
| 128 Bridge(WebSocketChannelClient*, WorkerGlobalScope&); | 127 Bridge(WebSocketChannelClient*, WorkerGlobalScope&); |
| 129 ~Bridge(); | 128 ~Bridge(); |
| 130 // sourceURLAtConnection and lineNumberAtConnection parameters may | 129 // sourceURLAtConnection and lineNumberAtConnection parameters may |
| 131 // be shown when the connection fails. | 130 // be shown when the connection fails. |
| 132 void initialize(const String& sourceURLAtConnection, unsigned lineNumber
AtConnection); | 131 void initialize(const String& sourceURLAtConnection, unsigned lineNumber
AtConnection); |
| 133 bool connect(const KURL&, const String& protocol); | 132 bool connect(const KURL&, const String& protocol); |
| 134 void send(const CString& message); | 133 void send(const CString& message); |
| 135 void send(const DOMArrayBuffer&, unsigned byteOffset, unsigned byteLengt
h); | 134 void send(const DOMArrayBuffer&, unsigned byteOffset, unsigned byteLengt
h); |
| 136 void send(PassRefPtr<BlobDataHandle>); | 135 void send(PassRefPtr<BlobDataHandle>); |
| 137 void close(int code, const String& reason); | 136 void close(int code, const String& reason); |
| 138 void fail(const String& reason, MessageLevel, const String& sourceURL, u
nsigned lineNumber); | 137 void fail(const String& reason, MessageLevel, const String& sourceURL, u
nsigned lineNumber); |
| 139 void disconnect(); | 138 void disconnect(); |
| 140 | 139 |
| 141 // Returns null when |disconnect| has already been called. | 140 // Returns null when |disconnect| has already been called. |
| 142 WebSocketChannelClient* client() { return m_client; } | 141 WebSocketChannelClient* client() { return m_client; } |
| 143 | 142 |
| 144 DECLARE_TRACE(); | 143 DECLARE_TRACE(); |
| 145 | 144 |
| 146 private: | 145 private: |
| 147 // Returns false if shutdown event is received before method completion. | 146 // Returns false if shutdown event is received before method completion. |
| 148 bool waitForMethodCompletion(PassOwnPtr<ExecutionContextTask>); | 147 bool waitForMethodCompletion(PassOwnPtr<ExecutionContextTask>); |
| 149 void peerShouldBeDisconnected(); | |
| 150 | 148 |
| 151 Member<WebSocketChannelClient> m_client; | 149 Member<WebSocketChannelClient> m_client; |
| 152 RefPtrWillBeMember<WorkerGlobalScope> m_workerGlobalScope; | 150 RefPtrWillBeMember<WorkerGlobalScope> m_workerGlobalScope; |
| 153 RefPtr<WorkerLoaderProxy> m_loaderProxy; | 151 RefPtr<WorkerLoaderProxy> m_loaderProxy; |
| 154 Member<WebSocketChannelSyncHelper> m_syncHelper; | 152 Member<WebSocketChannelSyncHelper> m_syncHelper; |
| 155 Member<Peer> m_peer; | 153 Member<Peer> m_peer; |
| 156 }; | 154 }; |
| 157 | 155 |
| 158 private: | 156 private: |
| 159 WorkerWebSocketChannel(WorkerGlobalScope&, WebSocketChannelClient*, const St
ring& sourceURL, unsigned lineNumber); | 157 WorkerWebSocketChannel(WorkerGlobalScope&, WebSocketChannelClient*, const St
ring& sourceURL, unsigned lineNumber); |
| 160 | 158 |
| 161 Member<Bridge> m_bridge; | 159 Member<Bridge> m_bridge; |
| 162 String m_sourceURLAtConnection; | 160 String m_sourceURLAtConnection; |
| 163 unsigned m_lineNumberAtConnection; | 161 unsigned m_lineNumberAtConnection; |
| 164 }; | 162 }; |
| 165 | 163 |
| 166 } // namespace blink | 164 } // namespace blink |
| 167 | 165 |
| 168 #endif // WorkerWebSocketChannel_h | 166 #endif // WorkerWebSocketChannel_h |
| OLD | NEW |