| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 27 matching lines...) Expand all Loading... |
| 38 #include "core/fileapi/Blob.h" | 38 #include "core/fileapi/Blob.h" |
| 39 #include "core/fileapi/FileError.h" | 39 #include "core/fileapi/FileError.h" |
| 40 #include "core/fileapi/FileReaderLoader.h" | 40 #include "core/fileapi/FileReaderLoader.h" |
| 41 #include "core/fileapi/FileReaderLoaderClient.h" | 41 #include "core/fileapi/FileReaderLoaderClient.h" |
| 42 #include "core/inspector/InspectorInstrumentation.h" | 42 #include "core/inspector/InspectorInstrumentation.h" |
| 43 #include "core/inspector/ScriptCallStack.h" | 43 #include "core/inspector/ScriptCallStack.h" |
| 44 #include "core/loader/UniqueIdentifier.h" | 44 #include "core/loader/UniqueIdentifier.h" |
| 45 #include "modules/websockets/WebSocketChannel.h" | 45 #include "modules/websockets/WebSocketChannel.h" |
| 46 #include "modules/websockets/WebSocketChannelClient.h" | 46 #include "modules/websockets/WebSocketChannelClient.h" |
| 47 #include "platform/Logging.h" | 47 #include "platform/Logging.h" |
| 48 #include "platform/NotImplemented.h" |
| 48 #include "public/platform/Platform.h" | 49 #include "public/platform/Platform.h" |
| 49 #include "public/platform/WebSocketHandle.h" | 50 #include "public/platform/WebSocketHandle.h" |
| 50 #include "public/platform/WebString.h" | 51 #include "public/platform/WebString.h" |
| 51 #include "public/platform/WebURL.h" | 52 #include "public/platform/WebURL.h" |
| 52 #include "public/platform/WebVector.h" | 53 #include "public/platform/WebVector.h" |
| 53 #include "weborigin/SecurityOrigin.h" | 54 #include "weborigin/SecurityOrigin.h" |
| 54 #include "wtf/ArrayBuffer.h" | 55 #include "wtf/ArrayBuffer.h" |
| 55 #include "wtf/Vector.h" | 56 #include "wtf/Vector.h" |
| 56 #include "wtf/text/WTFString.h" | 57 #include "wtf/text/WTFString.h" |
| 57 | 58 |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 handleDidClose(CloseEventCodeAbnormalClosure, String()); | 255 handleDidClose(CloseEventCodeAbnormalClosure, String()); |
| 255 // handleDidClose may delete this object. | 256 // handleDidClose may delete this object. |
| 256 } | 257 } |
| 257 | 258 |
| 258 void NewWebSocketChannelImpl::disconnect() | 259 void NewWebSocketChannelImpl::disconnect() |
| 259 { | 260 { |
| 260 LOG(Network, "NewWebSocketChannelImpl %p disconnect()", this); | 261 LOG(Network, "NewWebSocketChannelImpl %p disconnect()", this); |
| 261 if (m_identifier) | 262 if (m_identifier) |
| 262 InspectorInstrumentation::didCloseWebSocket(document(), m_identifier); | 263 InspectorInstrumentation::didCloseWebSocket(document(), m_identifier); |
| 263 abortAsyncOperations(); | 264 abortAsyncOperations(); |
| 264 if (m_handle) | |
| 265 m_handle->close(CloseEventCodeAbnormalClosure, ""); | |
| 266 m_handle.clear(); | 265 m_handle.clear(); |
| 267 m_client = 0; | 266 m_client = 0; |
| 268 m_identifier = 0; | 267 m_identifier = 0; |
| 269 } | 268 } |
| 270 | 269 |
| 271 void NewWebSocketChannelImpl::suspend() | 270 void NewWebSocketChannelImpl::suspend() |
| 272 { | 271 { |
| 273 LOG(Network, "NewWebSocketChannelImpl %p suspend()", this); | 272 LOG(Network, "NewWebSocketChannelImpl %p suspend()", this); |
| 274 } | 273 } |
| 275 | 274 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 } | 385 } |
| 387 // FIXME: We should have Request / Response information to be output. | 386 // FIXME: We should have Request / Response information to be output. |
| 388 // InspectorInstrumentation::willSendWebSocketHandshakeRequest(document(), m
_identifier, ""); | 387 // InspectorInstrumentation::willSendWebSocketHandshakeRequest(document(), m
_identifier, ""); |
| 389 // InspectorInstrumentation::didReceiveWebSocketHandshakeResponse(document()
, m_identifier, ""); | 388 // InspectorInstrumentation::didReceiveWebSocketHandshakeResponse(document()
, m_identifier, ""); |
| 390 | 389 |
| 391 m_subprotocol = selectedProtocol; | 390 m_subprotocol = selectedProtocol; |
| 392 m_extensions = extensions; | 391 m_extensions = extensions; |
| 393 m_client->didConnect(); | 392 m_client->didConnect(); |
| 394 } | 393 } |
| 395 | 394 |
| 395 void NewWebSocketChannelImpl::didFail(WebSocketHandle* handle, const WebKit::Web
String& message) |
| 396 { |
| 397 LOG(Network, "NewWebSocketChannelImpl %p didFail(%p, %s)", this, handle, mes
sage.utf8().data()); |
| 398 // FIXME: Hande the failure correctly. |
| 399 // CloseEventCodeAbnormalClosure is the closing code for the closure |
| 400 // without sending or receiving a Close control frame. |
| 401 didClose(handle, false, CloseEventCodeAbnormalClosure, WebKit::WebString()); |
| 402 // |this| may be deleted. |
| 403 } |
| 404 |
| 396 void NewWebSocketChannelImpl::didReceiveData(WebSocketHandle* handle, bool fin,
WebSocketHandle::MessageType type, const char* data, size_t size) | 405 void NewWebSocketChannelImpl::didReceiveData(WebSocketHandle* handle, bool fin,
WebSocketHandle::MessageType type, const char* data, size_t size) |
| 397 { | 406 { |
| 398 LOG(Network, "NewWebSocketChannelImpl %p didReceiveData(%p, %d, %d, (%p, %zu
))", this, handle, fin, type, data, size); | 407 LOG(Network, "NewWebSocketChannelImpl %p didReceiveData(%p, %d, %d, (%p, %zu
))", this, handle, fin, type, data, size); |
| 399 ASSERT(m_handle); | 408 ASSERT(m_handle); |
| 400 ASSERT(handle == m_handle); | 409 ASSERT(handle == m_handle); |
| 401 ASSERT(m_client); | 410 ASSERT(m_client); |
| 402 // Non-final frames cannot be empty. | 411 // Non-final frames cannot be empty. |
| 403 ASSERT(fin || size); | 412 ASSERT(fin || size); |
| 404 switch (type) { | 413 switch (type) { |
| 405 case WebSocketHandle::MessageTypeText: | 414 case WebSocketHandle::MessageTypeText: |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 } else { | 446 } else { |
| 438 m_client->didReceiveMessage(message); | 447 m_client->didReceiveMessage(message); |
| 439 } | 448 } |
| 440 } else { | 449 } else { |
| 441 OwnPtr<Vector<char> > binaryData = adoptPtr(new Vector<char>); | 450 OwnPtr<Vector<char> > binaryData = adoptPtr(new Vector<char>); |
| 442 binaryData->swap(m_receivingMessageData); | 451 binaryData->swap(m_receivingMessageData); |
| 443 m_client->didReceiveBinaryData(binaryData.release()); | 452 m_client->didReceiveBinaryData(binaryData.release()); |
| 444 } | 453 } |
| 445 } | 454 } |
| 446 | 455 |
| 447 void NewWebSocketChannelImpl::didClose(WebSocketHandle* handle, unsigned short c
ode, const WebKit::WebString& reason) | 456 void NewWebSocketChannelImpl::didClose(WebSocketHandle* handle, bool wasClean, u
nsigned short code, const WebKit::WebString& reason) |
| 448 { | 457 { |
| 449 LOG(Network, "NewWebSocketChannelImpl %p didClose(%p, %u, %s)", this, handle
, code, String(reason).utf8().data()); | 458 // FIXME: Use |wasClean| appropriately. |
| 459 LOG(Network, "NewWebSocketChannelImpl %p didClose(%p, %d, %u, %s)", this, ha
ndle, wasClean, code, String(reason).utf8().data()); |
| 450 ASSERT(m_handle); | 460 ASSERT(m_handle); |
| 451 m_handle.clear(); | 461 m_handle.clear(); |
| 452 if (m_identifier) { | 462 if (m_identifier) { |
| 453 InspectorInstrumentation::didCloseWebSocket(document(), m_identifier); | 463 InspectorInstrumentation::didCloseWebSocket(document(), m_identifier); |
| 454 m_identifier = 0; | 464 m_identifier = 0; |
| 455 } | 465 } |
| 456 | 466 |
| 457 // FIXME: Maybe we should notify an error to m_client for some didClose mess
ages. | 467 // FIXME: Maybe we should notify an error to m_client for some didClose mess
ages. |
| 458 handleDidClose(code, reason); | 468 handleDidClose(code, reason); |
| 459 // handleDidClose may delete this object. | 469 // handleDidClose may delete this object. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 476 if (errorCode == FileError::ABORT_ERR) { | 486 if (errorCode == FileError::ABORT_ERR) { |
| 477 // The error is caused by cancel(). | 487 // The error is caused by cancel(). |
| 478 return; | 488 return; |
| 479 } | 489 } |
| 480 // FIXME: Generate human-friendly reason message. | 490 // FIXME: Generate human-friendly reason message. |
| 481 failAsError("Failed to load Blob: error code = " + String::number(errorCode)
); | 491 failAsError("Failed to load Blob: error code = " + String::number(errorCode)
); |
| 482 // |this| can be deleted here. | 492 // |this| can be deleted here. |
| 483 } | 493 } |
| 484 | 494 |
| 485 } // namespace WebCore | 495 } // namespace WebCore |
| OLD | NEW |