| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 class WorkerGlobalScope; | 53 class WorkerGlobalScope; |
| 54 class WorkerLoaderProxy; | 54 class WorkerLoaderProxy; |
| 55 | 55 |
| 56 class WorkerWebSocketChannel final : public WebSocketChannel { | 56 class WorkerWebSocketChannel final : public WebSocketChannel { |
| 57 WTF_MAKE_NONCOPYABLE(WorkerWebSocketChannel); | 57 WTF_MAKE_NONCOPYABLE(WorkerWebSocketChannel); |
| 58 public: | 58 public: |
| 59 static WebSocketChannel* create(WorkerGlobalScope& workerGlobalScope, WebSoc
ketChannelClient* client, const String& sourceURL, unsigned lineNumber) | 59 static WebSocketChannel* create(WorkerGlobalScope& workerGlobalScope, WebSoc
ketChannelClient* client, const String& sourceURL, unsigned lineNumber) |
| 60 { | 60 { |
| 61 return new WorkerWebSocketChannel(workerGlobalScope, client, sourceURL,
lineNumber); | 61 return new WorkerWebSocketChannel(workerGlobalScope, client, sourceURL,
lineNumber); |
| 62 } | 62 } |
| 63 virtual ~WorkerWebSocketChannel(); | 63 ~WorkerWebSocketChannel() override; |
| 64 | 64 |
| 65 // WebSocketChannel functions. | 65 // WebSocketChannel functions. |
| 66 virtual bool connect(const KURL&, const String& protocol) override; | 66 bool connect(const KURL&, const String& protocol) override; |
| 67 virtual void send(const CString&) override; | 67 void send(const CString&) override; |
| 68 virtual void send(const DOMArrayBuffer&, unsigned byteOffset, unsigned byteL
ength) override; | 68 void send(const DOMArrayBuffer&, unsigned byteOffset, unsigned byteLength) o
verride; |
| 69 virtual void send(PassRefPtr<BlobDataHandle>) override; | 69 void send(PassRefPtr<BlobDataHandle>) override; |
| 70 virtual void sendTextAsCharVector(PassOwnPtr<Vector<char>>) override | 70 void sendTextAsCharVector(PassOwnPtr<Vector<char>>) override |
| 71 { | 71 { |
| 72 ASSERT_NOT_REACHED(); | 72 ASSERT_NOT_REACHED(); |
| 73 } | 73 } |
| 74 virtual void sendBinaryAsCharVector(PassOwnPtr<Vector<char>>) override | 74 void sendBinaryAsCharVector(PassOwnPtr<Vector<char>>) override |
| 75 { | 75 { |
| 76 ASSERT_NOT_REACHED(); | 76 ASSERT_NOT_REACHED(); |
| 77 } | 77 } |
| 78 virtual void close(int code, const String& reason) override; | 78 void close(int code, const String& reason) override; |
| 79 virtual void fail(const String& reason, MessageLevel, const String&, unsigne
d) override; | 79 void fail(const String& reason, MessageLevel, const String&, unsigned) overr
ide; |
| 80 virtual void disconnect() override; // Will suppress didClose(). | 80 void disconnect() override; // Will suppress didClose(). |
| 81 | 81 |
| 82 DECLARE_VIRTUAL_TRACE(); | 82 DECLARE_VIRTUAL_TRACE(); |
| 83 | 83 |
| 84 class Bridge; | 84 class Bridge; |
| 85 // Allocated in the worker thread, but used in the main thread. | 85 // Allocated in the worker thread, but used in the main thread. |
| 86 class Peer final : public GarbageCollectedFinalized<Peer>, public WebSocketC
hannelClient { | 86 class Peer final : public GarbageCollectedFinalized<Peer>, public WebSocketC
hannelClient { |
| 87 USING_GARBAGE_COLLECTED_MIXIN(Peer); | 87 USING_GARBAGE_COLLECTED_MIXIN(Peer); |
| 88 WTF_MAKE_NONCOPYABLE(Peer); | 88 WTF_MAKE_NONCOPYABLE(Peer); |
| 89 public: | 89 public: |
| 90 Peer(Bridge*, PassRefPtr<WorkerLoaderProxy>, WebSocketChannelSyncHelper*
); | 90 Peer(Bridge*, PassRefPtr<WorkerLoaderProxy>, WebSocketChannelSyncHelper*
); |
| 91 virtual ~Peer(); | 91 ~Peer() override; |
| 92 | 92 |
| 93 // sourceURLAtConnection and lineNumberAtConnection parameters may | 93 // sourceURLAtConnection and lineNumberAtConnection parameters may |
| 94 // be shown when the connection fails. | 94 // be shown when the connection fails. |
| 95 void initialize(const String& sourceURLAtConnection, unsigned lineNumber
AtConnection, ExecutionContext*); | 95 void initialize(const String& sourceURLAtConnection, unsigned lineNumber
AtConnection, ExecutionContext*); |
| 96 | 96 |
| 97 void connect(const KURL&, const String& protocol); | 97 void connect(const KURL&, const String& protocol); |
| 98 void sendTextAsCharVector(PassOwnPtr<Vector<char>>); | 98 void sendTextAsCharVector(PassOwnPtr<Vector<char>>); |
| 99 void sendBinaryAsCharVector(PassOwnPtr<Vector<char>>); | 99 void sendBinaryAsCharVector(PassOwnPtr<Vector<char>>); |
| 100 void sendBlob(PassRefPtr<BlobDataHandle>); | 100 void sendBlob(PassRefPtr<BlobDataHandle>); |
| 101 void close(int code, const String& reason); | 101 void close(int code, const String& reason); |
| 102 void fail(const String& reason, MessageLevel, const String& sourceURL, u
nsigned lineNumber); | 102 void fail(const String& reason, MessageLevel, const String& sourceURL, u
nsigned lineNumber); |
| 103 void disconnect(); | 103 void disconnect(); |
| 104 | 104 |
| 105 DECLARE_VIRTUAL_TRACE(); | 105 DECLARE_VIRTUAL_TRACE(); |
| 106 | 106 |
| 107 // WebSocketChannelClient functions. | 107 // WebSocketChannelClient functions. |
| 108 virtual void didConnect(const String& subprotocol, const String& extensi
ons) override; | 108 void didConnect(const String& subprotocol, const String& extensions) ove
rride; |
| 109 virtual void didReceiveTextMessage(const String& payload) override; | 109 void didReceiveTextMessage(const String& payload) override; |
| 110 virtual void didReceiveBinaryMessage(PassOwnPtr<Vector<char>>) override; | 110 void didReceiveBinaryMessage(PassOwnPtr<Vector<char>>) override; |
| 111 virtual void didConsumeBufferedAmount(uint64_t) override; | 111 void didConsumeBufferedAmount(uint64_t) override; |
| 112 virtual void didStartClosingHandshake() override; | 112 void didStartClosingHandshake() override; |
| 113 virtual void didClose(ClosingHandshakeCompletionStatus, unsigned short c
ode, const String& reason) override; | 113 void didClose(ClosingHandshakeCompletionStatus, unsigned short code, con
st String& reason) override; |
| 114 virtual void didError() override; | 114 void didError() override; |
| 115 | 115 |
| 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> { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 WorkerWebSocketChannel(WorkerGlobalScope&, WebSocketChannelClient*, const St
ring& sourceURL, unsigned lineNumber); | 157 WorkerWebSocketChannel(WorkerGlobalScope&, WebSocketChannelClient*, const St
ring& sourceURL, unsigned lineNumber); |
| 158 | 158 |
| 159 Member<Bridge> m_bridge; | 159 Member<Bridge> m_bridge; |
| 160 String m_sourceURLAtConnection; | 160 String m_sourceURLAtConnection; |
| 161 unsigned m_lineNumberAtConnection; | 161 unsigned m_lineNumberAtConnection; |
| 162 }; | 162 }; |
| 163 | 163 |
| 164 } // namespace blink | 164 } // namespace blink |
| 165 | 165 |
| 166 #endif // WorkerWebSocketChannel_h | 166 #endif // WorkerWebSocketChannel_h |
| OLD | NEW |