| 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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 | 259 |
| 260 const AtomicString& PresentationConnection::state() const { | 260 const AtomicString& PresentationConnection::state() const { |
| 261 return connectionStateToString(m_state); | 261 return connectionStateToString(m_state); |
| 262 } | 262 } |
| 263 | 263 |
| 264 void PresentationConnection::send(const String& message, | 264 void PresentationConnection::send(const String& message, |
| 265 ExceptionState& exceptionState) { | 265 ExceptionState& exceptionState) { |
| 266 if (!canSendMessage(exceptionState)) | 266 if (!canSendMessage(exceptionState)) |
| 267 return; | 267 return; |
| 268 | 268 |
| 269 m_messages.append(new Message(message)); | 269 m_messages.push_back(new Message(message)); |
| 270 handleMessageQueue(); | 270 handleMessageQueue(); |
| 271 } | 271 } |
| 272 | 272 |
| 273 void PresentationConnection::send(DOMArrayBuffer* arrayBuffer, | 273 void PresentationConnection::send(DOMArrayBuffer* arrayBuffer, |
| 274 ExceptionState& exceptionState) { | 274 ExceptionState& exceptionState) { |
| 275 ASSERT(arrayBuffer && arrayBuffer->buffer()); | 275 ASSERT(arrayBuffer && arrayBuffer->buffer()); |
| 276 if (!canSendMessage(exceptionState)) | 276 if (!canSendMessage(exceptionState)) |
| 277 return; | 277 return; |
| 278 | 278 |
| 279 m_messages.append(new Message(arrayBuffer)); | 279 m_messages.push_back(new Message(arrayBuffer)); |
| 280 handleMessageQueue(); | 280 handleMessageQueue(); |
| 281 } | 281 } |
| 282 | 282 |
| 283 void PresentationConnection::send(DOMArrayBufferView* arrayBufferView, | 283 void PresentationConnection::send(DOMArrayBufferView* arrayBufferView, |
| 284 ExceptionState& exceptionState) { | 284 ExceptionState& exceptionState) { |
| 285 ASSERT(arrayBufferView); | 285 ASSERT(arrayBufferView); |
| 286 if (!canSendMessage(exceptionState)) | 286 if (!canSendMessage(exceptionState)) |
| 287 return; | 287 return; |
| 288 | 288 |
| 289 m_messages.append(new Message(arrayBufferView->buffer())); | 289 m_messages.push_back(new Message(arrayBufferView->buffer())); |
| 290 handleMessageQueue(); | 290 handleMessageQueue(); |
| 291 } | 291 } |
| 292 | 292 |
| 293 void PresentationConnection::send(Blob* data, ExceptionState& exceptionState) { | 293 void PresentationConnection::send(Blob* data, ExceptionState& exceptionState) { |
| 294 ASSERT(data); | 294 ASSERT(data); |
| 295 if (!canSendMessage(exceptionState)) | 295 if (!canSendMessage(exceptionState)) |
| 296 return; | 296 return; |
| 297 | 297 |
| 298 m_messages.append(new Message(data->blobDataHandle())); | 298 m_messages.push_back(new Message(data->blobDataHandle())); |
| 299 handleMessageQueue(); | 299 handleMessageQueue(); |
| 300 } | 300 } |
| 301 | 301 |
| 302 bool PresentationConnection::canSendMessage(ExceptionState& exceptionState) { | 302 bool PresentationConnection::canSendMessage(ExceptionState& exceptionState) { |
| 303 if (m_state != WebPresentationConnectionState::Connected) { | 303 if (m_state != WebPresentationConnectionState::Connected) { |
| 304 throwPresentationDisconnectedError(exceptionState); | 304 throwPresentationDisconnectedError(exceptionState); |
| 305 return false; | 305 return false; |
| 306 } | 306 } |
| 307 | 307 |
| 308 // The connection can send a message if there is a client available. | 308 // The connection can send a message if there is a client available. |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 void PresentationConnection::tearDown() { | 516 void PresentationConnection::tearDown() { |
| 517 // Cancel current Blob loading if any. | 517 // Cancel current Blob loading if any. |
| 518 if (m_blobLoader) { | 518 if (m_blobLoader) { |
| 519 m_blobLoader->cancel(); | 519 m_blobLoader->cancel(); |
| 520 m_blobLoader.clear(); | 520 m_blobLoader.clear(); |
| 521 } | 521 } |
| 522 m_messages.clear(); | 522 m_messages.clear(); |
| 523 } | 523 } |
| 524 | 524 |
| 525 } // namespace blink | 525 } // namespace blink |
| OLD | NEW |