| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 namespace blink { | 45 namespace blink { |
| 46 | 46 |
| 47 class BlobDataHandle; | 47 class BlobDataHandle; |
| 48 class KURL; | 48 class KURL; |
| 49 class ExecutionContext; | 49 class ExecutionContext; |
| 50 class ExecutionContextTask; | 50 class ExecutionContextTask; |
| 51 class ThreadableWebSocketChannelSyncHelper; | 51 class ThreadableWebSocketChannelSyncHelper; |
| 52 class WorkerGlobalScope; | 52 class WorkerGlobalScope; |
| 53 class WorkerLoaderProxy; | 53 class WorkerLoaderProxy; |
| 54 | 54 |
| 55 class WorkerThreadableWebSocketChannel FINAL : public WebSocketChannel { | 55 class WorkerThreadableWebSocketChannel final : public WebSocketChannel { |
| 56 WTF_MAKE_NONCOPYABLE(WorkerThreadableWebSocketChannel); | 56 WTF_MAKE_NONCOPYABLE(WorkerThreadableWebSocketChannel); |
| 57 public: | 57 public: |
| 58 static WebSocketChannel* create(WorkerGlobalScope& workerGlobalScope, WebSoc
ketChannelClient* client, const String& sourceURL, unsigned lineNumber) | 58 static WebSocketChannel* create(WorkerGlobalScope& workerGlobalScope, WebSoc
ketChannelClient* client, const String& sourceURL, unsigned lineNumber) |
| 59 { | 59 { |
| 60 return adoptRefCountedGarbageCollected(new WorkerThreadableWebSocketChan
nel(workerGlobalScope, client, sourceURL, lineNumber)); | 60 return adoptRefCountedGarbageCollected(new WorkerThreadableWebSocketChan
nel(workerGlobalScope, client, sourceURL, lineNumber)); |
| 61 } | 61 } |
| 62 virtual ~WorkerThreadableWebSocketChannel(); | 62 virtual ~WorkerThreadableWebSocketChannel(); |
| 63 | 63 |
| 64 // WebSocketChannel functions. | 64 // WebSocketChannel functions. |
| 65 virtual bool connect(const KURL&, const String& protocol) OVERRIDE; | 65 virtual bool connect(const KURL&, const String& protocol) override; |
| 66 virtual void send(const String& message) OVERRIDE; | 66 virtual void send(const String& message) override; |
| 67 virtual void send(const ArrayBuffer&, unsigned byteOffset, unsigned byteLeng
th) OVERRIDE; | 67 virtual void send(const ArrayBuffer&, unsigned byteOffset, unsigned byteLeng
th) override; |
| 68 virtual void send(PassRefPtr<BlobDataHandle>) OVERRIDE; | 68 virtual void send(PassRefPtr<BlobDataHandle>) override; |
| 69 virtual void send(PassOwnPtr<Vector<char> >) OVERRIDE | 69 virtual void send(PassOwnPtr<Vector<char> >) override |
| 70 { | 70 { |
| 71 ASSERT_NOT_REACHED(); | 71 ASSERT_NOT_REACHED(); |
| 72 } | 72 } |
| 73 virtual void close(int code, const String& reason) OVERRIDE; | 73 virtual void close(int code, const String& reason) override; |
| 74 virtual void fail(const String& reason, MessageLevel, const String&, unsigne
d) OVERRIDE; | 74 virtual void fail(const String& reason, MessageLevel, const String&, unsigne
d) override; |
| 75 virtual void disconnect() OVERRIDE; // Will suppress didClose(). | 75 virtual void disconnect() override; // Will suppress didClose(). |
| 76 virtual void suspend() OVERRIDE { } | 76 virtual void suspend() override { } |
| 77 virtual void resume() OVERRIDE { } | 77 virtual void resume() override { } |
| 78 | 78 |
| 79 virtual void trace(Visitor*) OVERRIDE; | 79 virtual void trace(Visitor*) override; |
| 80 | 80 |
| 81 class Bridge; | 81 class Bridge; |
| 82 // Allocated in the worker thread, but used in the main thread. | 82 // Allocated in the worker thread, but used in the main thread. |
| 83 class Peer FINAL : public GarbageCollectedFinalized<Peer>, public WebSocketC
hannelClient { | 83 class Peer final : public GarbageCollectedFinalized<Peer>, public WebSocketC
hannelClient { |
| 84 USING_GARBAGE_COLLECTED_MIXIN(Peer); | 84 USING_GARBAGE_COLLECTED_MIXIN(Peer); |
| 85 WTF_MAKE_NONCOPYABLE(Peer); | 85 WTF_MAKE_NONCOPYABLE(Peer); |
| 86 public: | 86 public: |
| 87 Peer(Bridge*, WorkerLoaderProxy&, ThreadableWebSocketChannelSyncHelper*)
; | 87 Peer(Bridge*, WorkerLoaderProxy&, ThreadableWebSocketChannelSyncHelper*)
; |
| 88 virtual ~Peer(); | 88 virtual ~Peer(); |
| 89 | 89 |
| 90 // sourceURLAtConnection and lineNumberAtConnection parameters may | 90 // sourceURLAtConnection and lineNumberAtConnection parameters may |
| 91 // be shown when the connection fails. | 91 // be shown when the connection fails. |
| 92 static void initialize(ExecutionContext* executionContext, Peer* peer, c
onst String& sourceURLAtConnection, unsigned lineNumberAtConnection) | 92 static void initialize(ExecutionContext* executionContext, Peer* peer, c
onst String& sourceURLAtConnection, unsigned lineNumberAtConnection) |
| 93 { | 93 { |
| 94 peer->initializeInternal(executionContext, sourceURLAtConnection, li
neNumberAtConnection); | 94 peer->initializeInternal(executionContext, sourceURLAtConnection, li
neNumberAtConnection); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void connect(const KURL&, const String& protocol); | 97 void connect(const KURL&, const String& protocol); |
| 98 void send(const String& message); | 98 void send(const String& message); |
| 99 void sendArrayBuffer(PassOwnPtr<Vector<char> >); | 99 void sendArrayBuffer(PassOwnPtr<Vector<char> >); |
| 100 void sendBlob(PassRefPtr<BlobDataHandle>); | 100 void sendBlob(PassRefPtr<BlobDataHandle>); |
| 101 void bufferedAmount(); | 101 void bufferedAmount(); |
| 102 void close(int code, const String& reason); | 102 void close(int code, const String& reason); |
| 103 void fail(const String& reason, MessageLevel, const String& sourceURL, u
nsigned lineNumber); | 103 void fail(const String& reason, MessageLevel, const String& sourceURL, u
nsigned lineNumber); |
| 104 void disconnect(); | 104 void disconnect(); |
| 105 | 105 |
| 106 virtual void trace(Visitor*) OVERRIDE; | 106 virtual void trace(Visitor*) override; |
| 107 | 107 |
| 108 // WebSocketChannelClient functions. | 108 // WebSocketChannelClient functions. |
| 109 virtual void didConnect(const String& subprotocol, const String& extensi
ons) OVERRIDE; | 109 virtual void didConnect(const String& subprotocol, const String& extensi
ons) override; |
| 110 virtual void didReceiveTextMessage(const String& payload) OVERRIDE; | 110 virtual void didReceiveTextMessage(const String& payload) override; |
| 111 virtual void didReceiveBinaryMessage(PassOwnPtr<Vector<char> >) OVERRIDE
; | 111 virtual void didReceiveBinaryMessage(PassOwnPtr<Vector<char> >) override
; |
| 112 virtual void didConsumeBufferedAmount(unsigned long) OVERRIDE; | 112 virtual void didConsumeBufferedAmount(unsigned long) override; |
| 113 virtual void didStartClosingHandshake() OVERRIDE; | 113 virtual void didStartClosingHandshake() override; |
| 114 virtual void didClose(ClosingHandshakeCompletionStatus, unsigned short c
ode, const String& reason) OVERRIDE; | 114 virtual void didClose(ClosingHandshakeCompletionStatus, unsigned short c
ode, const String& reason) override; |
| 115 virtual void didError() OVERRIDE; | 115 virtual void didError() override; |
| 116 | 116 |
| 117 private: | 117 private: |
| 118 void initializeInternal(ExecutionContext*, const String& sourceURLAtConn
ection, unsigned lineNumberAtConnection); | 118 void initializeInternal(ExecutionContext*, const String& sourceURLAtConn
ection, unsigned lineNumberAtConnection); |
| 119 | 119 |
| 120 Member<Bridge> m_bridge; | 120 Member<Bridge> m_bridge; |
| 121 WorkerLoaderProxy& m_loaderProxy; | 121 WorkerLoaderProxy& m_loaderProxy; |
| 122 Member<WebSocketChannel> m_mainWebSocketChannel; | 122 Member<WebSocketChannel> m_mainWebSocketChannel; |
| 123 Member<ThreadableWebSocketChannelSyncHelper> m_syncHelper; | 123 Member<ThreadableWebSocketChannelSyncHelper> m_syncHelper; |
| 124 }; | 124 }; |
| 125 | 125 |
| 126 // Bridge for Peer. Running on the worker thread. | 126 // Bridge for Peer. Running on the worker thread. |
| 127 class Bridge FINAL : public GarbageCollectedFinalized<Bridge> { | 127 class Bridge final : public GarbageCollectedFinalized<Bridge> { |
| 128 WTF_MAKE_NONCOPYABLE(Bridge); | 128 WTF_MAKE_NONCOPYABLE(Bridge); |
| 129 public: | 129 public: |
| 130 Bridge(WebSocketChannelClient*, WorkerGlobalScope&); | 130 Bridge(WebSocketChannelClient*, WorkerGlobalScope&); |
| 131 ~Bridge(); | 131 ~Bridge(); |
| 132 // sourceURLAtConnection and lineNumberAtConnection parameters may | 132 // sourceURLAtConnection and lineNumberAtConnection parameters may |
| 133 // be shown when the connection fails. | 133 // be shown when the connection fails. |
| 134 void initialize(const String& sourceURLAtConnection, unsigned lineNumber
AtConnection); | 134 void initialize(const String& sourceURLAtConnection, unsigned lineNumber
AtConnection); |
| 135 bool connect(const KURL&, const String& protocol); | 135 bool connect(const KURL&, const String& protocol); |
| 136 void send(const String& message); | 136 void send(const String& message); |
| 137 void send(const ArrayBuffer&, unsigned byteOffset, unsigned byteLength); | 137 void send(const ArrayBuffer&, unsigned byteOffset, unsigned byteLength); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 161 WorkerThreadableWebSocketChannel(WorkerGlobalScope&, WebSocketChannelClient*
, const String& sourceURL, unsigned lineNumber); | 161 WorkerThreadableWebSocketChannel(WorkerGlobalScope&, WebSocketChannelClient*
, const String& sourceURL, unsigned lineNumber); |
| 162 | 162 |
| 163 Member<Bridge> m_bridge; | 163 Member<Bridge> m_bridge; |
| 164 String m_sourceURLAtConnection; | 164 String m_sourceURLAtConnection; |
| 165 unsigned m_lineNumberAtConnection; | 165 unsigned m_lineNumberAtConnection; |
| 166 }; | 166 }; |
| 167 | 167 |
| 168 } // namespace blink | 168 } // namespace blink |
| 169 | 169 |
| 170 #endif // WorkerThreadableWebSocketChannel_h | 170 #endif // WorkerThreadableWebSocketChannel_h |
| OLD | NEW |