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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 virtual WebSocketChannel::SendResult send(const ArrayBuffer&, unsigned byteO
ffset, unsigned byteLength) OVERRIDE; | 77 virtual WebSocketChannel::SendResult send(const ArrayBuffer&, unsigned byteO
ffset, unsigned byteLength) OVERRIDE; |
78 virtual WebSocketChannel::SendResult send(PassRefPtr<BlobDataHandle>) OVERRI
DE; | 78 virtual WebSocketChannel::SendResult send(PassRefPtr<BlobDataHandle>) OVERRI
DE; |
79 virtual WebSocketChannel::SendResult send(PassOwnPtr<Vector<char> >) OVERRID
E | 79 virtual WebSocketChannel::SendResult send(PassOwnPtr<Vector<char> >) OVERRID
E |
80 { | 80 { |
81 ASSERT_NOT_REACHED(); | 81 ASSERT_NOT_REACHED(); |
82 return WebSocketChannel::SendFail; | 82 return WebSocketChannel::SendFail; |
83 } | 83 } |
84 virtual void close(int code, const String& reason) OVERRIDE; | 84 virtual void close(int code, const String& reason) OVERRIDE; |
85 virtual void fail(const String& reason, MessageLevel, const String&, unsigne
d) OVERRIDE; | 85 virtual void fail(const String& reason, MessageLevel, const String&, unsigne
d) OVERRIDE; |
86 virtual void disconnect() OVERRIDE; // Will suppress didClose(). | 86 virtual void disconnect() OVERRIDE; // Will suppress didClose(). |
87 virtual void suspend() OVERRIDE { } | 87 virtual void suspend() OVERRIDE; |
88 virtual void resume() OVERRIDE { } | 88 virtual void resume() OVERRIDE; |
89 | 89 |
90 virtual void trace(Visitor*) OVERRIDE; | 90 virtual void trace(Visitor*) OVERRIDE; |
91 | 91 |
92 // Generated by the bridge. The Peer is destructed by an async call from | 92 // Generated by the bridge. The Peer is destructed by an async call from |
93 // Bridge, and may outlive the bridge. All methods of this class must | 93 // Bridge, and may outlive the bridge. All methods of this class must |
94 // be called on the main thread. | 94 // be called on the main thread. |
95 class Peer FINAL : public WebSocketChannelClient { | 95 class Peer FINAL : public WebSocketChannelClient { |
96 WTF_MAKE_NONCOPYABLE(Peer); WTF_MAKE_FAST_ALLOCATED; | 96 WTF_MAKE_NONCOPYABLE(Peer); WTF_MAKE_FAST_ALLOCATED; |
97 public: | 97 public: |
98 virtual ~Peer(); | 98 virtual ~Peer(); |
99 | 99 |
100 // sourceURLAtConnection and lineNumberAtConnection parameters may | 100 // sourceURLAtConnection and lineNumberAtConnection parameters may |
101 // be shown when the connection fails. | 101 // be shown when the connection fails. |
102 static void initialize(ExecutionContext*, PassRefPtr<WeakReference<Peer>
>, WorkerLoaderProxy*, PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientW
rapper>, const String& sourceURLAtConnection, unsigned lineNumberAtConnection, P
assOwnPtr<ThreadableWebSocketChannelSyncHelper>); | 102 static void initialize(ExecutionContext*, PassRefPtr<WeakReference<Peer>
>, WorkerLoaderProxy*, PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientW
rapper>, const String& sourceURLAtConnection, unsigned lineNumberAtConnection, P
assOwnPtr<ThreadableWebSocketChannelSyncHelper>); |
103 void destroy(); | 103 void destroy(); |
104 | 104 |
105 void connect(const KURL&, const String& protocol); | 105 void connect(const KURL&, const String& protocol); |
106 void send(const String& message); | 106 void send(const String& message); |
107 void sendArrayBuffer(PassOwnPtr<Vector<char> >); | 107 void sendArrayBuffer(PassOwnPtr<Vector<char> >); |
108 void sendBlob(PassRefPtr<BlobDataHandle>); | 108 void sendBlob(PassRefPtr<BlobDataHandle>); |
109 void bufferedAmount(); | 109 void bufferedAmount(); |
110 void close(int code, const String& reason); | 110 void close(int code, const String& reason); |
111 void fail(const String& reason, MessageLevel, const String& sourceURL, u
nsigned lineNumber); | 111 void fail(const String& reason, MessageLevel, const String& sourceURL, u
nsigned lineNumber); |
112 void disconnect(); | 112 void disconnect(); |
| 113 void suspend(); |
| 114 void resume(); |
113 | 115 |
114 // WebSocketChannelClient functions. | 116 // WebSocketChannelClient functions. |
115 virtual void didConnect(const String& subprotocol, const String& extensi
ons) OVERRIDE; | 117 virtual void didConnect(const String& subprotocol, const String& extensi
ons) OVERRIDE; |
116 virtual void didReceiveMessage(const String& message) OVERRIDE; | 118 virtual void didReceiveMessage(const String& message) OVERRIDE; |
117 virtual void didReceiveBinaryData(PassOwnPtr<Vector<char> >) OVERRIDE; | 119 virtual void didReceiveBinaryData(PassOwnPtr<Vector<char> >) OVERRIDE; |
118 virtual void didConsumeBufferedAmount(unsigned long) OVERRIDE; | 120 virtual void didConsumeBufferedAmount(unsigned long) OVERRIDE; |
119 virtual void didStartClosingHandshake() OVERRIDE; | 121 virtual void didStartClosingHandshake() OVERRIDE; |
120 virtual void didClose(ClosingHandshakeCompletionStatus, unsigned short c
ode, const String& reason) OVERRIDE; | 122 virtual void didClose(ClosingHandshakeCompletionStatus, unsigned short c
ode, const String& reason) OVERRIDE; |
121 virtual void didReceiveMessageError() OVERRIDE; | 123 virtual void didReceiveMessageError() OVERRIDE; |
122 | 124 |
(...skipping 20 matching lines...) Expand all Loading... |
143 // be shown when the connection fails. | 145 // be shown when the connection fails. |
144 void initialize(const String& sourceURLAtConnection, unsigned lineNumber
AtConnection); | 146 void initialize(const String& sourceURLAtConnection, unsigned lineNumber
AtConnection); |
145 bool connect(const KURL&, const String& protocol); | 147 bool connect(const KURL&, const String& protocol); |
146 WebSocketChannel::SendResult send(const String& message); | 148 WebSocketChannel::SendResult send(const String& message); |
147 WebSocketChannel::SendResult send(const ArrayBuffer&, unsigned byteOffse
t, unsigned byteLength); | 149 WebSocketChannel::SendResult send(const ArrayBuffer&, unsigned byteOffse
t, unsigned byteLength); |
148 WebSocketChannel::SendResult send(PassRefPtr<BlobDataHandle>); | 150 WebSocketChannel::SendResult send(PassRefPtr<BlobDataHandle>); |
149 unsigned long bufferedAmount(); | 151 unsigned long bufferedAmount(); |
150 void close(int code, const String& reason); | 152 void close(int code, const String& reason); |
151 void fail(const String& reason, MessageLevel, const String& sourceURL, u
nsigned lineNumber); | 153 void fail(const String& reason, MessageLevel, const String& sourceURL, u
nsigned lineNumber); |
152 void disconnect(); | 154 void disconnect(); |
| 155 void suspend(); |
| 156 void resume(); |
153 | 157 |
154 private: | 158 private: |
155 Bridge(PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper>,
WorkerGlobalScope&); | 159 Bridge(PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper>,
WorkerGlobalScope&); |
156 | 160 |
157 static void setWebSocketChannel(ExecutionContext*, Bridge* thisPtr, Peer
*, PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper>); | 161 static void setWebSocketChannel(ExecutionContext*, Bridge* thisPtr, Peer
*, PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper>); |
158 | 162 |
159 // Executed on the worker context's thread. | 163 // Executed on the worker context's thread. |
160 void clearClientWrapper(); | 164 void clearClientWrapper(); |
161 | 165 |
162 // Returns false if shutdown event is received before method completion. | 166 // Returns false if shutdown event is received before method completion. |
(...skipping 14 matching lines...) Expand all Loading... |
177 | 181 |
178 const RefPtrWillBeMember<ThreadableWebSocketChannelClientWrapper> m_workerCl
ientWrapper; | 182 const RefPtrWillBeMember<ThreadableWebSocketChannelClientWrapper> m_workerCl
ientWrapper; |
179 RefPtr<Bridge> m_bridge; | 183 RefPtr<Bridge> m_bridge; |
180 String m_sourceURLAtConnection; | 184 String m_sourceURLAtConnection; |
181 unsigned m_lineNumberAtConnection; | 185 unsigned m_lineNumberAtConnection; |
182 }; | 186 }; |
183 | 187 |
184 } // namespace WebCore | 188 } // namespace WebCore |
185 | 189 |
186 #endif // WorkerThreadableWebSocketChannel_h | 190 #endif // WorkerThreadableWebSocketChannel_h |
OLD | NEW |