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" |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 return; | 374 return; |
375 } | 375 } |
376 case BinaryTypeArrayBuffer: | 376 case BinaryTypeArrayBuffer: |
377 DOMArrayBuffer* buffer = DOMArrayBuffer::create(data, length); | 377 DOMArrayBuffer* buffer = DOMArrayBuffer::create(data, length); |
378 dispatchEvent(MessageEvent::create(buffer)); | 378 dispatchEvent(MessageEvent::create(buffer)); |
379 return; | 379 return; |
380 } | 380 } |
381 ASSERT_NOT_REACHED(); | 381 ASSERT_NOT_REACHED(); |
382 } | 382 } |
383 | 383 |
| 384 WebPresentationConnectionState PresentationConnection::getState() { |
| 385 return m_state; |
| 386 } |
| 387 |
384 void PresentationConnection::close() { | 388 void PresentationConnection::close() { |
385 if (m_state != WebPresentationConnectionState::Connecting && | 389 if (m_state != WebPresentationConnectionState::Connecting && |
386 m_state != WebPresentationConnectionState::Connected) { | 390 m_state != WebPresentationConnectionState::Connected) { |
387 return; | 391 return; |
388 } | 392 } |
389 WebPresentationClient* client = presentationClient(getExecutionContext()); | 393 WebPresentationClient* client = presentationClient(getExecutionContext()); |
390 if (client) | 394 if (client) |
391 client->closeSession(m_url, m_id); | 395 client->closeSession(m_url, m_id); |
392 | 396 |
393 tearDown(); | 397 tearDown(); |
394 } | 398 } |
395 | 399 |
396 void PresentationConnection::terminate() { | 400 void PresentationConnection::terminate() { |
397 if (m_state != WebPresentationConnectionState::Connected) | 401 if (m_state != WebPresentationConnectionState::Connected) |
398 return; | 402 return; |
399 WebPresentationClient* client = presentationClient(getExecutionContext()); | 403 WebPresentationClient* client = presentationClient(getExecutionContext()); |
400 if (client) | 404 if (client) |
401 client->terminateSession(m_url, m_id); | 405 client->terminateSession(m_url, m_id); |
402 | 406 |
403 tearDown(); | 407 tearDown(); |
404 } | 408 } |
405 | 409 |
406 bool PresentationConnection::matches( | 410 bool PresentationConnection::matches( |
407 const WebPresentationSessionInfo& sessionInfo) const { | 411 const WebPresentationSessionInfo& sessionInfo) const { |
408 return m_url == KURL(sessionInfo.url) && m_id == String(sessionInfo.id); | 412 return m_url == KURL(sessionInfo.url) && m_id == String(sessionInfo.id); |
409 } | 413 } |
410 | 414 |
| 415 bool PresentationConnection::matches(const String& id, const KURL& url) const { |
| 416 return m_url == url && m_id == id; |
| 417 } |
| 418 |
411 void PresentationConnection::didChangeState( | 419 void PresentationConnection::didChangeState( |
412 WebPresentationConnectionState state) { | 420 WebPresentationConnectionState state) { |
413 if (m_state == state) | 421 if (m_state == state) |
414 return; | 422 return; |
415 | 423 |
416 m_state = state; | 424 m_state = state; |
417 switch (m_state) { | 425 switch (m_state) { |
418 case WebPresentationConnectionState::Connecting: | 426 case WebPresentationConnectionState::Connecting: |
419 NOTREACHED(); | 427 NOTREACHED(); |
420 return; | 428 return; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 void PresentationConnection::tearDown() { | 494 void PresentationConnection::tearDown() { |
487 // Cancel current Blob loading if any. | 495 // Cancel current Blob loading if any. |
488 if (m_blobLoader) { | 496 if (m_blobLoader) { |
489 m_blobLoader->cancel(); | 497 m_blobLoader->cancel(); |
490 m_blobLoader.clear(); | 498 m_blobLoader.clear(); |
491 } | 499 } |
492 m_messages.clear(); | 500 m_messages.clear(); |
493 } | 501 } |
494 | 502 |
495 } // namespace blink | 503 } // namespace blink |
OLD | NEW |