Chromium Code Reviews| 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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 249 handleDidClose(CloseEventCodeAbnormalClosure, String()); | 250 handleDidClose(CloseEventCodeAbnormalClosure, String()); |
| 250 // handleDidClose may delete this object. | 251 // handleDidClose may delete this object. |
| 251 } | 252 } |
| 252 | 253 |
| 253 void NewWebSocketChannelImpl::disconnect() | 254 void NewWebSocketChannelImpl::disconnect() |
| 254 { | 255 { |
| 255 LOG(Network, "NewWebSocketChannelImpl %p disconnect()", this); | 256 LOG(Network, "NewWebSocketChannelImpl %p disconnect()", this); |
| 256 if (m_identifier) | 257 if (m_identifier) |
| 257 InspectorInstrumentation::didCloseWebSocket(document(), m_identifier); | 258 InspectorInstrumentation::didCloseWebSocket(document(), m_identifier); |
| 258 abortAsyncOperations(); | 259 abortAsyncOperations(); |
| 259 if (m_handle) | |
| 260 m_handle->close(CloseEventCodeAbnormalClosure, ""); | |
| 261 m_handle.clear(); | 260 m_handle.clear(); |
| 262 m_client = 0; | 261 m_client = 0; |
| 263 m_identifier = 0; | 262 m_identifier = 0; |
| 264 } | 263 } |
| 265 | 264 |
| 266 void NewWebSocketChannelImpl::suspend() | 265 void NewWebSocketChannelImpl::suspend() |
| 267 { | 266 { |
| 268 LOG(Network, "NewWebSocketChannelImpl %p suspend()", this); | 267 LOG(Network, "NewWebSocketChannelImpl %p suspend()", this); |
| 269 } | 268 } |
| 270 | 269 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 381 } | 380 } |
| 382 // FIXME: We should have Request / Response information to be output. | 381 // FIXME: We should have Request / Response information to be output. |
| 383 // InspectorInstrumentation::willSendWebSocketHandshakeRequest(document(), m _identifier, ""); | 382 // InspectorInstrumentation::willSendWebSocketHandshakeRequest(document(), m _identifier, ""); |
| 384 // InspectorInstrumentation::didReceiveWebSocketHandshakeResponse(document() , m_identifier, ""); | 383 // InspectorInstrumentation::didReceiveWebSocketHandshakeResponse(document() , m_identifier, ""); |
| 385 | 384 |
| 386 m_subprotocol = selectedProtocol; | 385 m_subprotocol = selectedProtocol; |
| 387 m_extensions = extensions; | 386 m_extensions = extensions; |
| 388 m_client->didConnect(); | 387 m_client->didConnect(); |
| 389 } | 388 } |
| 390 | 389 |
| 390 void NewWebSocketChannelImpl::didFail(WebSocketHandle* handle, const WebKit::Web String& message) | |
| 391 { | |
| 392 LOG(Network, "NewWebSocketChannelImpl %p didFail(%p, %s)", this, handle, mes sage.utf8().data()); | |
| 393 // FIXME: Hande the failure correctly. | |
| 394 const unsigned short abnormalClosure = 1006; | |
|
abarth-chromium
2013/10/31 17:54:49
Where does this number come from? If it's in the
yhirano
2013/11/01 03:51:47
Done.
| |
| 395 didClose(handle, false, abnormalClosure, ""); | |
| 396 // |this| may be deleted. | |
| 397 } | |
| 398 | |
| 391 void NewWebSocketChannelImpl::didReceiveData(WebSocketHandle* handle, bool fin, WebSocketHandle::MessageType type, const char* data, size_t size) | 399 void NewWebSocketChannelImpl::didReceiveData(WebSocketHandle* handle, bool fin, WebSocketHandle::MessageType type, const char* data, size_t size) |
| 392 { | 400 { |
| 393 LOG(Network, "NewWebSocketChannelImpl %p didReceiveData(%p, %d, %d, (%p, %zu ))", this, handle, fin, type, data, size); | 401 LOG(Network, "NewWebSocketChannelImpl %p didReceiveData(%p, %d, %d, (%p, %zu ))", this, handle, fin, type, data, size); |
| 394 ASSERT(m_handle); | 402 ASSERT(m_handle); |
| 395 ASSERT(handle == m_handle); | 403 ASSERT(handle == m_handle); |
| 396 ASSERT(m_client); | 404 ASSERT(m_client); |
| 397 // Non-final frames cannot be empty. | 405 // Non-final frames cannot be empty. |
| 398 ASSERT(fin || size); | 406 ASSERT(fin || size); |
| 399 switch (type) { | 407 switch (type) { |
| 400 case WebSocketHandle::MessageTypeText: | 408 case WebSocketHandle::MessageTypeText: |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 432 } else { | 440 } else { |
| 433 m_client->didReceiveMessage(message); | 441 m_client->didReceiveMessage(message); |
| 434 } | 442 } |
| 435 } else { | 443 } else { |
| 436 OwnPtr<Vector<char> > binaryData = adoptPtr(new Vector<char>); | 444 OwnPtr<Vector<char> > binaryData = adoptPtr(new Vector<char>); |
| 437 binaryData->swap(m_receivingMessageData); | 445 binaryData->swap(m_receivingMessageData); |
| 438 m_client->didReceiveBinaryData(binaryData.release()); | 446 m_client->didReceiveBinaryData(binaryData.release()); |
| 439 } | 447 } |
| 440 } | 448 } |
| 441 | 449 |
| 442 void NewWebSocketChannelImpl::didClose(WebSocketHandle* handle, unsigned short c ode, const WebKit::WebString& reason) | 450 void NewWebSocketChannelImpl::didClose(WebSocketHandle* handle, bool wasClean, u nsigned short code, const WebKit::WebString& reason) |
| 443 { | 451 { |
| 444 LOG(Network, "NewWebSocketChannelImpl %p didClose(%p, %u, %s)", this, handle , code, String(reason).utf8().data()); | 452 // FIXME: Use |wasClean| appropriately. |
| 453 LOG(Network, "NewWebSocketChannelImpl %p didClose(%p, %d, %u, %s)", this, ha ndle, wasClean, code, String(reason).utf8().data()); | |
| 445 ASSERT(m_handle); | 454 ASSERT(m_handle); |
| 446 m_handle.clear(); | 455 m_handle.clear(); |
| 447 if (m_identifier) { | 456 if (m_identifier) { |
| 448 InspectorInstrumentation::didCloseWebSocket(document(), m_identifier); | 457 InspectorInstrumentation::didCloseWebSocket(document(), m_identifier); |
| 449 m_identifier = 0; | 458 m_identifier = 0; |
| 450 } | 459 } |
| 451 | 460 |
| 452 // FIXME: Maybe we should notify an error to m_client for some didClose mess ages. | 461 // FIXME: Maybe we should notify an error to m_client for some didClose mess ages. |
| 453 handleDidClose(code, reason); | 462 handleDidClose(code, reason); |
| 454 // handleDidClose may delete this object. | 463 // handleDidClose may delete this object. |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 471 if (errorCode == FileError::ABORT_ERR) { | 480 if (errorCode == FileError::ABORT_ERR) { |
| 472 // The error is caused by cancel(). | 481 // The error is caused by cancel(). |
| 473 return; | 482 return; |
| 474 } | 483 } |
| 475 // FIXME: Generate human-friendly reason message. | 484 // FIXME: Generate human-friendly reason message. |
| 476 failAsError("Failed to load Blob: error code = " + String::number(errorCode) ); | 485 failAsError("Failed to load Blob: error code = " + String::number(errorCode) ); |
| 477 // |this| can be deleted here. | 486 // |this| can be deleted here. |
| 478 } | 487 } |
| 479 | 488 |
| 480 } // namespace WebCore | 489 } // namespace WebCore |
| OLD | NEW |