OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "modules/presentation/PresentationConnection.h" | 5 #include "modules/presentation/PresentationConnection.h" |
6 | 6 |
7 #include "bindings/core/v8/ScriptPromiseResolver.h" | 7 #include "bindings/core/v8/ScriptPromiseResolver.h" |
8 #include "core/dom/DOMArrayBuffer.h" | 8 #include "core/dom/DOMArrayBuffer.h" |
9 #include "core/dom/DOMArrayBufferView.h" | 9 #include "core/dom/DOMArrayBufferView.h" |
10 #include "core/dom/Document.h" | 10 #include "core/dom/Document.h" |
11 #include "core/dom/ExceptionCode.h" | 11 #include "core/dom/ExceptionCode.h" |
12 #include "core/dom/ExecutionContextTask.h" | |
13 #include "core/dom/TaskRunnerHelper.h" | 12 #include "core/dom/TaskRunnerHelper.h" |
14 #include "core/events/Event.h" | 13 #include "core/events/Event.h" |
15 #include "core/events/MessageEvent.h" | 14 #include "core/events/MessageEvent.h" |
16 #include "core/fileapi/FileReaderLoader.h" | 15 #include "core/fileapi/FileReaderLoader.h" |
17 #include "core/fileapi/FileReaderLoaderClient.h" | 16 #include "core/fileapi/FileReaderLoaderClient.h" |
18 #include "core/frame/Deprecation.h" | 17 #include "core/frame/Deprecation.h" |
19 #include "core/frame/LocalFrame.h" | 18 #include "core/frame/LocalFrame.h" |
20 #include "core/frame/UseCounter.h" | 19 #include "core/frame/UseCounter.h" |
21 #include "modules/EventTargetModules.h" | 20 #include "modules/EventTargetModules.h" |
22 #include "modules/presentation/Presentation.h" | 21 #include "modules/presentation/Presentation.h" |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 ASSERT(controller); | 196 ASSERT(controller); |
198 ASSERT(request); | 197 ASSERT(request); |
199 | 198 |
200 PresentationConnection* connection = new PresentationConnection( | 199 PresentationConnection* connection = new PresentationConnection( |
201 controller->frame(), sessionInfo.id, sessionInfo.url); | 200 controller->frame(), sessionInfo.id, sessionInfo.url); |
202 controller->registerConnection(connection); | 201 controller->registerConnection(connection); |
203 | 202 |
204 // Fire onconnectionavailable event asynchronously. | 203 // Fire onconnectionavailable event asynchronously. |
205 auto* event = PresentationConnectionAvailableEvent::create( | 204 auto* event = PresentationConnectionAvailableEvent::create( |
206 EventTypeNames::connectionavailable, connection); | 205 EventTypeNames::connectionavailable, connection); |
207 request->getExecutionContext()->postTask( | 206 TaskRunnerHelper::get(TaskType::Presentation, request->getExecutionContext()) |
208 TaskType::Presentation, BLINK_FROM_HERE, | 207 ->postTask(BLINK_FROM_HERE, |
209 createSameThreadTask(&PresentationConnection::dispatchEventAsync, | 208 WTF::bind(&PresentationConnection::dispatchEventAsync, |
210 wrapPersistent(request), wrapPersistent(event))); | 209 wrapPersistent(request), wrapPersistent(event))); |
211 | 210 |
212 return connection; | 211 return connection; |
213 } | 212 } |
214 | 213 |
215 // static | 214 // static |
216 PresentationConnection* PresentationConnection::take( | 215 PresentationConnection* PresentationConnection::take( |
217 PresentationReceiver* receiver, | 216 PresentationReceiver* receiver, |
218 const WebPresentationSessionInfo& sessionInfo) { | 217 const WebPresentationSessionInfo& sessionInfo) { |
219 DCHECK(receiver); | 218 DCHECK(receiver); |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 FileError::ErrorCode errorCode) { | 480 FileError::ErrorCode errorCode) { |
482 ASSERT(!m_messages.isEmpty() && m_messages.first()->type == MessageTypeBlob); | 481 ASSERT(!m_messages.isEmpty() && m_messages.first()->type == MessageTypeBlob); |
483 // FIXME: generate error message? | 482 // FIXME: generate error message? |
484 // Ignore the current failed blob item and continue with next items. | 483 // Ignore the current failed blob item and continue with next items. |
485 m_messages.removeFirst(); | 484 m_messages.removeFirst(); |
486 m_blobLoader.clear(); | 485 m_blobLoader.clear(); |
487 handleMessageQueue(); | 486 handleMessageQueue(); |
488 } | 487 } |
489 | 488 |
490 void PresentationConnection::dispatchStateChangeEvent(Event* event) { | 489 void PresentationConnection::dispatchStateChangeEvent(Event* event) { |
491 getExecutionContext()->postTask( | 490 TaskRunnerHelper::get(TaskType::Presentation, getExecutionContext()) |
492 TaskType::Presentation, BLINK_FROM_HERE, | 491 ->postTask(BLINK_FROM_HERE, |
493 createSameThreadTask(&PresentationConnection::dispatchEventAsync, | 492 WTF::bind(&PresentationConnection::dispatchEventAsync, |
494 wrapPersistent(this), wrapPersistent(event))); | 493 wrapPersistent(this), wrapPersistent(event))); |
495 } | 494 } |
496 | 495 |
497 // static | 496 // static |
498 void PresentationConnection::dispatchEventAsync(EventTarget* target, | 497 void PresentationConnection::dispatchEventAsync(EventTarget* target, |
499 Event* event) { | 498 Event* event) { |
500 DCHECK(target); | 499 DCHECK(target); |
501 DCHECK(event); | 500 DCHECK(event); |
502 target->dispatchEvent(event); | 501 target->dispatchEvent(event); |
503 } | 502 } |
504 | 503 |
505 void PresentationConnection::tearDown() { | 504 void PresentationConnection::tearDown() { |
506 // Cancel current Blob loading if any. | 505 // Cancel current Blob loading if any. |
507 if (m_blobLoader) { | 506 if (m_blobLoader) { |
508 m_blobLoader->cancel(); | 507 m_blobLoader->cancel(); |
509 m_blobLoader.clear(); | 508 m_blobLoader.clear(); |
510 } | 509 } |
511 m_messages.clear(); | 510 m_messages.clear(); |
512 } | 511 } |
513 | 512 |
514 } // namespace blink | 513 } // namespace blink |
OLD | NEW |