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 27 matching lines...) Expand all Loading... |
38 #include "WorkerContext.h" | 38 #include "WorkerContext.h" |
39 | 39 |
40 #include <wtf/PassRefPtr.h> | 40 #include <wtf/PassRefPtr.h> |
41 #include <wtf/RefCounted.h> | 41 #include <wtf/RefCounted.h> |
42 #include <wtf/RefPtr.h> | 42 #include <wtf/RefPtr.h> |
43 #include <wtf/Threading.h> | 43 #include <wtf/Threading.h> |
44 #include <wtf/text/WTFString.h> | 44 #include <wtf/text/WTFString.h> |
45 | 45 |
46 namespace WebCore { | 46 namespace WebCore { |
47 | 47 |
| 48 class BlobDataHandle; |
48 class KURL; | 49 class KURL; |
49 class ScriptExecutionContext; | 50 class ScriptExecutionContext; |
50 class ThreadableWebSocketChannelClientWrapper; | 51 class ThreadableWebSocketChannelClientWrapper; |
51 class WorkerContext; | 52 class WorkerContext; |
52 class WorkerLoaderProxy; | 53 class WorkerLoaderProxy; |
53 class WorkerRunLoop; | 54 class WorkerRunLoop; |
54 | 55 |
55 class WorkerThreadableWebSocketChannel : public RefCounted<WorkerThreadableWebSo
cketChannel>, public ThreadableWebSocketChannel { | 56 class WorkerThreadableWebSocketChannel : public RefCounted<WorkerThreadableWebSo
cketChannel>, public ThreadableWebSocketChannel { |
56 WTF_MAKE_FAST_ALLOCATED; | 57 WTF_MAKE_FAST_ALLOCATED; |
57 public: | 58 public: |
(...skipping 25 matching lines...) Expand all Loading... |
83 static Peer* create(PassRefPtr<ThreadableWebSocketChannelClientWrapper>
clientWrapper, WorkerLoaderProxy& loaderProxy, ScriptExecutionContext* context,
const String& taskMode) | 84 static Peer* create(PassRefPtr<ThreadableWebSocketChannelClientWrapper>
clientWrapper, WorkerLoaderProxy& loaderProxy, ScriptExecutionContext* context,
const String& taskMode) |
84 { | 85 { |
85 return new Peer(clientWrapper, loaderProxy, context, taskMode); | 86 return new Peer(clientWrapper, loaderProxy, context, taskMode); |
86 } | 87 } |
87 ~Peer(); | 88 ~Peer(); |
88 | 89 |
89 void connect(const KURL&, const String& protocol); | 90 void connect(const KURL&, const String& protocol); |
90 void send(const String& message); | 91 void send(const String& message); |
91 void send(const ArrayBuffer&); | 92 void send(const ArrayBuffer&); |
92 void send(const Blob&); | 93 void send(const Blob&); |
| 94 void send(PassRefPtr<BlobDataHandle> blobDataHandle); |
93 void bufferedAmount(); | 95 void bufferedAmount(); |
94 void close(int code, const String& reason); | 96 void close(int code, const String& reason); |
95 void fail(const String& reason); | 97 void fail(const String& reason); |
96 void disconnect(); | 98 void disconnect(); |
97 void suspend(); | 99 void suspend(); |
98 void resume(); | 100 void resume(); |
99 | 101 |
100 // WebSocketChannelClient functions. | 102 // WebSocketChannelClient functions. |
101 virtual void didConnect() OVERRIDE; | 103 virtual void didConnect() OVERRIDE; |
102 virtual void didReceiveMessage(const String& message) OVERRIDE; | 104 virtual void didReceiveMessage(const String& message) OVERRIDE; |
(...skipping 25 matching lines...) Expand all Loading... |
128 public: | 130 public: |
129 static PassRefPtr<Bridge> create(PassRefPtr<ThreadableWebSocketChannelCl
ientWrapper> workerClientWrapper, PassRefPtr<WorkerContext> workerContext, const
String& taskMode) | 131 static PassRefPtr<Bridge> create(PassRefPtr<ThreadableWebSocketChannelCl
ientWrapper> workerClientWrapper, PassRefPtr<WorkerContext> workerContext, const
String& taskMode) |
130 { | 132 { |
131 return adoptRef(new Bridge(workerClientWrapper, workerContext, taskM
ode)); | 133 return adoptRef(new Bridge(workerClientWrapper, workerContext, taskM
ode)); |
132 } | 134 } |
133 ~Bridge(); | 135 ~Bridge(); |
134 void initialize(); | 136 void initialize(); |
135 void connect(const KURL&, const String& protocol); | 137 void connect(const KURL&, const String& protocol); |
136 ThreadableWebSocketChannel::SendResult send(const String& message); | 138 ThreadableWebSocketChannel::SendResult send(const String& message); |
137 ThreadableWebSocketChannel::SendResult send(const ArrayBuffer&, unsigned
byteOffset, unsigned byteLength); | 139 ThreadableWebSocketChannel::SendResult send(const ArrayBuffer&, unsigned
byteOffset, unsigned byteLength); |
138 ThreadableWebSocketChannel::SendResult send(const Blob&); | 140 ThreadableWebSocketChannel::SendResult send(PassRefPtr<BlobDataHandle> b
lobDataHandle); |
139 unsigned long bufferedAmount(); | 141 unsigned long bufferedAmount(); |
140 void close(int code, const String& reason); | 142 void close(int code, const String& reason); |
141 void fail(const String& reason); | 143 void fail(const String& reason); |
142 void disconnect(); | 144 void disconnect(); |
143 void suspend(); | 145 void suspend(); |
144 void resume(); | 146 void resume(); |
145 | 147 |
146 using RefCounted<Bridge>::ref; | 148 using RefCounted<Bridge>::ref; |
147 using RefCounted<Bridge>::deref; | 149 using RefCounted<Bridge>::deref; |
148 | 150 |
(...skipping 16 matching lines...) Expand all Loading... |
165 WorkerLoaderProxy& m_loaderProxy; | 167 WorkerLoaderProxy& m_loaderProxy; |
166 String m_taskMode; | 168 String m_taskMode; |
167 Peer* m_peer; | 169 Peer* m_peer; |
168 }; | 170 }; |
169 | 171 |
170 WorkerThreadableWebSocketChannel(WorkerContext*, WebSocketChannelClient*, co
nst String& taskMode); | 172 WorkerThreadableWebSocketChannel(WorkerContext*, WebSocketChannelClient*, co
nst String& taskMode); |
171 | 173 |
172 static void mainThreadConnect(ScriptExecutionContext*, Peer*, const KURL&, c
onst String& protocol); | 174 static void mainThreadConnect(ScriptExecutionContext*, Peer*, const KURL&, c
onst String& protocol); |
173 static void mainThreadSend(ScriptExecutionContext*, Peer*, const String& mes
sage); | 175 static void mainThreadSend(ScriptExecutionContext*, Peer*, const String& mes
sage); |
174 static void mainThreadSendArrayBuffer(ScriptExecutionContext*, Peer*, PassOw
nPtr<Vector<char> >); | 176 static void mainThreadSendArrayBuffer(ScriptExecutionContext*, Peer*, PassOw
nPtr<Vector<char> >); |
175 static void mainThreadSendBlob(ScriptExecutionContext*, Peer*, const KURL&,
const String& type, long long size); | 177 static void mainThreadSendBlob(ScriptExecutionContext*, Peer*, PassRefPtr<Bl
obDataHandle> blobDataHandle); |
176 static void mainThreadBufferedAmount(ScriptExecutionContext*, Peer*); | 178 static void mainThreadBufferedAmount(ScriptExecutionContext*, Peer*); |
177 static void mainThreadClose(ScriptExecutionContext*, Peer*, int code, const
String& reason); | 179 static void mainThreadClose(ScriptExecutionContext*, Peer*, int code, const
String& reason); |
178 static void mainThreadFail(ScriptExecutionContext*, Peer*, const String& rea
son); | 180 static void mainThreadFail(ScriptExecutionContext*, Peer*, const String& rea
son); |
179 static void mainThreadDestroy(ScriptExecutionContext*, PassOwnPtr<Peer>); | 181 static void mainThreadDestroy(ScriptExecutionContext*, PassOwnPtr<Peer>); |
180 static void mainThreadSuspend(ScriptExecutionContext*, Peer*); | 182 static void mainThreadSuspend(ScriptExecutionContext*, Peer*); |
181 static void mainThreadResume(ScriptExecutionContext*, Peer*); | 183 static void mainThreadResume(ScriptExecutionContext*, Peer*); |
182 | 184 |
183 class WorkerContextDidInitializeTask; | 185 class WorkerContextDidInitializeTask; |
184 | 186 |
185 RefPtr<WorkerContext> m_workerContext; | 187 RefPtr<WorkerContext> m_workerContext; |
186 RefPtr<ThreadableWebSocketChannelClientWrapper> m_workerClientWrapper; | 188 RefPtr<ThreadableWebSocketChannelClientWrapper> m_workerClientWrapper; |
187 RefPtr<Bridge> m_bridge; | 189 RefPtr<Bridge> m_bridge; |
188 }; | 190 }; |
189 | 191 |
190 } // namespace WebCore | 192 } // namespace WebCore |
191 | 193 |
192 #endif // ENABLE(WEB_SOCKETS) | 194 #endif // ENABLE(WEB_SOCKETS) |
193 | 195 |
194 #endif // WorkerThreadableWebSocketChannel_h | 196 #endif // WorkerThreadableWebSocketChannel_h |
OLD | NEW |