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

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

Issue 267323004: Oilpan: Move ThreadableWebSocketChannelClientWrapper to Oilpan's heap (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 // Generated by the bridge. The Peer is destructed by an async call from 93 // Generated by the bridge. The Peer is destructed by an async call from
94 // Bridge, and may outlive the bridge. All methods of this class must 94 // Bridge, and may outlive the bridge. All methods of this class must
95 // be called on the main thread. 95 // be called on the main thread.
96 class Peer FINAL : public WebSocketChannelClient { 96 class Peer FINAL : public WebSocketChannelClient {
97 WTF_MAKE_NONCOPYABLE(Peer); WTF_MAKE_FAST_ALLOCATED; 97 WTF_MAKE_NONCOPYABLE(Peer); WTF_MAKE_FAST_ALLOCATED;
98 public: 98 public:
99 virtual ~Peer(); 99 virtual ~Peer();
100 100
101 // sourceURLAtConnection and lineNumberAtConnection parameters may 101 // sourceURLAtConnection and lineNumberAtConnection parameters may
102 // be shown when the connection fails. 102 // be shown when the connection fails.
103 static void initialize(ExecutionContext*, PassRefPtr<WeakReference<Peer> >, WorkerLoaderProxy*, PassRefPtr<ThreadableWebSocketChannelClientWrapper>, con st String& sourceURLAtConnection, unsigned lineNumberAtConnection, PassOwnPtr<Th readableWebSocketChannelSyncHelper>); 103 static void initialize(ExecutionContext*, PassRefPtr<WeakReference<Peer> >, WorkerLoaderProxy*, PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientW rapper>, const String& sourceURLAtConnection, unsigned lineNumberAtConnection, P assOwnPtr<ThreadableWebSocketChannelSyncHelper>);
104 void destroy(); 104 void destroy();
105 105
106 void connect(const KURL&, const String& protocol); 106 void connect(const KURL&, const String& protocol);
107 void send(const String& message); 107 void send(const String& message);
108 void sendArrayBuffer(PassOwnPtr<Vector<char> >); 108 void sendArrayBuffer(PassOwnPtr<Vector<char> >);
109 void sendBlob(PassRefPtr<BlobDataHandle>); 109 void sendBlob(PassRefPtr<BlobDataHandle>);
110 void bufferedAmount(); 110 void bufferedAmount();
111 void close(int code, const String& reason); 111 void close(int code, const String& reason);
112 void fail(const String& reason, MessageLevel, const String& sourceURL, u nsigned lineNumber); 112 void fail(const String& reason, MessageLevel, const String& sourceURL, u nsigned lineNumber);
113 void disconnect(); 113 void disconnect();
114 void suspend(); 114 void suspend();
115 void resume(); 115 void resume();
116 116
117 // WebSocketChannelClient functions. 117 // WebSocketChannelClient functions.
118 virtual void didConnect() OVERRIDE; 118 virtual void didConnect() OVERRIDE;
119 virtual void didReceiveMessage(const String& message) OVERRIDE; 119 virtual void didReceiveMessage(const String& message) OVERRIDE;
120 virtual void didReceiveBinaryData(PassOwnPtr<Vector<char> >) OVERRIDE; 120 virtual void didReceiveBinaryData(PassOwnPtr<Vector<char> >) OVERRIDE;
121 virtual void didUpdateBufferedAmount(unsigned long bufferedAmount) OVERR IDE; 121 virtual void didUpdateBufferedAmount(unsigned long bufferedAmount) OVERR IDE;
122 virtual void didStartClosingHandshake() OVERRIDE; 122 virtual void didStartClosingHandshake() OVERRIDE;
123 virtual void didClose(unsigned long unhandledBufferedAmount, ClosingHand shakeCompletionStatus, unsigned short code, const String& reason) OVERRIDE; 123 virtual void didClose(unsigned long unhandledBufferedAmount, ClosingHand shakeCompletionStatus, unsigned short code, const String& reason) OVERRIDE;
124 virtual void didReceiveMessageError() OVERRIDE; 124 virtual void didReceiveMessageError() OVERRIDE;
125 125
126 private: 126 private:
127 Peer(PassRefPtr<WeakReference<Peer> >, PassRefPtr<ThreadableWebSocketCha nnelClientWrapper>, WorkerLoaderProxy&, ExecutionContext*, const String& sourceU RL, unsigned lineNumber, PassOwnPtr<ThreadableWebSocketChannelSyncHelper>); 127 Peer(PassRefPtr<WeakReference<Peer> >, PassRefPtrWillBeRawPtr<Threadable WebSocketChannelClientWrapper>, WorkerLoaderProxy&, ExecutionContext*, const Str ing& sourceURL, unsigned lineNumber, PassOwnPtr<ThreadableWebSocketChannelSyncHe lper>);
128 128
129 const RefPtr<ThreadableWebSocketChannelClientWrapper> m_workerClientWrap per; 129 const RefPtrWillBePersistent<ThreadableWebSocketChannelClientWrapper> m_ workerClientWrapper;
130 WorkerLoaderProxy& m_loaderProxy; 130 WorkerLoaderProxy& m_loaderProxy;
131 RefPtrWillBePersistent<WebSocketChannel> m_mainWebSocketChannel; 131 RefPtrWillBePersistent<WebSocketChannel> m_mainWebSocketChannel;
132 OwnPtr<ThreadableWebSocketChannelSyncHelper> m_syncHelper; 132 OwnPtr<ThreadableWebSocketChannelSyncHelper> m_syncHelper;
133 WeakPtrFactory<Peer> m_weakFactory; 133 WeakPtrFactory<Peer> m_weakFactory;
134 }; 134 };
135 135
136 private: 136 private:
137 // Bridge for Peer. Running on the worker thread. 137 // Bridge for Peer. Running on the worker thread.
138 class Bridge : public RefCounted<Bridge> { 138 class Bridge : public RefCounted<Bridge> {
139 public: 139 public:
140 static PassRefPtr<Bridge> create(PassRefPtr<ThreadableWebSocketChannelCl ientWrapper> workerClientWrapper, WorkerGlobalScope& workerGlobalScope) 140 static PassRefPtr<Bridge> create(PassRefPtrWillBeRawPtr<ThreadableWebSoc ketChannelClientWrapper> workerClientWrapper, WorkerGlobalScope& workerGlobalSco pe)
141 { 141 {
142 return adoptRef(new Bridge(workerClientWrapper, workerGlobalScope)); 142 return adoptRef(new Bridge(workerClientWrapper, workerGlobalScope));
143 } 143 }
144 ~Bridge(); 144 ~Bridge();
145 // sourceURLAtConnection and lineNumberAtConnection parameters may 145 // sourceURLAtConnection and lineNumberAtConnection parameters may
146 // be shown when the connection fails. 146 // be shown when the connection fails.
147 void initialize(const String& sourceURLAtConnection, unsigned lineNumber AtConnection); 147 void initialize(const String& sourceURLAtConnection, unsigned lineNumber AtConnection);
148 bool connect(const KURL&, const String& protocol); 148 bool connect(const KURL&, const String& protocol);
149 WebSocketChannel::SendResult send(const String& message); 149 WebSocketChannel::SendResult send(const String& message);
150 WebSocketChannel::SendResult send(const ArrayBuffer&, unsigned byteOffse t, unsigned byteLength); 150 WebSocketChannel::SendResult send(const ArrayBuffer&, unsigned byteOffse t, unsigned byteLength);
151 WebSocketChannel::SendResult send(PassRefPtr<BlobDataHandle>); 151 WebSocketChannel::SendResult send(PassRefPtr<BlobDataHandle>);
152 unsigned long bufferedAmount(); 152 unsigned long bufferedAmount();
153 void close(int code, const String& reason); 153 void close(int code, const String& reason);
154 void fail(const String& reason, MessageLevel, const String& sourceURL, u nsigned lineNumber); 154 void fail(const String& reason, MessageLevel, const String& sourceURL, u nsigned lineNumber);
155 void disconnect(); 155 void disconnect();
156 void suspend(); 156 void suspend();
157 void resume(); 157 void resume();
158 158
159 private: 159 private:
160 Bridge(PassRefPtr<ThreadableWebSocketChannelClientWrapper>, WorkerGlobal Scope&); 160 Bridge(PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper>, WorkerGlobalScope&);
161 161
162 static void setWebSocketChannel(ExecutionContext*, Bridge* thisPtr, Peer *, PassRefPtr<ThreadableWebSocketChannelClientWrapper>); 162 static void setWebSocketChannel(ExecutionContext*, Bridge* thisPtr, Peer *, PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper>);
163 163
164 // Executed on the worker context's thread. 164 // Executed on the worker context's thread.
165 void clearClientWrapper(); 165 void clearClientWrapper();
166 166
167 // Returns false if shutdown event is received before method completion. 167 // Returns false if shutdown event is received before method completion.
168 bool waitForMethodCompletion(PassOwnPtr<ExecutionContextTask>); 168 bool waitForMethodCompletion(PassOwnPtr<ExecutionContextTask>);
169 169
170 void terminatePeer(); 170 void terminatePeer();
171 171
172 bool hasTerminatedPeer() { return !m_syncHelper; } 172 bool hasTerminatedPeer() { return !m_syncHelper; }
173 173
174 const RefPtr<ThreadableWebSocketChannelClientWrapper> m_workerClientWrap per; 174 const RefPtrWillBePersistent<ThreadableWebSocketChannelClientWrapper> m_ workerClientWrapper;
175 RefPtrWillBePersistent<WorkerGlobalScope> m_workerGlobalScope; 175 RefPtrWillBePersistent<WorkerGlobalScope> m_workerGlobalScope;
176 WorkerLoaderProxy& m_loaderProxy; 176 WorkerLoaderProxy& m_loaderProxy;
177 ThreadableWebSocketChannelSyncHelper* m_syncHelper; 177 ThreadableWebSocketChannelSyncHelper* m_syncHelper;
178 WeakPtr<Peer> m_peer; 178 WeakPtr<Peer> m_peer;
179 }; 179 };
180 180
181 WorkerThreadableWebSocketChannel(WorkerGlobalScope&, WebSocketChannelClient* , const String& sourceURL, unsigned lineNumber); 181 WorkerThreadableWebSocketChannel(WorkerGlobalScope&, WebSocketChannelClient* , const String& sourceURL, unsigned lineNumber);
182 182
183 const RefPtr<ThreadableWebSocketChannelClientWrapper> m_workerClientWrapper; 183 const RefPtrWillBePersistent<ThreadableWebSocketChannelClientWrapper> m_work erClientWrapper;
184 RefPtr<Bridge> m_bridge; 184 RefPtr<Bridge> m_bridge;
185 String m_sourceURLAtConnection; 185 String m_sourceURLAtConnection;
186 unsigned m_lineNumberAtConnection; 186 unsigned m_lineNumberAtConnection;
187 }; 187 };
188 188
189 } // namespace WebCore 189 } // namespace WebCore
190 190
191 #endif // WorkerThreadableWebSocketChannel_h 191 #endif // WorkerThreadableWebSocketChannel_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698