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

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

Powered by Google App Engine
This is Rietveld 408576698