| OLD | NEW |
| 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 bridge_.Clear(); | 155 bridge_.Clear(); |
| 156 } | 156 } |
| 157 | 157 |
| 158 DEFINE_TRACE(WorkerWebSocketChannel) { | 158 DEFINE_TRACE(WorkerWebSocketChannel) { |
| 159 visitor->Trace(bridge_); | 159 visitor->Trace(bridge_); |
| 160 WebSocketChannel::Trace(visitor); | 160 WebSocketChannel::Trace(visitor); |
| 161 } | 161 } |
| 162 | 162 |
| 163 Peer::Peer(Bridge* bridge, | 163 Peer::Peer(Bridge* bridge, |
| 164 PassRefPtr<WorkerLoaderProxy> loader_proxy, | 164 PassRefPtr<WorkerLoaderProxy> loader_proxy, |
| 165 RefPtr<WebTaskRunner> worker_networking_task_runner, |
| 165 WorkerThreadLifecycleContext* worker_thread_lifecycle_context) | 166 WorkerThreadLifecycleContext* worker_thread_lifecycle_context) |
| 166 : WorkerThreadLifecycleObserver(worker_thread_lifecycle_context), | 167 : WorkerThreadLifecycleObserver(worker_thread_lifecycle_context), |
| 167 bridge_(bridge), | 168 bridge_(bridge), |
| 168 loader_proxy_(std::move(loader_proxy)), | 169 loader_proxy_(std::move(loader_proxy)), |
| 170 worker_networking_task_runner_(std::move(worker_networking_task_runner)), |
| 169 main_web_socket_channel_(nullptr) { | 171 main_web_socket_channel_(nullptr) { |
| 170 DCHECK(IsMainThread()); | 172 DCHECK(IsMainThread()); |
| 171 } | 173 } |
| 172 | 174 |
| 173 Peer::~Peer() { | 175 Peer::~Peer() { |
| 174 DCHECK(IsMainThread()); | 176 DCHECK(IsMainThread()); |
| 175 } | 177 } |
| 176 | 178 |
| 177 bool Peer::Initialize(std::unique_ptr<SourceLocation> location, | 179 bool Peer::Initialize(std::unique_ptr<SourceLocation> location, |
| 178 ThreadableLoadingContext* loading_context) { | 180 ThreadableLoadingContext* loading_context) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 | 237 |
| 236 static void WorkerGlobalScopeDidConnect(Bridge* bridge, | 238 static void WorkerGlobalScopeDidConnect(Bridge* bridge, |
| 237 const String& subprotocol, | 239 const String& subprotocol, |
| 238 const String& extensions) { | 240 const String& extensions) { |
| 239 if (bridge && bridge->Client()) | 241 if (bridge && bridge->Client()) |
| 240 bridge->Client()->DidConnect(subprotocol, extensions); | 242 bridge->Client()->DidConnect(subprotocol, extensions); |
| 241 } | 243 } |
| 242 | 244 |
| 243 void Peer::DidConnect(const String& subprotocol, const String& extensions) { | 245 void Peer::DidConnect(const String& subprotocol, const String& extensions) { |
| 244 DCHECK(IsMainThread()); | 246 DCHECK(IsMainThread()); |
| 245 loader_proxy_->PostTaskToWorkerGlobalScope( | 247 worker_networking_task_runner_->PostTask( |
| 246 BLINK_FROM_HERE, CrossThreadBind(&WorkerGlobalScopeDidConnect, bridge_, | 248 BLINK_FROM_HERE, CrossThreadBind(&WorkerGlobalScopeDidConnect, bridge_, |
| 247 subprotocol, extensions)); | 249 subprotocol, extensions)); |
| 248 } | 250 } |
| 249 | 251 |
| 250 static void WorkerGlobalScopeDidReceiveTextMessage(Bridge* bridge, | 252 static void WorkerGlobalScopeDidReceiveTextMessage(Bridge* bridge, |
| 251 const String& payload) { | 253 const String& payload) { |
| 252 if (bridge && bridge->Client()) | 254 if (bridge && bridge->Client()) |
| 253 bridge->Client()->DidReceiveTextMessage(payload); | 255 bridge->Client()->DidReceiveTextMessage(payload); |
| 254 } | 256 } |
| 255 | 257 |
| 256 void Peer::DidReceiveTextMessage(const String& payload) { | 258 void Peer::DidReceiveTextMessage(const String& payload) { |
| 257 DCHECK(IsMainThread()); | 259 DCHECK(IsMainThread()); |
| 258 loader_proxy_->PostTaskToWorkerGlobalScope( | 260 worker_networking_task_runner_->PostTask( |
| 259 BLINK_FROM_HERE, CrossThreadBind(&WorkerGlobalScopeDidReceiveTextMessage, | 261 BLINK_FROM_HERE, CrossThreadBind(&WorkerGlobalScopeDidReceiveTextMessage, |
| 260 bridge_, payload)); | 262 bridge_, payload)); |
| 261 } | 263 } |
| 262 | 264 |
| 263 static void WorkerGlobalScopeDidReceiveBinaryMessage( | 265 static void WorkerGlobalScopeDidReceiveBinaryMessage( |
| 264 Bridge* bridge, | 266 Bridge* bridge, |
| 265 std::unique_ptr<Vector<char>> payload) { | 267 std::unique_ptr<Vector<char>> payload) { |
| 266 if (bridge && bridge->Client()) | 268 if (bridge && bridge->Client()) |
| 267 bridge->Client()->DidReceiveBinaryMessage(std::move(payload)); | 269 bridge->Client()->DidReceiveBinaryMessage(std::move(payload)); |
| 268 } | 270 } |
| 269 | 271 |
| 270 void Peer::DidReceiveBinaryMessage(std::unique_ptr<Vector<char>> payload) { | 272 void Peer::DidReceiveBinaryMessage(std::unique_ptr<Vector<char>> payload) { |
| 271 DCHECK(IsMainThread()); | 273 DCHECK(IsMainThread()); |
| 272 loader_proxy_->PostTaskToWorkerGlobalScope( | 274 worker_networking_task_runner_->PostTask( |
| 273 BLINK_FROM_HERE, | 275 BLINK_FROM_HERE, |
| 274 CrossThreadBind(&WorkerGlobalScopeDidReceiveBinaryMessage, bridge_, | 276 CrossThreadBind(&WorkerGlobalScopeDidReceiveBinaryMessage, bridge_, |
| 275 WTF::Passed(std::move(payload)))); | 277 WTF::Passed(std::move(payload)))); |
| 276 } | 278 } |
| 277 | 279 |
| 278 static void WorkerGlobalScopeDidConsumeBufferedAmount(Bridge* bridge, | 280 static void WorkerGlobalScopeDidConsumeBufferedAmount(Bridge* bridge, |
| 279 uint64_t consumed) { | 281 uint64_t consumed) { |
| 280 if (bridge && bridge->Client()) | 282 if (bridge && bridge->Client()) |
| 281 bridge->Client()->DidConsumeBufferedAmount(consumed); | 283 bridge->Client()->DidConsumeBufferedAmount(consumed); |
| 282 } | 284 } |
| 283 | 285 |
| 284 void Peer::DidConsumeBufferedAmount(uint64_t consumed) { | 286 void Peer::DidConsumeBufferedAmount(uint64_t consumed) { |
| 285 DCHECK(IsMainThread()); | 287 DCHECK(IsMainThread()); |
| 286 loader_proxy_->PostTaskToWorkerGlobalScope( | 288 worker_networking_task_runner_->PostTask( |
| 287 BLINK_FROM_HERE, | 289 BLINK_FROM_HERE, |
| 288 CrossThreadBind(&WorkerGlobalScopeDidConsumeBufferedAmount, bridge_, | 290 CrossThreadBind(&WorkerGlobalScopeDidConsumeBufferedAmount, bridge_, |
| 289 consumed)); | 291 consumed)); |
| 290 } | 292 } |
| 291 | 293 |
| 292 static void WorkerGlobalScopeDidStartClosingHandshake(Bridge* bridge) { | 294 static void WorkerGlobalScopeDidStartClosingHandshake(Bridge* bridge) { |
| 293 if (bridge && bridge->Client()) | 295 if (bridge && bridge->Client()) |
| 294 bridge->Client()->DidStartClosingHandshake(); | 296 bridge->Client()->DidStartClosingHandshake(); |
| 295 } | 297 } |
| 296 | 298 |
| 297 void Peer::DidStartClosingHandshake() { | 299 void Peer::DidStartClosingHandshake() { |
| 298 DCHECK(IsMainThread()); | 300 DCHECK(IsMainThread()); |
| 299 loader_proxy_->PostTaskToWorkerGlobalScope( | 301 worker_networking_task_runner_->PostTask( |
| 300 BLINK_FROM_HERE, | 302 BLINK_FROM_HERE, |
| 301 CrossThreadBind(&WorkerGlobalScopeDidStartClosingHandshake, bridge_)); | 303 CrossThreadBind(&WorkerGlobalScopeDidStartClosingHandshake, bridge_)); |
| 302 } | 304 } |
| 303 | 305 |
| 304 static void WorkerGlobalScopeDidClose( | 306 static void WorkerGlobalScopeDidClose( |
| 305 Bridge* bridge, | 307 Bridge* bridge, |
| 306 WebSocketChannelClient::ClosingHandshakeCompletionStatus | 308 WebSocketChannelClient::ClosingHandshakeCompletionStatus |
| 307 closing_handshake_completion, | 309 closing_handshake_completion, |
| 308 unsigned short code, | 310 unsigned short code, |
| 309 const String& reason) { | 311 const String& reason) { |
| 310 if (bridge && bridge->Client()) | 312 if (bridge && bridge->Client()) |
| 311 bridge->Client()->DidClose(closing_handshake_completion, code, reason); | 313 bridge->Client()->DidClose(closing_handshake_completion, code, reason); |
| 312 } | 314 } |
| 313 | 315 |
| 314 void Peer::DidClose( | 316 void Peer::DidClose( |
| 315 ClosingHandshakeCompletionStatus closing_handshake_completion, | 317 ClosingHandshakeCompletionStatus closing_handshake_completion, |
| 316 unsigned short code, | 318 unsigned short code, |
| 317 const String& reason) { | 319 const String& reason) { |
| 318 DCHECK(IsMainThread()); | 320 DCHECK(IsMainThread()); |
| 319 if (main_web_socket_channel_) { | 321 if (main_web_socket_channel_) { |
| 320 main_web_socket_channel_->Disconnect(); | 322 main_web_socket_channel_->Disconnect(); |
| 321 main_web_socket_channel_ = nullptr; | 323 main_web_socket_channel_ = nullptr; |
| 322 } | 324 } |
| 323 loader_proxy_->PostTaskToWorkerGlobalScope( | 325 worker_networking_task_runner_->PostTask( |
| 324 BLINK_FROM_HERE, | 326 BLINK_FROM_HERE, |
| 325 CrossThreadBind(&WorkerGlobalScopeDidClose, bridge_, | 327 CrossThreadBind(&WorkerGlobalScopeDidClose, bridge_, |
| 326 closing_handshake_completion, code, reason)); | 328 closing_handshake_completion, code, reason)); |
| 327 } | 329 } |
| 328 | 330 |
| 329 static void WorkerGlobalScopeDidError(Bridge* bridge) { | 331 static void WorkerGlobalScopeDidError(Bridge* bridge) { |
| 330 if (bridge && bridge->Client()) | 332 if (bridge && bridge->Client()) |
| 331 bridge->Client()->DidError(); | 333 bridge->Client()->DidError(); |
| 332 } | 334 } |
| 333 | 335 |
| 334 void Peer::DidError() { | 336 void Peer::DidError() { |
| 335 DCHECK(IsMainThread()); | 337 DCHECK(IsMainThread()); |
| 336 loader_proxy_->PostTaskToWorkerGlobalScope( | 338 worker_networking_task_runner_->PostTask( |
| 337 BLINK_FROM_HERE, CrossThreadBind(&WorkerGlobalScopeDidError, bridge_)); | 339 BLINK_FROM_HERE, CrossThreadBind(&WorkerGlobalScopeDidError, bridge_)); |
| 338 } | 340 } |
| 339 | 341 |
| 340 void Peer::ContextDestroyed(WorkerThreadLifecycleContext*) { | 342 void Peer::ContextDestroyed(WorkerThreadLifecycleContext*) { |
| 341 DCHECK(IsMainThread()); | 343 DCHECK(IsMainThread()); |
| 342 if (main_web_socket_channel_) { | 344 if (main_web_socket_channel_) { |
| 343 main_web_socket_channel_->Disconnect(); | 345 main_web_socket_channel_->Disconnect(); |
| 344 main_web_socket_channel_ = nullptr; | 346 main_web_socket_channel_ = nullptr; |
| 345 } | 347 } |
| 346 bridge_ = nullptr; | 348 bridge_ = nullptr; |
| 347 } | 349 } |
| 348 | 350 |
| 349 DEFINE_TRACE(Peer) { | 351 DEFINE_TRACE(Peer) { |
| 350 visitor->Trace(main_web_socket_channel_); | 352 visitor->Trace(main_web_socket_channel_); |
| 351 WebSocketChannelClient::Trace(visitor); | 353 WebSocketChannelClient::Trace(visitor); |
| 352 WorkerThreadLifecycleObserver::Trace(visitor); | 354 WorkerThreadLifecycleObserver::Trace(visitor); |
| 353 } | 355 } |
| 354 | 356 |
| 355 Bridge::Bridge(WebSocketChannelClient* client, | 357 Bridge::Bridge(WebSocketChannelClient* client, |
| 356 WorkerGlobalScope& worker_global_scope) | 358 WorkerGlobalScope& worker_global_scope) |
| 357 : client_(client), | 359 : client_(client), |
| 358 worker_global_scope_(worker_global_scope), | 360 worker_global_scope_(worker_global_scope), |
| 359 loader_proxy_(worker_global_scope_->GetThread()->GetWorkerLoaderProxy()) { | 361 loader_proxy_(worker_global_scope_->GetThread()->GetWorkerLoaderProxy()), |
| 360 } | 362 parent_frame_task_runners_( |
| 363 worker_global_scope_->GetThread()->GetParentFrameTaskRunners()) {} |
| 361 | 364 |
| 362 Bridge::~Bridge() { | 365 Bridge::~Bridge() { |
| 363 DCHECK(!peer_); | 366 DCHECK(!peer_); |
| 364 } | 367 } |
| 365 | 368 |
| 366 void Bridge::ConnectOnMainThread( | 369 void Bridge::ConnectOnMainThread( |
| 367 std::unique_ptr<SourceLocation> location, | 370 std::unique_ptr<SourceLocation> location, |
| 368 RefPtr<WorkerLoaderProxy> loader_proxy, | 371 RefPtr<WorkerLoaderProxy> loader_proxy, |
| 372 RefPtr<WebTaskRunner> worker_networking_task_runner, |
| 369 WorkerThreadLifecycleContext* worker_thread_lifecycle_context, | 373 WorkerThreadLifecycleContext* worker_thread_lifecycle_context, |
| 370 const KURL& url, | 374 const KURL& url, |
| 371 const String& protocol, | 375 const String& protocol, |
| 372 WebSocketChannelSyncHelper* sync_helper) { | 376 WebSocketChannelSyncHelper* sync_helper) { |
| 373 DCHECK(IsMainThread()); | 377 DCHECK(IsMainThread()); |
| 374 DCHECK(!peer_); | 378 DCHECK(!peer_); |
| 375 ThreadableLoadingContext* loading_context = | 379 ThreadableLoadingContext* loading_context = |
| 376 loader_proxy->GetThreadableLoadingContext(); | 380 loader_proxy->GetThreadableLoadingContext(); |
| 377 if (!loading_context) | 381 if (!loading_context) |
| 378 return; | 382 return; |
| 379 Peer* peer = new Peer(this, loader_proxy_, worker_thread_lifecycle_context); | 383 Peer* peer = |
| 384 new Peer(this, loader_proxy_, std::move(worker_networking_task_runner), |
| 385 worker_thread_lifecycle_context); |
| 380 if (peer->Initialize(std::move(location), loading_context)) { | 386 if (peer->Initialize(std::move(location), loading_context)) { |
| 381 peer_ = peer; | 387 peer_ = peer; |
| 382 sync_helper->SetConnectRequestResult(peer_->Connect(url, protocol)); | 388 sync_helper->SetConnectRequestResult(peer_->Connect(url, protocol)); |
| 383 } | 389 } |
| 384 sync_helper->SignalWorkerThread(); | 390 sync_helper->SignalWorkerThread(); |
| 385 } | 391 } |
| 386 | 392 |
| 387 bool Bridge::Connect(std::unique_ptr<SourceLocation> location, | 393 bool Bridge::Connect(std::unique_ptr<SourceLocation> location, |
| 388 const KURL& url, | 394 const KURL& url, |
| 389 const String& protocol) { | 395 const String& protocol) { |
| 390 // Wait for completion of the task on the main thread because the mixed | 396 // Wait for completion of the task on the main thread because the mixed |
| 391 // content check must synchronously be conducted. | 397 // content check must synchronously be conducted. |
| 392 WebSocketChannelSyncHelper sync_helper; | 398 WebSocketChannelSyncHelper sync_helper; |
| 393 loader_proxy_->PostTaskToLoader( | 399 RefPtr<WebTaskRunner> worker_networking_task_runner = |
| 394 BLINK_FROM_HERE, | 400 TaskRunnerHelper::Get(TaskType::kNetworking, worker_global_scope_.Get()); |
| 395 CrossThreadBind( | 401 parent_frame_task_runners_->Get(TaskType::kNetworking) |
| 396 &Bridge::ConnectOnMainThread, WrapCrossThreadPersistent(this), | 402 ->PostTask( |
| 397 WTF::Passed(location->Clone()), loader_proxy_, | 403 BLINK_FROM_HERE, |
| 398 WrapCrossThreadPersistent(worker_global_scope_->GetThread() | 404 CrossThreadBind(&Bridge::ConnectOnMainThread, |
| 399 ->GetWorkerThreadLifecycleContext()), | 405 WrapCrossThreadPersistent(this), |
| 400 url, protocol, CrossThreadUnretained(&sync_helper))); | 406 WTF::Passed(location->Clone()), loader_proxy_, |
| 407 std::move(worker_networking_task_runner), |
| 408 WrapCrossThreadPersistent( |
| 409 worker_global_scope_->GetThread() |
| 410 ->GetWorkerThreadLifecycleContext()), |
| 411 url, protocol, CrossThreadUnretained(&sync_helper))); |
| 401 sync_helper.Wait(); | 412 sync_helper.Wait(); |
| 402 return sync_helper.ConnectRequestResult(); | 413 return sync_helper.ConnectRequestResult(); |
| 403 } | 414 } |
| 404 | 415 |
| 405 void Bridge::Send(const CString& message) { | 416 void Bridge::Send(const CString& message) { |
| 406 DCHECK(peer_); | 417 DCHECK(peer_); |
| 407 std::unique_ptr<Vector<char>> data = | 418 std::unique_ptr<Vector<char>> data = |
| 408 WTF::WrapUnique(new Vector<char>(message.length())); | 419 WTF::WrapUnique(new Vector<char>(message.length())); |
| 409 if (message.length()) | 420 if (message.length()) |
| 410 memcpy(data->data(), static_cast<const char*>(message.data()), | 421 memcpy(data->data(), static_cast<const char*>(message.data()), |
| 411 message.length()); | 422 message.length()); |
| 412 | 423 |
| 413 loader_proxy_->PostTaskToLoader( | 424 parent_frame_task_runners_->Get(TaskType::kNetworking) |
| 414 BLINK_FROM_HERE, CrossThreadBind(&Peer::SendTextAsCharVector, peer_, | 425 ->PostTask(BLINK_FROM_HERE, |
| 415 WTF::Passed(std::move(data)))); | 426 CrossThreadBind(&Peer::SendTextAsCharVector, peer_, |
| 427 WTF::Passed(std::move(data)))); |
| 416 } | 428 } |
| 417 | 429 |
| 418 void Bridge::Send(const DOMArrayBuffer& binary_data, | 430 void Bridge::Send(const DOMArrayBuffer& binary_data, |
| 419 unsigned byte_offset, | 431 unsigned byte_offset, |
| 420 unsigned byte_length) { | 432 unsigned byte_length) { |
| 421 DCHECK(peer_); | 433 DCHECK(peer_); |
| 422 // ArrayBuffer isn't thread-safe, hence the content of ArrayBuffer is copied | 434 // ArrayBuffer isn't thread-safe, hence the content of ArrayBuffer is copied |
| 423 // into Vector<char>. | 435 // into Vector<char>. |
| 424 std::unique_ptr<Vector<char>> data = | 436 std::unique_ptr<Vector<char>> data = |
| 425 WTF::MakeUnique<Vector<char>>(byte_length); | 437 WTF::MakeUnique<Vector<char>>(byte_length); |
| 426 if (binary_data.ByteLength()) | 438 if (binary_data.ByteLength()) |
| 427 memcpy(data->data(), | 439 memcpy(data->data(), |
| 428 static_cast<const char*>(binary_data.Data()) + byte_offset, | 440 static_cast<const char*>(binary_data.Data()) + byte_offset, |
| 429 byte_length); | 441 byte_length); |
| 430 | 442 |
| 431 loader_proxy_->PostTaskToLoader( | 443 parent_frame_task_runners_->Get(TaskType::kNetworking) |
| 432 BLINK_FROM_HERE, CrossThreadBind(&Peer::SendBinaryAsCharVector, peer_, | 444 ->PostTask(BLINK_FROM_HERE, |
| 433 WTF::Passed(std::move(data)))); | 445 CrossThreadBind(&Peer::SendBinaryAsCharVector, peer_, |
| 446 WTF::Passed(std::move(data)))); |
| 434 } | 447 } |
| 435 | 448 |
| 436 void Bridge::Send(PassRefPtr<BlobDataHandle> data) { | 449 void Bridge::Send(PassRefPtr<BlobDataHandle> data) { |
| 437 DCHECK(peer_); | 450 DCHECK(peer_); |
| 438 loader_proxy_->PostTaskToLoader( | 451 parent_frame_task_runners_->Get(TaskType::kNetworking) |
| 439 BLINK_FROM_HERE, | 452 ->PostTask(BLINK_FROM_HERE, |
| 440 CrossThreadBind(&Peer::SendBlob, peer_, std::move(data))); | 453 CrossThreadBind(&Peer::SendBlob, peer_, std::move(data))); |
| 441 } | 454 } |
| 442 | 455 |
| 443 void Bridge::Close(int code, const String& reason) { | 456 void Bridge::Close(int code, const String& reason) { |
| 444 DCHECK(peer_); | 457 DCHECK(peer_); |
| 445 loader_proxy_->PostTaskToLoader( | 458 parent_frame_task_runners_->Get(TaskType::kNetworking) |
| 446 BLINK_FROM_HERE, CrossThreadBind(&Peer::Close, peer_, code, reason)); | 459 ->PostTask(BLINK_FROM_HERE, |
| 460 CrossThreadBind(&Peer::Close, peer_, code, reason)); |
| 447 } | 461 } |
| 448 | 462 |
| 449 void Bridge::Fail(const String& reason, | 463 void Bridge::Fail(const String& reason, |
| 450 MessageLevel level, | 464 MessageLevel level, |
| 451 std::unique_ptr<SourceLocation> location) { | 465 std::unique_ptr<SourceLocation> location) { |
| 452 DCHECK(peer_); | 466 DCHECK(peer_); |
| 453 loader_proxy_->PostTaskToLoader( | 467 parent_frame_task_runners_->Get(TaskType::kNetworking) |
| 454 BLINK_FROM_HERE, CrossThreadBind(&Peer::Fail, peer_, reason, level, | 468 ->PostTask(BLINK_FROM_HERE, |
| 455 WTF::Passed(location->Clone()))); | 469 CrossThreadBind(&Peer::Fail, peer_, reason, level, |
| 470 WTF::Passed(location->Clone()))); |
| 456 } | 471 } |
| 457 | 472 |
| 458 void Bridge::Disconnect() { | 473 void Bridge::Disconnect() { |
| 459 if (!peer_) | 474 if (!peer_) |
| 460 return; | 475 return; |
| 461 | 476 |
| 462 loader_proxy_->PostTaskToLoader(BLINK_FROM_HERE, | 477 parent_frame_task_runners_->Get(TaskType::kNetworking) |
| 463 CrossThreadBind(&Peer::Disconnect, peer_)); | 478 ->PostTask(BLINK_FROM_HERE, CrossThreadBind(&Peer::Disconnect, peer_)); |
| 464 | 479 |
| 465 client_ = nullptr; | 480 client_ = nullptr; |
| 466 peer_ = nullptr; | 481 peer_ = nullptr; |
| 467 worker_global_scope_.Clear(); | 482 worker_global_scope_.Clear(); |
| 468 } | 483 } |
| 469 | 484 |
| 470 DEFINE_TRACE(Bridge) { | 485 DEFINE_TRACE(Bridge) { |
| 471 visitor->Trace(client_); | 486 visitor->Trace(client_); |
| 472 visitor->Trace(worker_global_scope_); | 487 visitor->Trace(worker_global_scope_); |
| 473 } | 488 } |
| 474 | 489 |
| 475 } // namespace blink | 490 } // namespace blink |
| OLD | NEW |