Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(366)

Side by Side Diff: Source/modules/websockets/WorkerThreadableWebSocketChannel.h

Issue 23992003: blob hacking webcore style (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 28 matching lines...) Expand all
39 #include "wtf/PassOwnPtr.h" 39 #include "wtf/PassOwnPtr.h"
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/Vector.h" 44 #include "wtf/Vector.h"
45 #include "wtf/text/WTFString.h" 45 #include "wtf/text/WTFString.h"
46 46
47 namespace WebCore { 47 namespace WebCore {
48 48
49 class BlobDataHandle;
49 class KURL; 50 class KURL;
50 class ExecutionContext; 51 class ExecutionContext;
51 class ThreadableWebSocketChannelClientWrapper; 52 class ThreadableWebSocketChannelClientWrapper;
52 class WorkerGlobalScope; 53 class WorkerGlobalScope;
53 class WorkerLoaderProxy; 54 class WorkerLoaderProxy;
54 class WorkerRunLoop; 55 class WorkerRunLoop;
55 56
56 class WorkerThreadableWebSocketChannel : public RefCounted<WorkerThreadableWebSo cketChannel>, public WebSocketChannel { 57 class WorkerThreadableWebSocketChannel : public RefCounted<WorkerThreadableWebSo cketChannel>, public WebSocketChannel {
57 WTF_MAKE_FAST_ALLOCATED; 58 WTF_MAKE_FAST_ALLOCATED;
58 public: 59 public:
59 static PassRefPtr<WebSocketChannel> create(WorkerGlobalScope* workerGlobalSc ope, WebSocketChannelClient* client, const String& taskMode) 60 static PassRefPtr<WebSocketChannel> create(WorkerGlobalScope* workerGlobalSc ope, WebSocketChannelClient* client, const String& taskMode)
60 { 61 {
61 return adoptRef(new WorkerThreadableWebSocketChannel(workerGlobalScope, client, taskMode)); 62 return adoptRef(new WorkerThreadableWebSocketChannel(workerGlobalScope, client, taskMode));
62 } 63 }
63 virtual ~WorkerThreadableWebSocketChannel(); 64 virtual ~WorkerThreadableWebSocketChannel();
64 65
65 // WebSocketChannel functions. 66 // WebSocketChannel functions.
66 virtual void connect(const KURL&, const String& protocol) OVERRIDE; 67 virtual void connect(const KURL&, const String& protocol) OVERRIDE;
67 virtual String subprotocol() OVERRIDE; 68 virtual String subprotocol() OVERRIDE;
68 virtual String extensions() OVERRIDE; 69 virtual String extensions() OVERRIDE;
69 virtual WebSocketChannel::SendResult send(const String& message) OVERRIDE; 70 virtual WebSocketChannel::SendResult send(const String& message) OVERRIDE;
70 virtual WebSocketChannel::SendResult send(const ArrayBuffer&, unsigned byteO ffset, unsigned byteLength) OVERRIDE; 71 virtual WebSocketChannel::SendResult send(const ArrayBuffer&, unsigned byteO ffset, unsigned byteLength) OVERRIDE;
71 virtual WebSocketChannel::SendResult send(const Blob&) OVERRIDE; 72 virtual WebSocketChannel::SendResult send(PassRefPtr<BlobDataHandle>) OVERRI DE;
72 virtual unsigned long bufferedAmount() const OVERRIDE; 73 virtual unsigned long bufferedAmount() const OVERRIDE;
73 virtual void close(int code, const String& reason) OVERRIDE; 74 virtual void close(int code, const String& reason) OVERRIDE;
74 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;
75 virtual void disconnect() OVERRIDE; // Will suppress didClose(). 76 virtual void disconnect() OVERRIDE; // Will suppress didClose().
76 virtual void suspend() OVERRIDE; 77 virtual void suspend() OVERRIDE;
77 virtual void resume() OVERRIDE; 78 virtual void resume() OVERRIDE;
78 79
79 // Generated by the bridge. The Peer and its bridge should have identical 80 // Generated by the bridge. The Peer and its bridge should have identical
80 // lifetimes. 81 // lifetimes.
81 class Peer : public WebSocketChannelClient { 82 class Peer : public WebSocketChannelClient {
82 WTF_MAKE_NONCOPYABLE(Peer); WTF_MAKE_FAST_ALLOCATED; 83 WTF_MAKE_NONCOPYABLE(Peer); WTF_MAKE_FAST_ALLOCATED;
83 public: 84 public:
84 // sourceURLAtConnection and lineNumberAtConnection parameters may 85 // sourceURLAtConnection and lineNumberAtConnection parameters may
85 // be shown when the connection fails. 86 // be shown when the connection fails.
86 static Peer* create(PassRefPtr<ThreadableWebSocketChannelClientWrapper> clientWrapper, WorkerLoaderProxy& loaderProxy, ExecutionContext* context, const String& taskMode, const String& sourceURLAtConnection, unsigned lineNumberAtConn ection) 87 static Peer* create(PassRefPtr<ThreadableWebSocketChannelClientWrapper> clientWrapper, WorkerLoaderProxy& loaderProxy, ExecutionContext* context, const String& taskMode, const String& sourceURLAtConnection, unsigned lineNumberAtConn ection)
87 { 88 {
88 return new Peer(clientWrapper, loaderProxy, context, taskMode, sourc eURLAtConnection, lineNumberAtConnection); 89 return new Peer(clientWrapper, loaderProxy, context, taskMode, sourc eURLAtConnection, lineNumberAtConnection);
89 } 90 }
90 ~Peer(); 91 ~Peer();
91 92
92 void connect(const KURL&, const String& protocol); 93 void connect(const KURL&, const String& protocol);
93 void send(const String& message); 94 void send(const String& message);
94 void send(const ArrayBuffer&); 95 void send(const ArrayBuffer&);
95 void send(const Blob&); 96 void send(PassRefPtr<BlobDataHandle>);
96 void bufferedAmount(); 97 void bufferedAmount();
97 void close(int code, const String& reason); 98 void close(int code, const String& reason);
98 void fail(const String& reason, MessageLevel, const String& sourceURL, u nsigned lineNumber); 99 void fail(const String& reason, MessageLevel, const String& sourceURL, u nsigned lineNumber);
99 void disconnect(); 100 void disconnect();
100 void suspend(); 101 void suspend();
101 void resume(); 102 void resume();
102 103
103 // WebSocketChannelClient functions. 104 // WebSocketChannelClient functions.
104 virtual void didConnect() OVERRIDE; 105 virtual void didConnect() OVERRIDE;
105 virtual void didReceiveMessage(const String& message) OVERRIDE; 106 virtual void didReceiveMessage(const String& message) OVERRIDE;
(...skipping 28 matching lines...) Expand all
134 { 135 {
135 return adoptRef(new Bridge(workerClientWrapper, workerGlobalScope, t askMode)); 136 return adoptRef(new Bridge(workerClientWrapper, workerGlobalScope, t askMode));
136 } 137 }
137 ~Bridge(); 138 ~Bridge();
138 // sourceURLAtConnection and lineNumberAtConnection parameters may 139 // sourceURLAtConnection and lineNumberAtConnection parameters may
139 // be shown when the connection fails. 140 // be shown when the connection fails.
140 void initialize(const String& sourceURLAtConnection, unsigned lineNumber AtConnection); 141 void initialize(const String& sourceURLAtConnection, unsigned lineNumber AtConnection);
141 void connect(const KURL&, const String& protocol); 142 void connect(const KURL&, const String& protocol);
142 WebSocketChannel::SendResult send(const String& message); 143 WebSocketChannel::SendResult send(const String& message);
143 WebSocketChannel::SendResult send(const ArrayBuffer&, unsigned byteOffse t, unsigned byteLength); 144 WebSocketChannel::SendResult send(const ArrayBuffer&, unsigned byteOffse t, unsigned byteLength);
144 WebSocketChannel::SendResult send(const Blob&); 145 WebSocketChannel::SendResult send(PassRefPtr<BlobDataHandle>);
145 unsigned long bufferedAmount(); 146 unsigned long bufferedAmount();
146 void close(int code, const String& reason); 147 void close(int code, const String& reason);
147 void fail(const String& reason, MessageLevel, const String& sourceURL, u nsigned lineNumber); 148 void fail(const String& reason, MessageLevel, const String& sourceURL, u nsigned lineNumber);
148 void disconnect(); 149 void disconnect();
149 void suspend(); 150 void suspend();
150 void resume(); 151 void resume();
151 152
152 using RefCounted<Bridge>::ref; 153 using RefCounted<Bridge>::ref;
153 using RefCounted<Bridge>::deref; 154 using RefCounted<Bridge>::deref;
154 155
(...skipping 19 matching lines...) Expand all
174 WorkerLoaderProxy& m_loaderProxy; 175 WorkerLoaderProxy& m_loaderProxy;
175 String m_taskMode; 176 String m_taskMode;
176 Peer* m_peer; 177 Peer* m_peer;
177 }; 178 };
178 179
179 WorkerThreadableWebSocketChannel(WorkerGlobalScope*, WebSocketChannelClient* , const String& taskMode); 180 WorkerThreadableWebSocketChannel(WorkerGlobalScope*, WebSocketChannelClient* , const String& taskMode);
180 181
181 static void mainThreadConnect(ExecutionContext*, Peer*, const KURL&, const S tring& protocol); 182 static void mainThreadConnect(ExecutionContext*, Peer*, const KURL&, const S tring& protocol);
182 static void mainThreadSend(ExecutionContext*, Peer*, const String& message); 183 static void mainThreadSend(ExecutionContext*, Peer*, const String& message);
183 static void mainThreadSendArrayBuffer(ExecutionContext*, Peer*, PassOwnPtr<V ector<char> >); 184 static void mainThreadSendArrayBuffer(ExecutionContext*, Peer*, PassOwnPtr<V ector<char> >);
184 static void mainThreadSendBlob(ExecutionContext*, Peer*, const KURL&, const String& type, long long size); 185 static void mainThreadSendBlob(ExecutionContext*, Peer*, PassRefPtr<BlobData Handle>);
185 static void mainThreadBufferedAmount(ExecutionContext*, Peer*); 186 static void mainThreadBufferedAmount(ExecutionContext*, Peer*);
186 static void mainThreadClose(ExecutionContext*, Peer*, int code, const String & reason); 187 static void mainThreadClose(ExecutionContext*, Peer*, int code, const String & reason);
187 static void mainThreadFail(ExecutionContext*, Peer*, const String& reason, M essageLevel, const String& sourceURL, unsigned lineNumber); 188 static void mainThreadFail(ExecutionContext*, Peer*, const String& reason, M essageLevel, const String& sourceURL, unsigned lineNumber);
188 static void mainThreadDestroy(ExecutionContext*, PassOwnPtr<Peer>); 189 static void mainThreadDestroy(ExecutionContext*, PassOwnPtr<Peer>);
189 static void mainThreadSuspend(ExecutionContext*, Peer*); 190 static void mainThreadSuspend(ExecutionContext*, Peer*);
190 static void mainThreadResume(ExecutionContext*, Peer*); 191 static void mainThreadResume(ExecutionContext*, Peer*);
191 192
192 class WorkerGlobalScopeDidInitializeTask; 193 class WorkerGlobalScopeDidInitializeTask;
193 194
194 RefPtr<WorkerGlobalScope> m_workerGlobalScope; 195 RefPtr<WorkerGlobalScope> m_workerGlobalScope;
195 RefPtr<ThreadableWebSocketChannelClientWrapper> m_workerClientWrapper; 196 RefPtr<ThreadableWebSocketChannelClientWrapper> m_workerClientWrapper;
196 RefPtr<Bridge> m_bridge; 197 RefPtr<Bridge> m_bridge;
197 String m_sourceURLAtConnection; 198 String m_sourceURLAtConnection;
198 unsigned m_lineNumberAtConnection; 199 unsigned m_lineNumberAtConnection;
199 }; 200 };
200 201
201 } // namespace WebCore 202 } // namespace WebCore
202 203
203 #endif // WorkerThreadableWebSocketChannel_h 204 #endif // WorkerThreadableWebSocketChannel_h
OLDNEW
« no previous file with comments | « Source/modules/websockets/WebSocketChannel.h ('k') | Source/modules/websockets/WorkerThreadableWebSocketChannel.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698