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