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

Side by Side Diff: third_party/WebKit/Source/modules/websockets/WorkerWebSocketChannel.cpp

Issue 1986143002: Revert of Apply AllowCrossThreadAccess() in the callers of createCrossThreadTask() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@temp1549143002
Patch Set: Created 4 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
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 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 { 377 {
378 } 378 }
379 379
380 Bridge::~Bridge() 380 Bridge::~Bridge()
381 { 381 {
382 ASSERT(!m_peer); 382 ASSERT(!m_peer);
383 } 383 }
384 384
385 void Bridge::initialize(const String& sourceURL, unsigned lineNumber) 385 void Bridge::initialize(const String& sourceURL, unsigned lineNumber)
386 { 386 {
387 if (!waitForMethodCompletion(createCrossThreadTask(&Peer::initialize, AllowC rossThreadAccess(m_peer.get()), sourceURL, lineNumber))) { 387 if (!waitForMethodCompletion(createCrossThreadTask(&Peer::initialize, m_peer .get(), sourceURL, lineNumber))) {
388 // The worker thread has been signalled to shutdown before method comple tion. 388 // The worker thread has been signalled to shutdown before method comple tion.
389 disconnect(); 389 disconnect();
390 } 390 }
391 } 391 }
392 392
393 bool Bridge::connect(const KURL& url, const String& protocol) 393 bool Bridge::connect(const KURL& url, const String& protocol)
394 { 394 {
395 if (!m_peer) 395 if (!m_peer)
396 return false; 396 return false;
397 397
398 if (!waitForMethodCompletion(createCrossThreadTask(&Peer::connect, AllowCros sThreadAccess(m_peer.get()), url, protocol))) 398 if (!waitForMethodCompletion(createCrossThreadTask(&Peer::connect, m_peer.ge t(), url, protocol)))
399 return false; 399 return false;
400 400
401 return m_syncHelper->connectRequestResult(); 401 return m_syncHelper->connectRequestResult();
402 } 402 }
403 403
404 void Bridge::send(const CString& message) 404 void Bridge::send(const CString& message)
405 { 405 {
406 ASSERT(m_peer); 406 ASSERT(m_peer);
407 OwnPtr<Vector<char>> data = adoptPtr(new Vector<char>(message.length())); 407 OwnPtr<Vector<char>> data = adoptPtr(new Vector<char>(message.length()));
408 if (message.length()) 408 if (message.length())
409 memcpy(data->data(), static_cast<const char*>(message.data()), message.l ength()); 409 memcpy(data->data(), static_cast<const char*>(message.data()), message.l ength());
410 410
411 m_loaderProxy->postTaskToLoader(createCrossThreadTask(&Peer::sendTextAsCharV ector, AllowCrossThreadAccess(m_peer.get()), passed(data.release()))); 411 m_loaderProxy->postTaskToLoader(createCrossThreadTask(&Peer::sendTextAsCharV ector, m_peer.get(), passed(data.release())));
412 } 412 }
413 413
414 void Bridge::send(const DOMArrayBuffer& binaryData, unsigned byteOffset, unsigne d byteLength) 414 void Bridge::send(const DOMArrayBuffer& binaryData, unsigned byteOffset, unsigne d byteLength)
415 { 415 {
416 ASSERT(m_peer); 416 ASSERT(m_peer);
417 // ArrayBuffer isn't thread-safe, hence the content of ArrayBuffer is copied into Vector<char>. 417 // ArrayBuffer isn't thread-safe, hence the content of ArrayBuffer is copied into Vector<char>.
418 OwnPtr<Vector<char>> data = adoptPtr(new Vector<char>(byteLength)); 418 OwnPtr<Vector<char>> data = adoptPtr(new Vector<char>(byteLength));
419 if (binaryData.byteLength()) 419 if (binaryData.byteLength())
420 memcpy(data->data(), static_cast<const char*>(binaryData.data()) + byteO ffset, byteLength); 420 memcpy(data->data(), static_cast<const char*>(binaryData.data()) + byteO ffset, byteLength);
421 421
422 m_loaderProxy->postTaskToLoader(createCrossThreadTask(&Peer::sendBinaryAsCha rVector, AllowCrossThreadAccess(m_peer.get()), passed(data.release()))); 422 m_loaderProxy->postTaskToLoader(createCrossThreadTask(&Peer::sendBinaryAsCha rVector, m_peer.get(), passed(data.release())));
423 } 423 }
424 424
425 void Bridge::send(PassRefPtr<BlobDataHandle> data) 425 void Bridge::send(PassRefPtr<BlobDataHandle> data)
426 { 426 {
427 ASSERT(m_peer); 427 ASSERT(m_peer);
428 m_loaderProxy->postTaskToLoader(createCrossThreadTask(&Peer::sendBlob, Allow CrossThreadAccess(m_peer.get()), data)); 428 m_loaderProxy->postTaskToLoader(createCrossThreadTask(&Peer::sendBlob, m_pee r.get(), data));
429 } 429 }
430 430
431 void Bridge::close(int code, const String& reason) 431 void Bridge::close(int code, const String& reason)
432 { 432 {
433 ASSERT(m_peer); 433 ASSERT(m_peer);
434 m_loaderProxy->postTaskToLoader(createCrossThreadTask(&Peer::close, AllowCro ssThreadAccess(m_peer.get()), code, reason)); 434 m_loaderProxy->postTaskToLoader(createCrossThreadTask(&Peer::close, m_peer.g et(), code, reason));
435 } 435 }
436 436
437 void Bridge::fail(const String& reason, MessageLevel level, const String& source URL, unsigned lineNumber) 437 void Bridge::fail(const String& reason, MessageLevel level, const String& source URL, unsigned lineNumber)
438 { 438 {
439 ASSERT(m_peer); 439 ASSERT(m_peer);
440 m_loaderProxy->postTaskToLoader(createCrossThreadTask(&Peer::fail, AllowCros sThreadAccess(m_peer.get()), reason, level, sourceURL, lineNumber)); 440 m_loaderProxy->postTaskToLoader(createCrossThreadTask(&Peer::fail, m_peer.ge t(), reason, level, sourceURL, lineNumber));
441 } 441 }
442 442
443 void Bridge::disconnect() 443 void Bridge::disconnect()
444 { 444 {
445 if (!m_peer) 445 if (!m_peer)
446 return; 446 return;
447 447
448 waitForMethodCompletion(createCrossThreadTask(&Peer::disconnect, AllowCrossT hreadAccess(m_peer.get()))); 448 waitForMethodCompletion(createCrossThreadTask(&Peer::disconnect, m_peer.get( )));
449 // Here |m_peer| is detached from the main thread and we can delete it. 449 // Here |m_peer| is detached from the main thread and we can delete it.
450 450
451 m_client = nullptr; 451 m_client = nullptr;
452 m_peer = nullptr; 452 m_peer = nullptr;
453 m_syncHelper = nullptr; 453 m_syncHelper = nullptr;
454 // We won't use this any more. 454 // We won't use this any more.
455 m_workerGlobalScope.clear(); 455 m_workerGlobalScope.clear();
456 } 456 }
457 457
458 // Caller of this function should hold a reference to the bridge, because this f unction may call WebSocket::didClose() in the end, 458 // Caller of this function should hold a reference to the bridge, because this f unction may call WebSocket::didClose() in the end,
(...skipping 15 matching lines...) Expand all
474 474
475 DEFINE_TRACE(Bridge) 475 DEFINE_TRACE(Bridge)
476 { 476 {
477 visitor->trace(m_client); 477 visitor->trace(m_client);
478 visitor->trace(m_workerGlobalScope); 478 visitor->trace(m_workerGlobalScope);
479 visitor->trace(m_syncHelper); 479 visitor->trace(m_syncHelper);
480 visitor->trace(m_peer); 480 visitor->trace(m_peer);
481 } 481 }
482 482
483 } // namespace blink 483 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698