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