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

Side by Side Diff: trunk/Source/modules/websockets/WorkerThreadableWebSocketChannel.cpp

Issue 338343002: Revert 176303 "ThreadableWebSocketChannelClientWrapper don't nee..." (Closed) Base URL: svn://svn.chromium.org/blink/
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
« no previous file with comments | « trunk/Source/modules/websockets/WorkerThreadableWebSocketChannel.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 m_bridge->fail(reason, level, sourceURL, lineNumber); 180 m_bridge->fail(reason, level, sourceURL, lineNumber);
181 } 181 }
182 } 182 }
183 183
184 void WorkerThreadableWebSocketChannel::disconnect() 184 void WorkerThreadableWebSocketChannel::disconnect()
185 { 185 {
186 m_bridge->disconnect(); 186 m_bridge->disconnect();
187 m_bridge.clear(); 187 m_bridge.clear();
188 } 188 }
189 189
190 void WorkerThreadableWebSocketChannel::suspend()
191 {
192 m_workerClientWrapper->suspend();
193 if (m_bridge)
194 m_bridge->suspend();
195 }
196
197 void WorkerThreadableWebSocketChannel::resume()
198 {
199 m_workerClientWrapper->resume();
200 if (m_bridge)
201 m_bridge->resume();
202 }
203
190 void WorkerThreadableWebSocketChannel::trace(Visitor* visitor) 204 void WorkerThreadableWebSocketChannel::trace(Visitor* visitor)
191 { 205 {
192 visitor->trace(m_workerClientWrapper); 206 visitor->trace(m_workerClientWrapper);
193 WebSocketChannel::trace(visitor); 207 WebSocketChannel::trace(visitor);
194 } 208 }
195 209
196 WorkerThreadableWebSocketChannel::Peer::Peer(PassRefPtr<WeakReference<Peer> > re ference, PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper> clientW rapper, WorkerLoaderProxy& loaderProxy, ExecutionContext* context, const String& sourceURL, unsigned lineNumber, PassOwnPtr<ThreadableWebSocketChannelSyncHelper > syncHelper) 210 WorkerThreadableWebSocketChannel::Peer::Peer(PassRefPtr<WeakReference<Peer> > re ference, PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper> clientW rapper, WorkerLoaderProxy& loaderProxy, ExecutionContext* context, const String& sourceURL, unsigned lineNumber, PassOwnPtr<ThreadableWebSocketChannelSyncHelper > syncHelper)
197 : m_workerClientWrapper(clientWrapper) 211 : m_workerClientWrapper(clientWrapper)
198 , m_loaderProxy(loaderProxy) 212 , m_loaderProxy(loaderProxy)
199 , m_mainWebSocketChannel(nullptr) 213 , m_mainWebSocketChannel(nullptr)
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 312
299 void WorkerThreadableWebSocketChannel::Peer::disconnect() 313 void WorkerThreadableWebSocketChannel::Peer::disconnect()
300 { 314 {
301 ASSERT(isMainThread()); 315 ASSERT(isMainThread());
302 if (!m_mainWebSocketChannel) 316 if (!m_mainWebSocketChannel)
303 return; 317 return;
304 m_mainWebSocketChannel->disconnect(); 318 m_mainWebSocketChannel->disconnect();
305 m_mainWebSocketChannel = nullptr; 319 m_mainWebSocketChannel = nullptr;
306 } 320 }
307 321
322 void WorkerThreadableWebSocketChannel::Peer::suspend()
323 {
324 ASSERT(isMainThread());
325 if (!m_mainWebSocketChannel)
326 return;
327 m_mainWebSocketChannel->suspend();
328 }
329
330 void WorkerThreadableWebSocketChannel::Peer::resume()
331 {
332 ASSERT(isMainThread());
333 if (!m_mainWebSocketChannel)
334 return;
335 m_mainWebSocketChannel->resume();
336 }
337
308 static void workerGlobalScopeDidConnect(ExecutionContext* context, PassRefPtrWil lBeRawPtr<ThreadableWebSocketChannelClientWrapper> workerClientWrapper, const St ring& subprotocol, const String& extensions) 338 static void workerGlobalScopeDidConnect(ExecutionContext* context, PassRefPtrWil lBeRawPtr<ThreadableWebSocketChannelClientWrapper> workerClientWrapper, const St ring& subprotocol, const String& extensions)
309 { 339 {
310 ASSERT_UNUSED(context, context->isWorkerGlobalScope()); 340 ASSERT_UNUSED(context, context->isWorkerGlobalScope());
311 workerClientWrapper->didConnect(subprotocol, extensions); 341 workerClientWrapper->didConnect(subprotocol, extensions);
312 } 342 }
313 343
314 void WorkerThreadableWebSocketChannel::Peer::didConnect(const String& subprotoco l, const String& extensions) 344 void WorkerThreadableWebSocketChannel::Peer::didConnect(const String& subprotoco l, const String& extensions)
315 { 345 {
316 ASSERT(isMainThread()); 346 ASSERT(isMainThread());
317 m_loaderProxy.postTaskToWorkerGlobalScope(createCallbackTask(&workerGlobalSc opeDidConnect, m_workerClientWrapper.get(), subprotocol, extensions)); 347 m_loaderProxy.postTaskToWorkerGlobalScope(createCallbackTask(&workerGlobalSc opeDidConnect, m_workerClientWrapper.get(), subprotocol, extensions));
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 518
489 m_loaderProxy.postTaskToLoader(CallClosureTask::create(bind(&Peer::fail, m_p eer, reason.isolatedCopy(), level, sourceURL.isolatedCopy(), lineNumber))); 519 m_loaderProxy.postTaskToLoader(CallClosureTask::create(bind(&Peer::fail, m_p eer, reason.isolatedCopy(), level, sourceURL.isolatedCopy(), lineNumber)));
490 } 520 }
491 521
492 void WorkerThreadableWebSocketChannel::Bridge::disconnect() 522 void WorkerThreadableWebSocketChannel::Bridge::disconnect()
493 { 523 {
494 clearClientWrapper(); 524 clearClientWrapper();
495 terminatePeer(); 525 terminatePeer();
496 } 526 }
497 527
528 void WorkerThreadableWebSocketChannel::Bridge::suspend()
529 {
530 if (hasTerminatedPeer())
531 return;
532
533 m_loaderProxy.postTaskToLoader(CallClosureTask::create(bind(&Peer::suspend, m_peer)));
534 }
535
536 void WorkerThreadableWebSocketChannel::Bridge::resume()
537 {
538 if (hasTerminatedPeer())
539 return;
540
541 m_loaderProxy.postTaskToLoader(CallClosureTask::create(bind(&Peer::resume, m _peer)));
542 }
543
498 void WorkerThreadableWebSocketChannel::Bridge::clearClientWrapper() 544 void WorkerThreadableWebSocketChannel::Bridge::clearClientWrapper()
499 { 545 {
500 m_workerClientWrapper->clearClient(); 546 m_workerClientWrapper->clearClient();
501 } 547 }
502 548
503 // Caller of this function should hold a reference to the bridge, because this f unction may call WebSocket::didClose() in the end, 549 // Caller of this function should hold a reference to the bridge, because this f unction may call WebSocket::didClose() in the end,
504 // which causes the bridge to get disconnected from the WebSocket and deleted if there is no other reference. 550 // which causes the bridge to get disconnected from the WebSocket and deleted if there is no other reference.
505 bool WorkerThreadableWebSocketChannel::Bridge::waitForMethodCompletion(PassOwnPt r<ExecutionContextTask> task) 551 bool WorkerThreadableWebSocketChannel::Bridge::waitForMethodCompletion(PassOwnPt r<ExecutionContextTask> task)
506 { 552 {
507 ASSERT(m_workerGlobalScope); 553 ASSERT(m_workerGlobalScope);
(...skipping 16 matching lines...) Expand all
524 m_loaderProxy.postTaskToLoader(CallClosureTask::create(bind(&Peer::destroy, m_peer))); 570 m_loaderProxy.postTaskToLoader(CallClosureTask::create(bind(&Peer::destroy, m_peer)));
525 // Peer::destroy() deletes m_peer and then m_syncHelper will be released. 571 // Peer::destroy() deletes m_peer and then m_syncHelper will be released.
526 // We must not touch m_syncHelper any more. 572 // We must not touch m_syncHelper any more.
527 m_syncHelper = 0; 573 m_syncHelper = 0;
528 574
529 // We won't use this any more. 575 // We won't use this any more.
530 m_workerGlobalScope = nullptr; 576 m_workerGlobalScope = nullptr;
531 } 577 }
532 578
533 } // namespace WebCore 579 } // namespace WebCore
OLDNEW
« no previous file with comments | « trunk/Source/modules/websockets/WorkerThreadableWebSocketChannel.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698